private String getNameImage(ASTPrimaryExpression node) { ASTPrimaryPrefix prefix = node.getFirstDescendantOfType(ASTPrimaryPrefix.class); ASTName name = prefix.getFirstDescendantOfType(ASTName.class); String image = null; if (name != null) { image = name.getImage(); } return image; }
public int getArrayDepth() { ASTVariableDeclaratorId astVariableDeclaratorId = (ASTVariableDeclaratorId) node; ASTType typeNode = astVariableDeclaratorId.getTypeNode(); if (typeNode != null) { return ((Dimensionable) typeNode.jjtGetParent()).getArrayDepth(); } else { return 0; } }
private void checkForBadAnonymousDiamondUsage() { if (jdkVersion < 9) { ASTAllocationExpression node = (ASTAllocationExpression)jjtree.peekNode(); ASTTypeArguments types = node.getFirstChildOfType(ASTClassOrInterfaceType.class).getFirstChildOfType(ASTTypeArguments.class); if (node.isAnonymousClass() && types != null && types.isDiamond()) { throwParseException("Cannot use '<>' with anonymous inner classes when running in JDK inferior to 9 mode!"); } } } /**
/** Reinitialise. */ public void ReInit(CharStream stream) { token_source.ReInit(stream); token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_lookingAhead = false; jjtree.reset(); jj_gen = 0; for (int i = 0; i < 168; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); }
private boolean hasImports(ASTCompilationUnit cu, String className) { List<ASTImportDeclaration> imports = cu.findDescendantsOfType(ASTImportDeclaration.class); for (ASTImportDeclaration importDeclaration : imports) { ASTName name = importDeclaration.getFirstChildOfType(ASTName.class); if (name != null && name.hasImageEqualTo(className)) { return true; } } return false; } }
/** Constructor with user supplied CharStream. */ public JavaParser(CharStream stream) { token_source = new JavaParserTokenManager(stream); token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; for (int i = 0; i < 168; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); }
public int getArgumentCount() { if (this.jjtGetNumChildren() == 1) { return ((ASTArguments) this.jjtGetChild(0)).getArgumentCount(); } else { return ((ASTArguments) this.jjtGetChild(1)).getArgumentCount(); } }
/** Constructor with generated Token Manager. */ public JavaParser(JavaParserTokenManager tm) { token_source = tm; token = new Token(); token.next = jj_nt = token_source.getNextToken(); jj_gen = 0; for (int i = 0; i < 168; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); }
public boolean isArray() { ASTVariableDeclaratorId astVariableDeclaratorId = (ASTVariableDeclaratorId) node; ASTType typeNode = astVariableDeclaratorId.getTypeNode(); if (typeNode != null) { return ((Dimensionable) typeNode.jjtGetParent()).isArray(); } else { return false; } }
/** * Returns exception name caught by this catch block. */ public String getExceptionName() { return getFirstDescendantOfType(ASTVariableDeclaratorId.class).getImage(); }
@Override public boolean isPublic() { if (isAnnotationMember() || isInterfaceMember()) { return true; } return super.isPublic(); }
/** * Returns true if this method declaration is a member of an interface type. */ public boolean isInterfaceMember() { // for a real class/interface the 3rd parent is a ClassOrInterfaceDeclaration, // for anonymous classes, the parent is e.g. a AllocationExpression Node potentialTypeDeclaration = getNthParent(3); return potentialTypeDeclaration instanceof ASTClassOrInterfaceDeclaration && ((ASTClassOrInterfaceDeclaration) potentialTypeDeclaration).isInterface(); }
@Override public List<ASTAnyTypeBodyDeclaration> getDeclarations() { return getFirstChildOfType(ASTEnumBody.class) .findChildrenOfType(ASTAnyTypeBodyDeclaration.class); } }
@Override public boolean hasSuppressWarningsAnnotationFor(Rule rule) { for (ASTAnnotation a : findChildrenOfType(ASTAnnotation.class)) { if (a.suppresses(rule)) { return true; } } return false; }
/** Reinitialise. */ public void ReInit(JavaParserTokenManager tm) { token_source = tm; token = new Token(); token.next = jj_nt = token_source.getNextToken(); jjtree.reset(); jj_gen = 0; for (int i = 0; i < 168; i++) jj_la1[i] = -1; for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls(); }