public AnnotationTree TypeAnnotation(Tree type, List<? extends ExpressionTree> arguments) { ListBuffer<JCExpression> lb = new ListBuffer<JCExpression>(); for (ExpressionTree t : arguments) lb.append((JCExpression)t); return make.at(NOPOS).TypeAnnotation((JCTree)type, lb.toList()); }
public JCTree visitAnnotation(AnnotationTree node, P p) { JCAnnotation t = (JCAnnotation) node; JCTree annotationType = copy(t.annotationType, p); List<JCExpression> args = copy(t.args, p); if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) { JCAnnotation newTA = M.at(t.pos).TypeAnnotation(annotationType, args); newTA.attribute = t.attribute; return newTA; } else { JCAnnotation newT = M.at(t.pos).Annotation(annotationType, args); newT.attribute = t.attribute; return newT; } }
public JCTree visitAnnotation(AnnotationTree node, P p) { JCAnnotation t = (JCAnnotation) node; JCTree annotationType = copy(t.annotationType, p); List<JCExpression> args = copy(t.args, p); if (t.getKind() == Tree.Kind.TYPE_ANNOTATION) { JCAnnotation newTA = M.at(t.pos).TypeAnnotation(annotationType, args); newTA.attribute = t.attribute; return newTA; } else { JCAnnotation newT = M.at(t.pos).Annotation(annotationType, args); newT.attribute = t.attribute; return newT; } }
public JCAnnotation visitTypeCompoundInternal(Attribute.TypeCompound compound) { ListBuffer<JCExpression> args = new ListBuffer<JCExpression>(); for (List<Pair<Symbol.MethodSymbol,Attribute>> values = compound.values; values.nonEmpty(); values=values.tail) { Pair<MethodSymbol,Attribute> pair = values.head; JCExpression valueTree = translate(pair.snd); args.append(Assign(Ident(pair.fst), valueTree).setType(valueTree.type)); } return TypeAnnotation(Type(compound.type), args.toList()); } public void visitArray(Attribute.Array array) {
/** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ] * * @param pos position of "@" token * @param kind Whether to parse an ANNOTATION or TYPE_ANNOTATION */ JCAnnotation annotation(int pos, Tag kind) { // accept(AT); // AT consumed by caller checkAnnotations(); if (kind == Tag.TYPE_ANNOTATION) { checkTypeAnnotations(); } JCTree ident = qualident(false); List<JCExpression> fieldValues = annotationFieldValuesOpt(); JCAnnotation ann; if (kind == Tag.ANNOTATION) { ann = F.at(pos).Annotation(ident, fieldValues); } else if (kind == Tag.TYPE_ANNOTATION) { ann = F.at(pos).TypeAnnotation(ident, fieldValues); } else { throw new AssertionError("Unhandled annotation kind: " + kind); } storeEnd(ann, S.prevToken().endPos); return ann; }
public JCAnnotation visitTypeCompoundInternal(Attribute.TypeCompound compound) { ListBuffer<JCExpression> args = new ListBuffer<JCExpression>(); for (List<Pair<Symbol.MethodSymbol,Attribute>> values = compound.values; values.nonEmpty(); values=values.tail) { Pair<MethodSymbol,Attribute> pair = values.head; JCExpression valueTree = translate(pair.snd); args.append(Assign(Ident(pair.fst), valueTree).setType(valueTree.type)); } return TypeAnnotation(Type(compound.type), args.toList()); } public void visitArray(Attribute.Array array) {
/** Annotation = "@" Qualident [ "(" AnnotationFieldValues ")" ] * * @param pos position of "@" token * @param kind Whether to parse an ANNOTATION or TYPE_ANNOTATION */ JCAnnotation annotation(int pos, Tag kind) { // accept(AT); // AT consumed by caller checkAnnotations(); if (kind == Tag.TYPE_ANNOTATION) { checkTypeAnnotations(); } JCTree ident = qualident(false); List<JCExpression> fieldValues = annotationFieldValuesOpt(); JCAnnotation ann; if (kind == Tag.ANNOTATION) { ann = F.at(pos).Annotation(ident, fieldValues); } else if (kind == Tag.TYPE_ANNOTATION) { ann = F.at(pos).TypeAnnotation(ident, fieldValues); } else { throw new AssertionError("Unhandled annotation kind: " + kind); } storeEnd(ann, S.prevToken().endPos); return ann; }