|
Groovy 1.7.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.AnnotatedNode
org.codehaus.groovy.ast.ClassNode
class ClassNode extends AnnotatedNode
Represents a class in the AST.
A ClassNode should be created using the methods in ClassHelper.
This ClassNode may be used to represent a class declaration or
any other type. This class uses a proxy mechanism allowing to
create a class for a plain name at AST creation time. In another
phase of the compiler the real ClassNode for the plain name may be
found. To avoid the need of exchanging this ClassNode with an
instance of the correct ClassNode the correct ClassNode is set as
redirect. Most method calls are then redirected to that ClassNode.
There are three types of ClassNodes:
Nested Class Summary | |
---|---|
class |
ClassNode.MapOfLists
|
Field Summary | |
---|---|
static ClassNode[] |
EMPTY_ARRAY
|
static ClassNode |
SUPER
|
static ClassNode |
THIS
|
protected Class |
clazz
|
protected List |
innerClasses
|
protected boolean |
isPrimaryNode
|
protected Object |
lazyInitLock
|
Constructor Summary | |
ClassNode()
|
Method Summary | |
---|---|
def
|
ClassNode(Class c)
Creates a ClassNode from a real class. |
def
|
ClassNode(String name, int modifiers, ClassNode superClass)
base class |
def
|
ClassNode(String name, int modifiers, ClassNode superClass, ClassNode[] interfaces, MixinNode[] mixins)
base class |
void
|
addConstructor(ConstructorNode node)
|
ConstructorNode
|
addConstructor(int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement code)
|
void
|
addField(FieldNode node)
|
FieldNode
|
addField(String name, int modifiers, ClassNode type, Expression initialValue)
|
void
|
addFieldFirst(FieldNode node)
|
FieldNode
|
addFieldFirst(String name, int modifiers, ClassNode type, Expression initialValue)
|
void
|
addInterface(ClassNode type)
|
void
|
addMethod(MethodNode node)
|
MethodNode
|
addMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)
If a method with the given name and parameters is already defined then it is returned otherwise the given method is added to this node. |
void
|
addMixin(MixinNode mixin)
|
void
|
addObjectInitializerStatements(Statement statements)
Adds a statement to the object initializer. |
void
|
addProperty(PropertyNode node)
|
PropertyNode
|
addProperty(String name, int modifiers, ClassNode type, Expression initialValueExpression, Statement getterBlock, Statement setterBlock)
|
void
|
addStaticInitializerStatements(List staticStatements, boolean fieldInit)
|
MethodNode
|
addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)
Adds a synthetic method as part of the compilation process |
void
|
addTransform(Class transform, ASTNode node)
|
boolean
|
declaresInterface(ClassNode classNode)
or if one of its interfaces extends directly or indirectly the interface NOTE: Doesn't consider an interface to implement itself. |
boolean
|
equals(Object o)
|
List
|
getAbstractMethods()
ClassNode or null if there are no such methods |
List
|
getAllDeclaredMethods()
|
Set
|
getAllInterfaces()
|
List
|
getAnnotations()
|
List
|
getAnnotations(ClassNode type)
|
CompileUnit
|
getCompileUnit()
|
ClassNode
|
getComponentType()
|
List
|
getDeclaredConstructors()
|
FieldNode
|
getDeclaredField(String name)
Finds a field matching the given name in this class. |
MethodNode
|
getDeclaredMethod(String name, Parameter[] parameters)
Finds a method matching the given name and parameters in this class. |
List
|
getDeclaredMethods(String name)
This methods returns a list of all methods of the given name defined in the current class |
Map
|
getDeclaredMethodsMap()
|
MethodNode
|
getEnclosingMethod()
|
FieldNode
|
getField(String name)
Finds a field matching the given name in this class or a parent class. |
List
|
getFields()
|
GenericsType[]
|
getGenericsTypes()
|
MethodNode
|
getGetterMethod(String getterName)
|
Iterator
|
getInnerClasses()
|
ClassNode[]
|
getInterfaces()
|
MethodNode
|
getMethod(String name, Parameter[] parameters)
Finds a method matching the given name and parameters in this class or any parent class. |
List
|
getMethods()
|
List
|
getMethods(String name)
This methods creates a list of all methods with this name of the current class and of all super classes |
MixinNode[]
|
getMixins()
|
int
|
getModifiers()
|
ModuleNode
|
getModule()
|
String
|
getName()
|
String
|
getNameWithoutPackage()
|
List
|
getObjectInitializerStatements()
|
ClassNode
|
getOuterClass()
Helper method to avoid casting to inner class |
FieldNode
|
getOuterField(String name)
inner class |
PackageNode
|
getPackage()
|
String
|
getPackageName()
|
ClassNode
|
getPlainNodeReference()
|
List
|
getProperties()
|
PropertyNode
|
getProperty(String name)
|
MethodNode
|
getSetterMethod(String setterName)
|
ClassNode
|
getSuperClass()
|
Map
|
getTransforms(CompilePhase phase)
|
Class
|
getTypeClass()
|
ClassNode[]
|
getUnresolvedInterfaces()
|
ClassNode[]
|
getUnresolvedInterfaces(boolean useRedirect)
|
String
|
getUnresolvedName()
|
ClassNode
|
getUnresolvedSuperClass()
|
ClassNode
|
getUnresolvedSuperClass(boolean useRedirect)
|
boolean
|
hasDeclaredMethod(String name, Parameter[] parameters)
|
boolean
|
hasMethod(String name, Parameter[] parameters)
|
boolean
|
hasPackageName()
|
boolean
|
hasPossibleMethod(String name, Expression arguments)
Returns true if the given method has a possibly matching instance method with the given name and arguments. |
boolean
|
hasPossibleStaticMethod(String name, Expression arguments)
Returns true if the given method has a possibly matching static method with the given name and arguments. |
boolean
|
hasProperty(String name)
|
int
|
hashCode()
|
boolean
|
implementsInterface(ClassNode classNode)
|
boolean
|
isAnnotated()
|
boolean
|
isAnnotationDefinition()
|
boolean
|
isArray()
|
boolean
|
isDerivedFrom(ClassNode type)
|
boolean
|
isDerivedFromGroovyObject()
i.e. it implements GroovyObject |
boolean
|
isEnum()
|
boolean
|
isGenericsPlaceHolder()
|
boolean
|
isInterface()
|
boolean
|
isPrimaryClassNode()
|
boolean
|
isResolved()
|
boolean
|
isScript()
|
boolean
|
isScriptBody()
|
boolean
|
isStaticClass()
Is this class delcared in a static method (such as a closure / inner class declared in a static method) |
boolean
|
isUsingGenerics()
|
ClassNode
|
makeArray()
Returns a ClassNode representing an array of the class represented by this ClassNode |
protected boolean
|
parametersEqual(Parameter[] a, Parameter[] b)
|
void
|
positionStmtsAfterEnumInitStmts(List staticFieldStatements)
|
ClassNode
|
redirect()
Returns the ClassNode this ClassNode is redirecting to. |
void
|
renameField(String oldName, String newName)
|
void
|
setAnnotated(boolean flag)
Marks if the current class uses annotations or not |
protected void
|
setCompileUnit(CompileUnit cu)
|
void
|
setEnclosingMethod(MethodNode enclosingMethod)
|
void
|
setGenericsPlaceHolder(boolean b)
|
void
|
setGenericsTypes(GenericsType[] genericsTypes)
|
void
|
setInterfaces(ClassNode[] interfaces)
|
void
|
setModifiers(int modifiers)
|
void
|
setModule(ModuleNode module)
|
String
|
setName(String name)
|
void
|
setRedirect(ClassNode cn)
Sets this instance as proxy for the given ClassNode. |
void
|
setScript(boolean script)
|
void
|
setScriptBody(boolean scriptBody)
|
void
|
setStaticClass(boolean staticClass)
|
void
|
setSuperClass(ClassNode superClass)
Sets the superclass of this ClassNode |
void
|
setUnresolvedSuperClass(ClassNode sn)
|
void
|
setUsingGenerics(boolean b)
|
String
|
toString()
|
MethodNode
|
tryFindPossibleMethod(String name, Expression arguments)
|
void
|
visitContents(GroovyClassVisitor visitor)
|
Methods inherited from class AnnotatedNode | |
---|---|
addAnnotation, addAnnotations, getAnnotations, getAnnotations, getDeclaringClass, isSynthetic, setDeclaringClass, setSynthetic |
Methods inherited from class ASTNode | |
---|---|
getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setSourcePosition, visit |
Methods inherited from class Object | |
---|---|
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll |
Field Detail |
---|
static final ClassNode[] EMPTY_ARRAY
static final ClassNode SUPER
static final ClassNode THIS
protected Class clazz
protected List innerClasses
protected boolean isPrimaryNode
protected Object lazyInitLock
Constructor Detail |
---|
ClassNode()
Method Detail |
---|
public def ClassNode(Class c)
public def ClassNode(String name, int modifiers, ClassNode superClass)
public def ClassNode(String name, int modifiers, ClassNode superClass, ClassNode[] interfaces, MixinNode[] mixins)
public void addConstructor(ConstructorNode node)
public ConstructorNode addConstructor(int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement code)
public void addField(FieldNode node)
public FieldNode addField(String name, int modifiers, ClassNode type, Expression initialValue)
public void addFieldFirst(FieldNode node)
public FieldNode addFieldFirst(String name, int modifiers, ClassNode type, Expression initialValue)
public void addInterface(ClassNode type)
public void addMethod(MethodNode node)
public MethodNode addMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)
public void addMixin(MixinNode mixin)
public void addObjectInitializerStatements(Statement statements)
public void addProperty(PropertyNode node)
public PropertyNode addProperty(String name, int modifiers, ClassNode type, Expression initialValueExpression, Statement getterBlock, Statement setterBlock)
public void addStaticInitializerStatements(List staticStatements, boolean fieldInit)
public MethodNode addSyntheticMethod(String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)
public void addTransform(Class transform, ASTNode node)
public boolean declaresInterface(ClassNode classNode)
public boolean equals(Object o)
public List getAbstractMethods()
public List getAllDeclaredMethods()
public Set getAllInterfaces()
public List getAnnotations()
public List getAnnotations(ClassNode type)
public CompileUnit getCompileUnit()
public ClassNode getComponentType()
public List getDeclaredConstructors()
public FieldNode getDeclaredField(String name)
public MethodNode getDeclaredMethod(String name, Parameter[] parameters)
public List getDeclaredMethods(String name)
public Map getDeclaredMethodsMap()
public MethodNode getEnclosingMethod()
public FieldNode getField(String name)
public List getFields()
public GenericsType[] getGenericsTypes()
public MethodNode getGetterMethod(String getterName)
public Iterator getInnerClasses()
public ClassNode[] getInterfaces()
public MethodNode getMethod(String name, Parameter[] parameters)
public List getMethods()
public List getMethods(String name)
public MixinNode[] getMixins()
public int getModifiers()
public ModuleNode getModule()
public String getName()
public String getNameWithoutPackage()
public List getObjectInitializerStatements()
public ClassNode getOuterClass()
public FieldNode getOuterField(String name)
public PackageNode getPackage()
public String getPackageName()
public ClassNode getPlainNodeReference()
public List getProperties()
public PropertyNode getProperty(String name)
public MethodNode getSetterMethod(String setterName)
public ClassNode getSuperClass()
public Map getTransforms(CompilePhase phase)
public Class getTypeClass()
public ClassNode[] getUnresolvedInterfaces()
public ClassNode[] getUnresolvedInterfaces(boolean useRedirect)
public String getUnresolvedName()
public ClassNode getUnresolvedSuperClass()
public ClassNode getUnresolvedSuperClass(boolean useRedirect)
public boolean hasDeclaredMethod(String name, Parameter[] parameters)
public boolean hasMethod(String name, Parameter[] parameters)
public boolean hasPackageName()
public boolean hasPossibleMethod(String name, Expression arguments)
public boolean hasPossibleStaticMethod(String name, Expression arguments)
public boolean hasProperty(String name)
public int hashCode()
public boolean implementsInterface(ClassNode classNode)
public boolean isAnnotated()
public boolean isAnnotationDefinition()
public boolean isArray()
public boolean isDerivedFrom(ClassNode type)
public boolean isDerivedFromGroovyObject()
public boolean isEnum()
public boolean isGenericsPlaceHolder()
public boolean isInterface()
public boolean isPrimaryClassNode()
public boolean isResolved()
public boolean isScript()
public boolean isScriptBody()
public boolean isStaticClass()
public boolean isUsingGenerics()
public ClassNode makeArray()
protected boolean parametersEqual(Parameter[] a, Parameter[] b)
public void positionStmtsAfterEnumInitStmts(List staticFieldStatements)
public ClassNode redirect()
public void renameField(String oldName, String newName)
public void setAnnotated(boolean flag)
protected void setCompileUnit(CompileUnit cu)
public void setEnclosingMethod(MethodNode enclosingMethod)
public void setGenericsPlaceHolder(boolean b)
public void setGenericsTypes(GenericsType[] genericsTypes)
public void setInterfaces(ClassNode[] interfaces)
public void setModifiers(int modifiers)
public void setModule(ModuleNode module)
public String setName(String name)
public void setRedirect(ClassNode cn)
public void setScript(boolean script)
public void setScriptBody(boolean scriptBody)
public void setStaticClass(boolean staticClass)
public void setSuperClass(ClassNode superClass)
public void setUnresolvedSuperClass(ClassNode sn)
public void setUsingGenerics(boolean b)
public String toString()
public MethodNode tryFindPossibleMethod(String name, Expression arguments)
public void visitContents(GroovyClassVisitor visitor)
Copyright © 2003-2009 The Codehaus. All rights reserved.