Package org.codehaus.groovy.ast.tools
Class GeneralUtils
- java.lang.Object
- 
- org.codehaus.groovy.ast.tools.GeneralUtils
 
- 
 public class GeneralUtils extends Object Handy methods when working with the Groovy AST
- 
- 
Constructor SummaryConstructors Constructor Description GeneralUtils()
 - 
Method Summary
 
- 
- 
- 
Field Detail- 
ASSIGNpublic static final Token ASSIGN 
 - 
EQpublic static final Token EQ 
 - 
NEpublic static final Token NE 
 - 
NOT_IDENTICALpublic static final Token NOT_IDENTICAL 
 - 
LTpublic static final Token LT 
 - 
ANDpublic static final Token AND 
 - 
ORpublic static final Token OR 
 - 
CMPpublic static final Token CMP 
 - 
INSTANCEOFpublic static final Token INSTANCEOF 
 
- 
 - 
Method Detail- 
andXpublic static BinaryExpression andX(Expression lhv, Expression rhv) 
 - 
argspublic static ArgumentListExpression args(Expression... expressions) 
 - 
argspublic static ArgumentListExpression args(List<Expression> expressions) 
 - 
argspublic static ArgumentListExpression args(Parameter... parameters) 
 - 
argspublic static ArgumentListExpression args(String... names) 
 - 
asXpublic static CastExpression asX(ClassNode type, Expression expression) 
 - 
assignSpublic static Statement assignS(Expression target, Expression value) 
 - 
assignNullSpublic static Statement assignNullS(Expression target) 
 - 
assignXpublic static Expression assignX(Expression target, Expression value) 
 - 
attrXpublic static Expression attrX(Expression oe, Expression prop) 
 - 
binXpublic static BinaryExpression binX(Expression left, Token token, Expression right) 
 - 
blockpublic static BlockStatement block(VariableScope scope, Statement... stmts) 
 - 
blockpublic static BlockStatement block(VariableScope scope, List<Statement> stmts) 
 - 
blockpublic static BlockStatement block(Statement... stmts) 
 - 
boolXpublic static BooleanExpression boolX(Expression expr) 
 - 
bytecodeXpublic static BytecodeExpression bytecodeX(Consumer<org.objectweb.asm.MethodVisitor> writer) 
 - 
bytecodeXpublic static BytecodeExpression bytecodeX(ClassNode type, Consumer<org.objectweb.asm.MethodVisitor> writer) 
 - 
callSuperXpublic static MethodCallExpression callSuperX(String methodName) 
 - 
callSuperXpublic static MethodCallExpression callSuperX(String methodName, Expression args) 
 - 
callThisXpublic static MethodCallExpression callThisX(String methodName) 
 - 
callThisXpublic static MethodCallExpression callThisX(String methodName, Expression args) 
 - 
callXpublic static MethodCallExpression callX(Expression receiver, String methodName) 
 - 
callXpublic static MethodCallExpression callX(Expression receiver, String methodName, Expression args) 
 - 
callXpublic static MethodCallExpression callX(Expression receiver, Expression method, Expression args) 
 - 
callXpublic static StaticMethodCallExpression callX(ClassNode receiver, String methodName) 
 - 
callXpublic static StaticMethodCallExpression callX(ClassNode receiver, String methodName, Expression args) 
 - 
castXpublic static CastExpression castX(ClassNode type, Expression expression) 
 - 
castXpublic static CastExpression castX(ClassNode type, Expression expression, boolean ignoreAutoboxing) 
 - 
catchSpublic static CatchStatement catchS(Parameter variable, Statement code) 
 - 
classXpublic static ClassExpression classX(ClassNode clazz) 
 - 
classXpublic static ClassExpression classX(Class<?> clazz) 
 - 
closureXpublic static ClosureExpression closureX(Parameter[] params, Statement code) 
 - 
closureXpublic static ClosureExpression closureX(Statement code) 
 - 
cmpXpublic static BinaryExpression cmpX(Expression lhv, Expression rhv) Builds a binary expression that compares two values.- Parameters:
- lhv- expression for the value to compare from
- rhv- expression for the value value to compare to
- Returns:
- the expression comparing two values
 
 - 
constXpublic static ConstantExpression constX(Object val) 
 - 
constXpublic static ConstantExpression constX(Object val, boolean keepPrimitive) 
 - 
ctorXpublic static ConstructorCallExpression ctorX(ClassNode type, Expression args) 
 - 
ctorXpublic static ConstructorCallExpression ctorX(ClassNode type) 
 - 
ctorSuperSpublic static Statement ctorSuperS(Expression args) 
 - 
ctorSuperXpublic static ConstructorCallExpression ctorSuperX(Expression args) 
 - 
ctorThisSpublic static Statement ctorThisS(Expression args) 
 - 
ctorThisXpublic static ConstructorCallExpression ctorThisX(Expression args) 
 - 
ctorSuperSpublic static Statement ctorSuperS() 
 - 
ctorSuperXpublic static ConstructorCallExpression ctorSuperX() 
 - 
ctorThisSpublic static Statement ctorThisS() 
 - 
ctorThisXpublic static ConstructorCallExpression ctorThisX() 
 - 
declSpublic static Statement declS(Expression target, Expression init) 
 - 
declXpublic static DeclarationExpression declX(Expression target, Expression init) 
 - 
entryXpublic static MapEntryExpression entryX(Expression key, Expression value) 
 - 
eqXpublic static BinaryExpression eqX(Expression lhv, Expression rhv) 
 - 
equalsNullXpublic static BooleanExpression equalsNullX(Expression argExpr) 
 - 
fieldXpublic static FieldExpression fieldX(FieldNode fieldNode) 
 - 
fieldXpublic static FieldExpression fieldX(ClassNode owner, String fieldName) 
 - 
findArgpublic static Expression findArg(String argName) 
 - 
getAllMethodspublic static List<MethodNode> getAllMethods(ClassNode type) 
 - 
getAllPropertiespublic static List<PropertyNode> getAllProperties(ClassNode type) 
 - 
getInstanceNonPropertyFieldspublic static List<FieldNode> getInstanceNonPropertyFields(ClassNode cNode) 
 - 
getInstanceNonPropertyFieldNamespublic static List<String> getInstanceNonPropertyFieldNames(ClassNode cNode) 
 - 
getInstancePropertiespublic static List<PropertyNode> getInstanceProperties(ClassNode cNode) 
 - 
getInterfacesAndSuperInterfacespublic static Set<ClassNode> getInterfacesAndSuperInterfaces(ClassNode type) 
 - 
getAllPropertiespublic static List<PropertyNode> getAllProperties(Set<String> names, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly) 
 - 
getAllPropertiespublic static List<PropertyNode> getAllProperties(Set<String> names, ClassNode origType, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly) 
 - 
getAllPropertiespublic static List<PropertyNode> getAllProperties(Set<String> names, ClassNode origType, ClassNode cNode, boolean includeProperties, boolean includeFields, boolean includePseudoGetters, boolean includePseudoSetters, boolean traverseSuperClasses, boolean skipReadonly, boolean reverse, boolean allNames, boolean includeStatic) 
 - 
getterThisXpublic static Expression getterThisX(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.- Parameters:
- annotatedNode- the class node where the property node is accessed from
- pNode- the property being accessed
- Returns:
- a method call expression or a property expression
 
 - 
getterXpublic static Expression getterX(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.- Parameters:
- annotatedNode- the class node where the property node is accessed from
- receiver- the object having the property
- pNode- the property being accessed
- Returns:
- a method call expression or a property expression
 
 - 
hasClassXpublic static BinaryExpression hasClassX(Expression instance, ClassNode cNode) 
 - 
hasEqualFieldXpublic static BinaryExpression hasEqualFieldX(FieldNode fNode, Expression other) 
 - 
hasEqualPropertyXpublic static BinaryExpression hasEqualPropertyX(ClassNode annotatedNode, PropertyNode pNode, VariableExpression other) 
 - 
hasEqualPropertyX@Deprecated public static BinaryExpression hasEqualPropertyX(PropertyNode pNode, Expression other) Deprecated.
 - 
hasSameFieldXpublic static BooleanExpression hasSameFieldX(FieldNode fNode, Expression other) 
 - 
hasSamePropertyXpublic static BooleanExpression hasSamePropertyX(PropertyNode pNode, Expression other) 
 - 
ifElseS$$bridge@Deprecated public static Statement ifElseS$$bridge(Expression cond, Statement thenStmt, Statement elseStmt) Deprecated.
 - 
ifElseSpublic static IfStatement ifElseS(Expression cond, Statement thenStmt, Statement elseStmt) 
 - 
ifS$$bridge@Deprecated public static Statement ifS$$bridge(Expression cond, Expression trueExpr) Deprecated.
 - 
ifSpublic static IfStatement ifS(Expression cond, Expression trueExpr) 
 - 
ifS$$bridge@Deprecated public static Statement ifS$$bridge(Expression cond, Statement trueStmt) Deprecated.
 - 
ifSpublic static IfStatement ifS(Expression cond, Statement trueStmt) 
 - 
indexXpublic static Expression indexX(Expression target, Expression value) 
 - 
isInstanceOfXpublic static BooleanExpression isInstanceOfX(Expression objectExpression, ClassNode cNode) 
 - 
isNullXpublic static BooleanExpression isNullX(Expression expr) Alias forequalsNullX(Expression)
 - 
isOneXpublic static BooleanExpression isOneX(Expression expr) 
 - 
isTrueXpublic static BooleanExpression isTrueX(Expression argExpr) 
 - 
isZeroXpublic static BooleanExpression isZeroX(Expression expr) 
 - 
listXpublic static ListExpression listX(List<Expression> args) 
 - 
list2argspublic static ListExpression list2args(List<?> args) 
 - 
classList2argspublic static ListExpression classList2args(List<String> args) 
 - 
localVarXpublic static VariableExpression localVarX(String name) 
 - 
localVarXpublic static VariableExpression localVarX(String name, ClassNode type) 
 - 
ltXpublic static BinaryExpression ltX(Expression lhv, Expression rhv) 
 - 
mapXpublic static MapExpression mapX(List<MapEntryExpression> expressions) 
 - 
neXpublic static BinaryExpression neX(Expression lhv, Expression rhv) 
 - 
notIdenticalXpublic static BinaryExpression notIdenticalX(Expression lhv, Expression rhv) 
 - 
notNullXpublic static BooleanExpression notNullX(Expression argExpr) 
 - 
notXpublic static NotExpression notX(Expression expr) 
 - 
nullXpublic static ConstantExpression nullX() 
 - 
orXpublic static BinaryExpression orX(Expression lhv, Expression rhv) 
 - 
parampublic static Parameter param(ClassNode type, String name, Expression initialExpression) 
 - 
plusXpublic static BinaryExpression plusX(Expression lhv, Expression rhv) 
 - 
propXpublic static PropertyExpression propX(Expression owner, String property) 
 - 
propX$$bridge@Deprecated public static Expression propX$$bridge(Expression owner, String property) Deprecated.
 - 
propXpublic static PropertyExpression propX(Expression owner, Expression property) 
 - 
propX$$bridge@Deprecated public static Expression propX$$bridge(Expression owner, Expression property) Deprecated.
 - 
propXpublic static PropertyExpression propX(Expression owner, Expression property, boolean safe) 
 - 
returnSpublic static Statement returnS(Expression expr) 
 - 
safeExpressionpublic static Statement safeExpression(Expression fieldExpr, Expression expression) 
 - 
sameXpublic static BooleanExpression sameX(Expression self, Expression other) 
 - 
stmtpublic static Statement stmt(Expression expr) 
 - 
ternaryXpublic static TernaryExpression ternaryX(Expression cond, Expression trueExpr, Expression elseExpr) 
 - 
thisPropXpublic static PropertyExpression thisPropX(boolean implicit, String property) 
 - 
throwSpublic static ThrowStatement throwS(Expression expr) 
 - 
tryCatchSpublic static TryCatchStatement tryCatchS(Statement tryStatement) 
 - 
tryCatchSpublic static TryCatchStatement tryCatchS(Statement tryStatement, Statement finallyStatement) 
 - 
varXpublic static VariableExpression varX(String name) 
 - 
varXpublic static VariableExpression varX(Variable variable) 
 - 
varXpublic static VariableExpression varX(String name, ClassNode type) 
 - 
copyAnnotatedNodeAnnotationspublic 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.
 - 
copyAnnotatedNodeAnnotationspublic static void copyAnnotatedNodeAnnotations(AnnotatedNode annotatedNode, List<AnnotationNode> copied, List<AnnotationNode> notCopied, boolean includeGenerated) Copies all candidateAnnotations with retention policyRetentionPolicy.RUNTIMEandRetentionPolicy.CLASS.Generatedannotations will be copied ifincludeGeneratedis true.Annotations with GeneratedClosuremembers are not supported at present.
 - 
createConstructorStatementDefaultpublic static Statement createConstructorStatementDefault(FieldNode fNode) 
 - 
getGetterNamepublic static String getGetterName(PropertyNode pNode) 
 - 
convertASTToSourcepublic static String convertASTToSource(ReaderSource readerSource, ASTNode expression) throws Exception Converts an expression into the String source. Only some specific expressions like closure expression support this.- Parameters:
- readerSource- a source
- expression- an expression. Can't be null
- Returns:
- the source the closure was created from
- Throws:
- IllegalArgumentException- when expression is null
- Exception- when closure can't be read from source
 
 - 
copyStatementsWithSuperAdjustmentpublic static boolean copyStatementsWithSuperAdjustment(ClosureExpression pre, BlockStatement body) 
 - 
hasDeclaredMethodpublic static boolean hasDeclaredMethod(ClassNode cNode, String name, int argsCount) 
 - 
isDefaultVisibilitypublic static boolean isDefaultVisibility(int modifiers) 
 - 
makeDescriptorWithoutReturnType@Deprecated public static String makeDescriptorWithoutReturnType(MethodNode mn) Deprecated.use MethodNodeUtils#methodDescriptorWithoutReturnType(MethodNode) instead
 
- 
 
-