public class AnnotationVisitor
extends Object
An Annotation visitor responsible for:
AnnotationNode conforms to annotation metaAnnotationNode AST to reflect real annotation meta| Constructor and description |
|---|
AnnotationVisitor(SourceUnit source, ErrorCollector errorCollector)Creates a new annotation visitor. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected void |
addError(String msg)Reports an error against the current annotation. |
|
protected void |
addError(String msg, ASTNode node)Reports an error against the supplied AST node. |
|
public void |
checkCircularReference(ClassNode searchClass, ClassNode attrType, Expression startExp)Checks for circular references in nested annotations, which would cause infinite recursion. |
|
public void |
checkReturnType(ClassNode attrType, ASTNode node)Verifies that an annotation member return type is valid under Java annotation rules. |
|
public void |
setReportClass(ClassNode node)Sets the class to report errors against. |
|
public AnnotationNode |
visit(AnnotationNode node)Visits and validates an annotation node, checking that it conforms to annotation metadata and enhancing the AST to reflect real annotation semantics. |
|
protected void |
visitAnnotationExpression(String attrName, AnnotationConstantExpression valueExpr, ClassNode attrType)Validates a nested annotation attribute. |
|
protected void |
visitConstantExpression(String attrName, ConstantExpression valueExpr, ClassNode attrType)Validates a constant-valued annotation attribute. |
|
protected void |
visitEnumExpression(String attrName, PropertyExpression valueExpr, ClassNode attrType)Validates an enum-valued annotation attribute. |
|
protected void |
visitExpression(String attrName, Expression valueExpr, ClassNode attrType)Validates an annotation attribute value against its declared type. |
|
protected void |
visitListExpression(String attrName, ListExpression listExpr, ClassNode elementType)Validates each element of an array-valued annotation attribute. |
Creates a new annotation visitor.
source - the source unit being compilederrorCollector - the error collector for reporting validation errorsReports an error against the current annotation.
msg - the error messageReports an error against the supplied AST node.
msg - the error messagenode - the node to associate with the errorChecks for circular references in nested annotations, which would cause infinite recursion.
searchClass - the annotation class being searched for in the dependency chainattrType - the attribute type to checkstartExp - the expression where the check started, for error reportingVerifies that an annotation member return type is valid under Java annotation rules.
attrType - the declared return typenode - the node to report against on errorSets the class to report errors against.
node - the class node for error reportingVisits and validates an annotation node, checking that it conforms to annotation metadata and enhancing the AST to reflect real annotation semantics.
node - the annotation node to visit and validateValidates a nested annotation attribute.
attrName - the attribute namevalueExpr - the nested annotation expressionattrType - the declared annotation typeValidates a constant-valued annotation attribute.
attrName - the attribute namevalueExpr - the constant expressionattrType - the declared attribute typeValidates an enum-valued annotation attribute.
attrName - the attribute namevalueExpr - the enum constant expressionattrType - the declared enum typeValidates an annotation attribute value against its declared type.
attrName - the attribute namevalueExpr - the supplied value expressionattrType - the declared attribute typeValidates each element of an array-valued annotation attribute.
attrName - the attribute namelistExpr - the list expression representing the attribute valueelementType - the declared component typeCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.