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,..] :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, _, type(basic, int, 0), 'aField', 'null'),
annotationT(#Annotation, #Parent, #EnclosingElement, #AnnotationType, [#KeyValue]),
literalT(#Literal, #KeyValue, #EnclosingElement, type(class, Type0, 0), 'Member').
 
%case 2
fieldT(#Field, _, type(basic, int, 0), '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,       [memberValueT])
]).
Last modified: 2014/07/29 14:18
*