01 /**
02 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
03 */
04 package net.sourceforge.pmd.lang.ecmascript.ast;
05
06 import org.mozilla.javascript.ast.FunctionNode;
07
08 public class ASTFunctionNode extends AbstractEcmascriptNode<FunctionNode> {
09 public ASTFunctionNode(FunctionNode functionNode) {
10 super(functionNode);
11 super.setImage(functionNode.getName());
12 }
13
14 /**
15 * Accept the visitor.
16 */
17 public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
18 return visitor.visit(this, data);
19 }
20
21 public int getNumParams() {
22 return node.getParams().size();
23 }
24
25 public ASTName getFunctionName() {
26 if (node.getFunctionName() != null) {
27 return (ASTName) jjtGetChild(0);
28 }
29 return null;
30 }
31
32 public EcmascriptNode getParam(int index) {
33 if (node.getFunctionName() != null) {
34 index++;
35 }
36 return (EcmascriptNode) jjtGetChild(index);
37 }
38
39 public EcmascriptNode getBody(int index) {
40 return (EcmascriptNode) jjtGetChild(jjtGetNumChildren() - 1);
41 }
42
43 public boolean isClosure() {
44 return node.isExpressionClosure();
45 }
46
47 public boolean isGetter() {
48 return node.isGetter();
49 }
50
51 public boolean isSetter() {
52 return node.isSetter();
53 }
54
55 public boolean isGetterOrSetter() {
56 return node.isGetterOrSetter();
57 }
58 }
|