final public void AnnotationTypeDeclaration(int modifiers) throws ParseException { ASTAnnotationTypeDeclaration jjtn000 = new ASTAnnotationTypeDeclaration(this, JJTANNOTATIONTYPEDECLARATION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1));Token t; jjtn000.setModifiers(modifiers); try { jj_consume_token(AT); checkForBadAnnotationUsage(); checkForBadTypeIdentifierUsage(t.image); jjtn000.setImage(t.image); AnnotationTypeBody(); } catch (Throwable jjte000) { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0));
@Override public Object visit(ASTAnnotationTypeDeclaration node, Object data) { if (node.isAbstract()) { // may have several violations, with different explanations reportUnnecessaryModifiers(data, node, Modifier.ABSTRACT, "annotations types are implicitly abstract"); } if (!node.isNested()) { return data; } // a public annotation within an interface or annotation if (node.isPublic() && node.enclosingTypeIsA(TypeKind.INTERFACE, TypeKind.ANNOTATION)) { reportUnnecessaryModifiers(data, node, Modifier.PUBLIC, "members of " + getPrintableNodeKind(node.getEnclosingTypeDeclaration()) + " types are implicitly public"); } if (node.isStatic()) { // a static annotation reportUnnecessaryModifiers(data, node, Modifier.STATIC, "nested annotation types are implicitly static"); } return data; }
@Override public List<ASTAnyTypeBodyDeclaration> getDeclarations() { return getFirstChildOfType(ASTAnnotationTypeBody.class) .findChildrenOfType(ASTAnyTypeBodyDeclaration.class); } }
@Override public Object visit(ASTName node, Object data) { /* * Only doing this for nodes where getNameDeclaration is null this means * it's not a named node, i.e. Static reference or Annotation Doing this * for memory - TODO: Investigate if there is a valid memory concern or * not */ if (node.getNameDeclaration() == null) { // Skip these scenarios as there is no type to populate in these // cases: // 1) Parent is a PackageDeclaration, which is not a type // 2) Parent is a ImportDeclaration, this is handled elsewhere. if (!(node.jjtGetParent() instanceof ASTPackageDeclaration || node.jjtGetParent() instanceof ASTImportDeclaration)) { String name = node.getImage(); if (name.indexOf(StringAndCharConstants.DOT) != -1) { name = name.substring(0, name.indexOf(StringAndCharConstants.DOT)); } populateType(node, name); } } else { // Carry over the type from the declaration if (node.getNameDeclaration().getNode() instanceof TypeNode) { node.setType(((TypeNode)node.getNameDeclaration().getNode()).getType()); } } return super.visit(node, data); }
@Override public Object visit(ASTAnnotationTypeDeclaration node, Object data) { if (node.isAbstract()) { // may have several violations, with different explanations reportUnnecessaryModifiers(data, node, Modifier.ABSTRACT, "annotations types are implicitly abstract"); } if (!node.isNested()) { return data; } // a public annotation within an interface or annotation if (node.isPublic() && node.enclosingTypeIsA(TypeKind.INTERFACE, TypeKind.ANNOTATION)) { reportUnnecessaryModifiers(data, node, Modifier.PUBLIC, "members of " + getPrintableNodeKind(node.getEnclosingTypeDeclaration()) + " types are implicitly public"); } if (node.isStatic()) { // a static annotation reportUnnecessaryModifiers(data, node, Modifier.STATIC, "nested annotation types are implicitly static"); } return data; }
final public void AnnotationTypeDeclaration(int modifiers) throws ParseException { ASTAnnotationTypeDeclaration jjtn000 = new ASTAnnotationTypeDeclaration(this, JJTANNOTATIONTYPEDECLARATION); boolean jjtc000 = true; jjtree.openNodeScope(jjtn000); jjtn000.jjtSetFirstToken(getToken(1));Token t; jjtn000.setModifiers(modifiers); try { jj_consume_token(AT); checkForBadAnnotationUsage(); checkForBadTypeIdentifierUsage(t.image); jjtn000.setImage(t.image); AnnotationTypeBody(); } catch (Throwable jjte000) { if (jjtc000) { jjtree.closeNodeScope(jjtn000, true); jjtn000.jjtSetLastToken(getToken(0));
@Override public List<ASTAnyTypeBodyDeclaration> getDeclarations() { return getFirstChildOfType(ASTAnnotationTypeBody.class) .findChildrenOfType(ASTAnyTypeBodyDeclaration.class); } }