/** * Parses the Java annotation contained in a {@link String} and returns a * {@link AnnotationExpr} that represents it. * * @param annotation * {@link String} containing Java annotation * @return AnnotationExpr representing the Java annotation * @throws ParseException * if the source code has parser errors * @throws IOException */ public static AnnotationExpr parseAnnotation(final String annotation) throws ParseException { StringReader sr = new StringReader(annotation); AnnotationExpr ae = new ASTParser(sr).Annotation(); sr.close(); return ae; }
final public PackageDeclaration PackageDeclaration() throws ParseException { List annotations = null; AnnotationExpr ann; NameExpr name; int line; int column; label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AT: ; break; default: jj_la1[3] = jj_gen; break label_3; } ann = Annotation(); annotations = add(annotations, ann); } jj_consume_token(PACKAGE); line=token.beginLine; column=token.beginColumn; name = Name(); jj_consume_token(SEMICOLON); PackageDeclaration tmp = new PackageDeclaration(line, column, token.endLine, token.endColumn,annotations, name); {if (true) return tmp;} throw new Error("Missing return statement in function"); }
final public PackageDeclaration PackageDeclaration() throws ParseException { List annotations = null; AnnotationExpr ann; NameExpr name; int line; int column; label_3: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AT: ; break; default: jj_la1[3] = jj_gen; break label_3; } ann = Annotation(); annotations = add(annotations, ann); } jj_consume_token(PACKAGE); line=token.beginLine; column=token.beginColumn; name = Name(); jj_consume_token(SEMICOLON); {if (true) return new PackageDeclaration(line, column, token.endLine, token.endColumn,annotations, name);} throw new Error("Missing return statement in function"); }
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AT: ret = Annotation(); break; case LBRACE:
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case AT: ret = Annotation(); break; case LBRACE:
break label_9; ann = Annotation(); annotations = add(annotations, ann); if(line==-1){line=ann.getBeginLine(); column=ann.getBeginColumn();}
break label_9; ann = Annotation(); annotations = add(annotations, ann); if(line==-1){line=ann.getBeginLine(); column=ann.getBeginColumn();}
break; case AT: ann = Annotation(); annotations = add(annotations, ann); if(beginLine==-1) {beginLine=ann.getBeginLine(); beginColumn=ann.getBeginColumn();} break;
break; case AT: ann = Annotation(); annotations = add(annotations, ann); if(beginLine==-1) {beginLine=ann.getBeginLine(); beginColumn=ann.getBeginColumn();} break;