View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.ecmascript.ast;
5   
6   import org.mozilla.javascript.ast.TryStatement;
7   
8   public class ASTTryStatement extends AbstractEcmascriptNode<TryStatement> {
9       public ASTTryStatement(TryStatement tryStatement) {
10  	super(tryStatement);
11      }
12  
13      /**
14       * Accept the visitor.
15       */
16      public Object jjtAccept(EcmascriptParserVisitor visitor, Object data) {
17  	return visitor.visit(this, data);
18      }
19  
20      public EcmascriptNode getTryBlock() {
21  	return (EcmascriptNode) jjtGetChild(0);
22      }
23  
24      public boolean isCatch() {
25  	return getNumCatchClause() != 0;
26      }
27  
28      public int getNumCatchClause() {
29  	return node.getCatchClauses().size();
30      }
31  
32      public ASTCatchClause getCatchClause(int index) {
33  	return (ASTCatchClause) jjtGetChild(index - 1);
34      }
35  
36      public boolean isFinally() {
37  	return node.getFinallyBlock() != null;
38      }
39  
40      public EcmascriptNode getFinallyBlock() {
41  	return (EcmascriptNode) jjtGetChild(jjtGetNumChildren() - 1);
42      }
43  }