01: /* Generated By:JJTree: Do not edit this line. ASTMethodDeclaration.java */
02:
03: package net.sourceforge.pmd.ast;
04:
05: public class ASTMethodDeclaration extends AccessNode {
06: public ASTMethodDeclaration(int id) {
07: super (id);
08: }
09:
10: public ASTMethodDeclaration(JavaParser p, int id) {
11: super (p, id);
12: }
13:
14: /**
15: * Accept the visitor. *
16: */
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: /**
27: * Gets the name of the method.
28: *
29: * @return a String representing the name of the method
30: */
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))
67: .isVoid();
68: }
69:
70: public ASTResultType getResultType() {
71: return (ASTResultType) getFirstChildOfType(ASTResultType.class);
72: }
73:
74: public ASTBlock getBlock() {
75: // FIXME doesn't work for all methods that use generics and declare exceptions
76: if (this .jjtGetChild(2) instanceof ASTBlock) {
77: return (ASTBlock) this .jjtGetChild(2);
78: }
79: if (jjtGetNumChildren() > 3) {
80: if (this .jjtGetChild(3) instanceof ASTBlock) {
81: return (ASTBlock) this .jjtGetChild(3);
82: }
83: }
84: return null;
85: }
86: }
|