public class AnnotatedNode
extends ASTNode
implements GroovydocHolder
Base class for any AST node which is capable of being annotated
| Type Params | Return Type | Name and description |
|---|---|---|
|
public AnnotationNode |
addAnnotation(ClassNode type)Adds a new annotation of the specified type to this node. |
|
public void |
addAnnotation(AnnotationNode annotation)Attaches an annotation node to this AST node. |
|
public void |
addAnnotations(List<AnnotationNode> annotations)Attaches a list of annotations to this AST node. |
|
public List<AnnotationNode> |
getAnnotations()Returns all annotations attached to this AST node. |
|
public List<AnnotationNode> |
getAnnotations(ClassNode type)Returns annotations of a specific type attached to this AST node. |
|
public ClassNode |
getDeclaringClass()Returns the class that declares this annotated node. |
|
public Groovydoc |
getGroovydoc()Returns the Groovydoc associated with this node. |
|
public AnnotatedNode |
getInstance()Returns this node instance (used by GroovydocHolder interface). |
|
public boolean |
hasNoRealSourcePosition()Checks whether this node has a real source position. |
|
public boolean |
isSynthetic()Checks whether this node was added by the compiler (synthetic). |
|
public void |
setDeclaringClass(ClassNode declaringClass)Sets the class that declares this annotated node. |
|
public void |
setHasNoRealSourcePosition(boolean hasNoRealSourcePosition)Marks whether this node has a real source position. |
|
public void |
setSynthetic(boolean synthetic)Marks this node as having been added by the compiler (synthetic). |
| Methods inherited from class | Name |
|---|---|
class ASTNode |
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit |
Adds a new annotation of the specified type to this node. Creates an AnnotationNode and attaches it.
type - the annotation type as a ClassNodeAttaches an annotation node to this AST node. Does nothing if the annotation is null. Lazily initializes the annotations list.
annotation - the AnnotationNode to attachAttaches a list of annotations to this AST node. Individually adds each annotation in the list.
annotations - list of AnnotationNode objects to attachReturns all annotations attached to this AST node. Annotations are runtime-visible or source-level metadata attached to language elements.
Returns annotations of a specific type attached to this AST node. Filters the annotation list by the provided type.
type - the annotation type to filter byReturns the class that declares this annotated node. For class members (fields, methods), this is the enclosing class. Returns null for top-level declarations.
Returns the Groovydoc associated with this node. Groovydoc is documentation metadata attached to source elements. Returns Groovydoc.EMPTY_GROOVYDOC if no documentation is available.
Returns this node instance (used by GroovydocHolder interface).
Checks whether this node has a real source position. Returns false for compiler-generated nodes (like default constructors). This flag distinguishes user-written code from synthetic compiler output.
Checks whether this node was added by the compiler (synthetic).
Synthetic nodes include auto-generated methods, constructors, and other compiler-inserted elements.
Note: This flag is distinct from the synthetic modifier for classes, fields, and methods in bytecode.
Sets the class that declares this annotated node. Establishes the ownership relationship for class members.
declaringClass - the declaring ClassNodeMarks whether this node has a real source position. Used to distinguish compiler-generated nodes from user-written code.
hasNoRealSourcePosition - false if this node was explicitly written in source Marks this node as having been added by the compiler (synthetic).
Synthetic nodes include auto-generated methods, constructors, and other compiler-inserted elements.
Note: This flag is distinct from the synthetic modifier for classes, fields, and methods in bytecode.
synthetic - true to mark as compiler-generated, false for user-written