|
Griffon 1.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.griffon.ast.GriffonASTUtils
public class GriffonASTUtils
Helper methods for working with Groovy AST trees.
Field Summary | |
---|---|
static Token |
AND
|
static Token |
ASSIGN
|
static Token |
CMP
|
static Token |
EQ
|
static Token |
INSTANCEOF
|
static Token |
NE
|
static ArgumentListExpression |
NO_ARGS
|
static ClassNode[] |
NO_EXCEPTIONS
|
static Parameter[] |
NO_PARAMS
|
static Token |
OR
|
static Expression |
SUPER
|
static Expression |
THIS
|
Constructor Summary | |
GriffonASTUtils()
|
Method Summary | |
---|---|
static boolean
|
addMethod(ClassNode classNode, MethodNode methodNode)
|
static boolean
|
addMethod(ClassNode classNode, MethodNode methodNode, boolean replace)
|
static void
|
addReadOnlyProperty(ClassNode classNode, String propertyName, ClassNode propertyClass, Object value)
|
static BinaryExpression
|
and(Expression lhv, Expression rhv)
|
static ArgumentListExpression
|
args(Expression... expressions)
|
static ArgumentListExpression
|
args(List expressions)
|
static BinaryExpression
|
assign(Expression lhv, Expression rhv)
|
static Statement
|
assigns(Expression expression, Expression value)
|
static BlockStatement
|
block(Statement... stms)
|
static MethodCallExpression
|
call(Expression receiver, String methodName, ArgumentListExpression args)
|
static StaticMethodCallExpression
|
call(ClassNode receiver, String methodName, ArgumentListExpression args)
|
static ClassExpression
|
classx(ClassNode clazz)
|
static ClassExpression
|
classx(Class clazz)
|
static BinaryExpression
|
cmp(Expression lhv, Expression rhv)
|
static ConstantExpression
|
constx(Object val)
|
static ConstructorCallExpression
|
ctor(ClassNode type, Expression args)
|
static Statement
|
decls(Expression lhv, Expression rhv)
|
static BinaryExpression
|
eq(Expression lhv, Expression rhv)
|
static FieldExpression
|
field(FieldNode fieldNode)
|
static FieldExpression
|
field(ClassNode owner, String fieldName)
|
static String
|
getFullName(ClassNode classNode)
Gets the full name of a ClassNode. |
static ClassNode
|
getFurthestParent(ClassNode classNode)
|
static boolean
|
hasField(ClassNode classNode, String name, int modifiers, ClassNode type)
|
static boolean
|
hasOrInheritsField(ClassNode classNode, String name, int modifiers, ClassNode type)
|
static boolean
|
hasOrInheritsProperty(ClassNode classNode, String propertyName)
|
static boolean
|
hasProperty(ClassNode classNode, String propertyName)
Returns whether a classNode has the specified property or not |
static Statement
|
ifs(Expression cond, Expression trueExpr)
|
static Statement
|
ifs(Expression cond, Expression trueExpr, Expression falseExpr)
|
static Statement
|
ifs_no_return(Expression cond, Expression trueExpr)
|
static Statement
|
ifs_no_return(Expression cond, Expression trueExpr, Expression falseExpr)
|
static Statement
|
ifs_no_return(Expression cond, Statement trueStmnt)
|
static Statement
|
ifs_no_return(Expression cond, Statement trueStmnt, Statement falseStmnt)
|
static boolean
|
implementsMethod(ClassNode classNode, MethodNode methodNode)
|
static boolean
|
implementsOrInheritsMethod(ClassNode classNode, MethodNode methodNode)
|
static boolean
|
implementsOrInheritsZeroArgMethod(ClassNode classNode, String methodName, List ignoreClasses)
|
static boolean
|
implementsZeroArgMethod(ClassNode classNode, String methodName)
Tests whether the ClasNode implements the specified method name. |
static void
|
injectConstant(ClassNode classNode, String propertyName, Class propertyClass, Object value)
|
static FieldNode
|
injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Object value)
|
static FieldNode
|
injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Object value, boolean deep)
|
static FieldNode
|
injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Expression initialExpression)
|
static FieldNode
|
injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Expression initialExpression, boolean deep)
|
static void
|
injectInterface(ClassNode classNode, ClassNode type)
|
static void
|
injectInterface(ClassNode classNode, ClassNode type, boolean deep)
|
static void
|
injectMethod(ClassNode classNode, MethodNode methodNode)
|
static void
|
injectMethod(ClassNode classNode, MethodNode methodNode, boolean deep)
|
static void
|
injectProperty(ClassNode classNode, String propertyName, Class propertyClass)
|
static void
|
injectProperty(ClassNode classNode, String propertyName, Class propertyClass, Object value)
|
static void
|
injectProperty(ClassNode classNode, String propertyName, int modifiers, Class propertyClass)
|
static void
|
injectProperty(ClassNode classNode, String propertyName, int modifiers, Class propertyClass, Object value)
|
static void
|
injectProperty(ClassNode classNode, String propertyName, ClassNode propertyClass)
|
static void
|
injectProperty(ClassNode classNode, String propertyName, int modifiers, ClassNode propertyClass)
|
static void
|
injectProperty(ClassNode classNode, String propertyName, int modifiers, ClassNode propertyClass, Object value)
|
static BinaryExpression
|
iof(Expression lhv, Expression rhv)
|
static BinaryExpression
|
iof(Expression lhv, ClassNode rhv)
|
static boolean
|
isEnum(ClassNode classNode)
|
static BinaryExpression
|
ne(Expression lhv, Expression rhv)
|
static NotExpression
|
not(Expression expr)
|
static BinaryExpression
|
or(Expression lhv, Expression rhv)
|
static Parameter
|
param(ClassNode type, String name)
|
static Parameter
|
param(ClassNode type, String name, Expression initialExpression)
|
static boolean
|
parametersEqual(Parameter[] a, Parameter[] b)
@return true if the two arrays are of the same size and have the same contents |
static Parameter[]
|
params(Parameter... params)
|
static Expression
|
prop(Expression owner, String property)
|
static Expression
|
prop(Expression owner, Expression property)
|
static Statement
|
returns(Expression expr)
|
static ExpressionStatement
|
stmnt(Expression expression)
|
static ClassNode[]
|
throwing(ClassNode... exceptions)
|
static VariableExpression
|
var(String name)
|
static VariableExpression
|
var(String name, ClassNode type)
|
static ArgumentListExpression
|
vars(String... names)
|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Field Detail |
---|
public static final Token AND
public static final Token ASSIGN
public static final Token CMP
public static final Token EQ
public static final Token INSTANCEOF
public static final Token NE
public static final ArgumentListExpression NO_ARGS
public static final ClassNode[] NO_EXCEPTIONS
public static final Parameter[] NO_PARAMS
public static final Token OR
public static final Expression SUPER
public static final Expression THIS
Constructor Detail |
---|
GriffonASTUtils()
Method Detail |
---|
public static boolean addMethod(ClassNode classNode, MethodNode methodNode)
public static boolean addMethod(ClassNode classNode, MethodNode methodNode, boolean replace)
public static void addReadOnlyProperty(ClassNode classNode, String propertyName, ClassNode propertyClass, Object value)
public static BinaryExpression and(Expression lhv, Expression rhv)
public static ArgumentListExpression args(Expression... expressions)
public static ArgumentListExpression args(List expressions)
public static BinaryExpression assign(Expression lhv, Expression rhv)
public static Statement assigns(Expression expression, Expression value)
public static BlockStatement block(Statement... stms)
public static MethodCallExpression call(Expression receiver, String methodName, ArgumentListExpression args)
public static StaticMethodCallExpression call(ClassNode receiver, String methodName, ArgumentListExpression args)
public static ClassExpression classx(ClassNode clazz)
public static ClassExpression classx(Class clazz)
public static BinaryExpression cmp(Expression lhv, Expression rhv)
public static ConstantExpression constx(Object val)
public static ConstructorCallExpression ctor(ClassNode type, Expression args)
public static Statement decls(Expression lhv, Expression rhv)
public static BinaryExpression eq(Expression lhv, Expression rhv)
public static FieldExpression field(FieldNode fieldNode)
public static FieldExpression field(ClassNode owner, String fieldName)
public static String getFullName(ClassNode classNode)
classNode
- The class node
public static ClassNode getFurthestParent(ClassNode classNode)
public static boolean hasField(ClassNode classNode, String name, int modifiers, ClassNode type)
public static boolean hasOrInheritsField(ClassNode classNode, String name, int modifiers, ClassNode type)
public static boolean hasOrInheritsProperty(ClassNode classNode, String propertyName)
public static boolean hasProperty(ClassNode classNode, String propertyName)
classNode
- The ClassNodepropertyName
- The name of the property
public static Statement ifs(Expression cond, Expression trueExpr)
public static Statement ifs(Expression cond, Expression trueExpr, Expression falseExpr)
public static Statement ifs_no_return(Expression cond, Expression trueExpr)
public static Statement ifs_no_return(Expression cond, Expression trueExpr, Expression falseExpr)
public static Statement ifs_no_return(Expression cond, Statement trueStmnt)
public static Statement ifs_no_return(Expression cond, Statement trueStmnt, Statement falseStmnt)
public static boolean implementsMethod(ClassNode classNode, MethodNode methodNode)
public static boolean implementsOrInheritsMethod(ClassNode classNode, MethodNode methodNode)
@SuppressWarnings("unchecked") public static boolean implementsOrInheritsZeroArgMethod(ClassNode classNode, String methodName, List ignoreClasses)
public static boolean implementsZeroArgMethod(ClassNode classNode, String methodName)
classNode
- The ClassNodemethodName
- The method name
public static void injectConstant(ClassNode classNode, String propertyName, Class propertyClass, Object value)
public static FieldNode injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Object value)
public static FieldNode injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Object value, boolean deep)
public static FieldNode injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Expression initialExpression)
public static FieldNode injectField(ClassNode classNode, String name, int modifiers, ClassNode type, Expression initialExpression, boolean deep)
public static void injectInterface(ClassNode classNode, ClassNode type)
public static void injectInterface(ClassNode classNode, ClassNode type, boolean deep)
public static void injectMethod(ClassNode classNode, MethodNode methodNode)
public static void injectMethod(ClassNode classNode, MethodNode methodNode, boolean deep)
public static void injectProperty(ClassNode classNode, String propertyName, Class propertyClass)
public static void injectProperty(ClassNode classNode, String propertyName, Class propertyClass, Object value)
public static void injectProperty(ClassNode classNode, String propertyName, int modifiers, Class propertyClass)
public static void injectProperty(ClassNode classNode, String propertyName, int modifiers, Class propertyClass, Object value)
public static void injectProperty(ClassNode classNode, String propertyName, ClassNode propertyClass)
public static void injectProperty(ClassNode classNode, String propertyName, int modifiers, ClassNode propertyClass)
public static void injectProperty(ClassNode classNode, String propertyName, int modifiers, ClassNode propertyClass, Object value)
public static BinaryExpression iof(Expression lhv, Expression rhv)
public static BinaryExpression iof(Expression lhv, ClassNode rhv)
public static boolean isEnum(ClassNode classNode)
public static BinaryExpression ne(Expression lhv, Expression rhv)
public static NotExpression not(Expression expr)
public static BinaryExpression or(Expression lhv, Expression rhv)
public static Parameter param(ClassNode type, String name)
public static Parameter param(ClassNode type, String name, Expression initialExpression)
public static boolean parametersEqual(Parameter[] a, Parameter[] b)
public static Parameter[] params(Parameter... params)
public static Expression prop(Expression owner, String property)
public static Expression prop(Expression owner, Expression property)
public static Statement returns(Expression expr)
public static ExpressionStatement stmnt(Expression expression)
public static ClassNode[] throwing(ClassNode... exceptions)
public static VariableExpression var(String name)
public static VariableExpression var(String name, ClassNode type)
public static ArgumentListExpression vars(String... names)
Groovy Documentation