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 = 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 = getFirstParentOfType(ASTClassOrInterfaceDeclaration.class);
62: return clz != null && clz.isInterface();
63: }
64:
65: public boolean isVoid() {
66: return getFirstChildOfType(ASTResultType.class).isVoid();
67: }
68:
69: public ASTResultType getResultType() {
70: return getFirstChildOfType(ASTResultType.class);
71: }
72:
73: public ASTBlock getBlock() {
74: // FIXME doesn't work for all methods that use generics and declare exceptions
75: 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: }
|