annotationT(#id, #parent, #encl, #annotationType, [#keyValue_1,..] )

Represents an annotation (expression). Java 5 Syntax Element

Arguments

#id: id
the unique ID assigned to this fact.

#parent: id
the ID of the fact that represents the parent of this fact in the prolog AST. Either the ID of the annotated element or membervaluet fact in case of a nested annotation. e.g. @Ann2 in @Ann(value = 1, ann1 = @Ann2(id=1))

#encl: id
the enclosing annotated declaration, expression or statement. Here we extended the Java 5 annotation model.

annotationType: classT
the referenced annotation type.

[#keyValue_1,..] :AnnotationExpression, memberValueT
list of IDs of the member value pairs.

Sample Java Source

@ThisAnnotation("Member")   //case 1
private int aField;      

@ThisAnnotation             //case 2 : If the annotation is a marker annotation the expression is 
private int anotherField;   //         flagged by a markerAnnotationT(#id) fact.

Its PEF Representation

%case 1
fieldT(#Field, _, #Fieldtype, 'aField', 'null'),
annotationT(#Annotation, #Parent, #EnclosingElement, #AnnotationType, [#KeyValue]),
literalT(#Literal, #KeyValue, #EnclosingElement, #Literaltype, 'Member').

%case 2
fieldT(#Field, _, #Fieldtype, 'anotherField', 'null'),
annotationT(#Annotation, #Enclosing, #Enclosing, #AnnotationType, []),
markerAnnotationT(#Annotation).

AST Specification

ast_node_def('Java',annotationT,[
     ast_arg(id,             mult(1,1,no ),  id, [id]),
     ast_arg(parent,         mult(1,1,no ),  id, [id]),
     ast_arg(encl,           mult(1,1,no ),  id, [id]),
     ast_arg(annotationType, mult(1,1,no ),  id, [classT]),
     ast_arg(values,         mult(0,*,ord ), id, [annotationExpressionType, memberValueT])
]).
research/jtransformer/api/java/pefs/3.0/annotationt.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024