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      @Deprecated // use hasCatch() instead
25      public boolean isCatch() {
26          return hasCatch();
27      }
28  
29      public boolean hasCatch() {
30  	return getNumCatchClause() != 0;
31      }
32  
33      public int getNumCatchClause() {
34          return node.getCatchClauses().size();
35      }
36  
37      public ASTCatchClause getCatchClause(int index) {
38          if (index >= getNumCatchClause()) {
39              return null;
40          }
41          return (ASTCatchClause) jjtGetChild(index + 1);
42      }
43  
44      @Deprecated // use hasFinally() instead
45      public boolean isFinally() {
46          return hasFinally();
47      }
48  
49      public boolean hasFinally() {
50          return node.getFinallyBlock() != null;
51      }
52  
53      public EcmascriptNode<?> getFinallyBlock() {
54          if (!hasFinally()) {
55              return null;
56          }
57          return (EcmascriptNode<?>) jjtGetChild(jjtGetNumChildren() - 1);
58      }
59  }