1 2 3 package net.sourceforge.pmd.ast; 4 5 public class ASTMethodDeclaration extends AccessNode { 6 public ASTMethodDeclaration(int id) { 7 super(id); 8 } 9 10 public ASTMethodDeclaration(JavaParser p, int id) { 11 super(p, id); 12 } 13 14 17 public Object jjtAccept(JavaParserVisitor visitor, Object data) { 18 return visitor.visit(this, data); 19 } 20 21 public void dump(String prefix) { 22 System.out.println(collectDumpedModifiers(prefix)); 23 dumpChildren(prefix); 24 } 25 26 31 public String getMethodName() { 32 ASTMethodDeclarator md = (ASTMethodDeclarator) getFirstChildOfType(ASTMethodDeclarator.class); 33 if (md != null) 34 return md.getImage(); 35 return null; 36 } 37 38 public boolean isSyntacticallyPublic() { 39 return super.isPublic(); 40 } 41 42 public boolean isSyntacticallyAbstract() { 43 return super.isAbstract(); 44 } 45 46 public boolean isPublic() { 47 if (isInterfaceMember()) { 48 return true; 49 } 50 return super.isPublic(); 51 } 52 53 public boolean isAbstract() { 54 if (isInterfaceMember()) { 55 return true; 56 } 57 return super.isAbstract(); 58 } 59 60 public boolean isInterfaceMember() { 61 ASTClassOrInterfaceDeclaration clz = (ASTClassOrInterfaceDeclaration) getFirstParentOfType(ASTClassOrInterfaceDeclaration.class); 62 return clz != null && clz.isInterface(); 63 } 64 65 public boolean isVoid() { 66 return ((ASTResultType) getFirstChildOfType(ASTResultType.class)).isVoid(); 67 } 68 69 public ASTResultType getResultType() { 70 return (ASTResultType) getFirstChildOfType(ASTResultType.class); 71 } 72 73 public ASTBlock getBlock() { 74 if (this.jjtGetChild(2) instanceof ASTBlock) { 76 return (ASTBlock) this.jjtGetChild(2); 77 } 78 if (jjtGetNumChildren() > 3) { 79 if (this.jjtGetChild(3) instanceof ASTBlock) { 80 return (ASTBlock) this.jjtGetChild(3); 81 } 82 } 83 return null; 84 } 85 } 86 | Popular Tags |