View Javadoc

1   /* Generated By:JJTree: Do not edit this line. ASTModifiers.java */
2   
3   package net.sourceforge.pmd.ast;
4   
5   public class ASTModifiers extends SimpleNode {
6     public ASTModifiers(int id) {
7       super(id);
8     }
9   
10    public ASTModifiers(JavaParser p, int id) {
11      super(p, id);
12    }
13  
14      public boolean isDiscardable() {
15          return true;
16      }
17  
18      public void discardIfNecessary() {
19          SimpleNode parent = (SimpleNode)jjtGetParent();
20          if (jjtGetNumChildren() > 0  && jjtGetChild(0) instanceof ASTAnnotation) {
21              super.discardIfNecessary();
22          } else if (parent.jjtGetNumChildren() == 2) {
23              parent.children = new Node[] {parent.children[1]};
24          } else if (parent.jjtGetNumChildren() == 3) {
25              // AnnotationTypeMemberDeclaration with default value, like this:
26              // String defaultValue() default "";
27              parent.children = new Node[] {parent.children[1], parent.children[2]};
28          } else if (parent.jjtGetNumChildren() == 4) {
29              // JDK 1.5 forloop syntax
30              parent.children = new Node[] {parent.children[1], parent.children[2], parent.children[3]};
31          } else {
32              throw new RuntimeException("ASTModifiers.discardIfNecessary didn't see expected children");
33          }
34      }
35  
36    /*** Accept the visitor. **/
37    public Object jjtAccept(JavaParserVisitor visitor, Object data) {
38      return visitor.visit(this, data);
39    }
40  }