Package org.codehaus.groovy.ast.tools
Class GeneralUtils
java.lang.Object
org.codehaus.groovy.ast.tools.GeneralUtils
Handy methods when working with the Groovy AST
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BinaryExpressionandX(Expression lhv, Expression rhv) static ArgumentListExpressionstatic ArgumentListExpressionargs(List<Expression> expressions) static ArgumentListExpressionargs(Expression... expressions) static ArgumentListExpressionstatic StatementassignS(Expression target, Expression value) static ExpressionassignX(Expression target, Expression value) static ExpressionattrX(Expression oe, Expression prop) static BinaryExpressionbinX(Expression left, Token token, Expression right) static BlockStatementstatic BlockStatementblock(VariableScope varScope, List<Statement> stmts) static BlockStatementblock(VariableScope varScope, Statement... stmts) static MethodCallExpressioncallSuperX(String methodName) static MethodCallExpressioncallSuperX(String methodName, Expression args) static MethodCallExpressionstatic MethodCallExpressioncallThisX(String methodName, Expression args) static StaticMethodCallExpressionstatic StaticMethodCallExpressioncallX(ClassNode receiver, String methodName, Expression args) static MethodCallExpressioncallX(Expression receiver, String methodName) static MethodCallExpressioncallX(Expression receiver, String methodName, Expression args) static MethodCallExpressioncallX(Expression receiver, Expression method, Expression args) static CastExpressioncastX(ClassNode type, Expression expression) static CastExpressioncastX(ClassNode type, Expression expression, boolean ignoreAutoboxing) static CatchStatementstatic ClassExpressionstatic ClassExpressionstatic Parameter[]cloneParams(Parameter[] source) static ClosureExpressionstatic ClosureExpressionstatic BinaryExpressioncmpX(Expression lhv, Expression rhv) static ConstantExpressionstatic ConstantExpressionstatic voidcopyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied) Copies all candidateAnnotations with retention policyRetentionPolicy.RUNTIMEandRetentionPolicy.CLASS.static Statementstatic Statementstatic StatementctorSuperS(Expression args) static Statementstatic StatementctorThisS(Expression args) static ConstructorCallExpressionstatic ConstructorCallExpressionctorX(ClassNode type, Expression args) static StatementdeclS(Expression target, Expression init) static BooleanExpressionequalsNullX(Expression argExpr) static BinaryExpressioneqX(Expression lhv, Expression rhv) static FieldExpressionstatic FieldExpressionstatic Expressionstatic List<MethodNode> getAllMethods(ClassNode type) static List<PropertyNode> getAllProperties(ClassNode type) static StringgetGetterName(PropertyNode pNode) static List<PropertyNode> getInstanceProperties(ClassNode cNode) getSuperPropertyFields(ClassNode cNode) static ExpressiongetterThisX(ClassNode annotatedNode, PropertyNode pNode) This method is similar topropX(Expression, Expression)but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access.static ExpressiongetterX(ClassNode annotatedNode, Expression receiver, PropertyNode pNode) This method is similar topropX(Expression, Expression)but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access.static ExpressiongetterX(ClassNode annotatedNode, PropertyNode pNode) Deprecated.use getterThisX insteadstatic BinaryExpressionhasClassX(Expression instance, ClassNode cNode) static booleanhasDeclaredMethod(ClassNode cNode, String name, int argsCount) static BinaryExpressionhasEqualFieldX(FieldNode fNode, Expression other) static BinaryExpressionhasEqualPropertyX(PropertyNode pNode, Expression other) static BooleanExpressionhasSameFieldX(FieldNode fNode, Expression other) static BooleanExpressionhasSamePropertyX(PropertyNode pNode, Expression other) static StatementifElseS(Expression cond, Statement thenStmt, Statement elseStmt) static StatementifS(Expression cond, Expression trueExpr) static StatementifS(Expression cond, Statement trueStmt) static ExpressionindexX(Expression target, Expression value) static BooleanExpressionisInstanceOfX(Expression objectExpression, ClassNode cNode) static BooleanExpressionisOneX(Expression expr) static booleanisOrImplements(ClassNode type, ClassNode interfaceType) static BooleanExpressionisTrueX(Expression argExpr) static BooleanExpressionisZeroX(Expression expr) static BinaryExpressionltX(Expression lhv, Expression rhv) static Stringstatic BinaryExpressionneX(Expression lhv, Expression rhv) static BooleanExpressionnotNullX(Expression argExpr) static NotExpressionnotX(Expression expr) static BinaryExpressionorX(Expression lhv, Expression rhv) static Parameterstatic Parameterparam(ClassNode type, String name, Expression initialExpression) static Parameter[]static BinaryExpressionplusX(Expression lhv, Expression rhv) static ExpressionpropX(Expression owner, String property) static ExpressionpropX(Expression owner, Expression property) static StatementreturnS(Expression expr) static StatementsafeExpression(Expression fieldExpr, Expression expression) static BooleanExpressionsameX(Expression self, Expression other) static Statementstmt(Expression expr) static TernaryExpressionternaryX(Expression cond, Expression trueExpr, Expression elseExpr) static ThrowStatementthrowS(Expression expr) static VariableExpressionstatic VariableExpressionstatic VariableExpression
-
Field Details
-
ASSIGN
-
EQ
-
NE
-
LT
-
AND
-
OR
-
CMP
-
-
Constructor Details
-
GeneralUtils
public GeneralUtils()
-
-
Method Details
-
andX
-
args
-
args
-
args
-
args
-
assignS
-
assignX
-
attrX
-
binX
-
block
-
block
-
block
-
callSuperX
-
callSuperX
-
callThisX
-
callThisX
-
callX
-
callX
-
callX
-
callX
public static StaticMethodCallExpression callX(ClassNode receiver, String methodName, Expression args) -
callX
-
castX
-
castX
-
classX
-
classX
-
closureX
-
closureX
-
cloneParams
-
cmpX
-
constX
-
constX
-
copyAnnotatedNodeAnnotations
public static void copyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied) Copies all candidateAnnotations with retention policyRetentionPolicy.RUNTIMEandRetentionPolicy.CLASS.Annotations with
GeneratedClosuremembers are not supported at present. -
createConstructorStatementDefault
-
ctorX
-
ctorX
-
ctorSuperS
-
ctorThisS
-
ctorSuperS
-
ctorThisS
-
declS
-
eqX
-
equalsNullX
-
fieldX
-
fieldX
-
findArg
-
getAllMethods
-
getAllProperties
-
getGetterName
-
getInstanceNonPropertyFields
-
getInstanceProperties
-
getInstancePropertyFields
-
getInterfacesAndSuperInterfaces
-
getSuperNonPropertyFields
-
getSuperPropertyFields
-
hasClassX
-
hasDeclaredMethod
-
hasEqualFieldX
-
hasEqualPropertyX
-
hasSameFieldX
-
hasSamePropertyX
-
ifElseS
-
ifS
-
ifS
-
indexX
-
isInstanceOfX
-
isOneX
-
isOrImplements
-
isTrueX
-
isZeroX
-
ltX
-
makeDescriptorWithoutReturnType
-
neX
-
notNullX
-
notX
-
orX
-
param
-
param
-
params
-
plusX
-
propX
-
propX
-
returnS
-
safeExpression
-
sameX
-
stmt
-
ternaryX
-
varX
-
varX
-
varX
-
throwS
-
catchS
-
getterX
Deprecated.use getterThisX instead -
getterThisX
This method is similar topropX(Expression, Expression)but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access.- Parameters:
annotatedNode- the class node where the property node is accessed frompNode- the property being accessed- Returns:
- a method call expression or a property expression
-
getterX
This method is similar topropX(Expression, Expression)but will make sure that if the property being accessed is defined inside the classnode provided as a parameter, then a getter call is generated instead of a field access.- Parameters:
annotatedNode- the class node where the property node is accessed fromreceiver- the object having the propertypNode- the property being accessed- Returns:
- a method call expression or a property expression
-