View Javadoc

    1   package net.sourceforge.pmd.util.designer;
    2
    3   import java.util.ArrayList;
    4   import java.util.List;
    5
    6   import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
    7   import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration;
    8   import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
    9   import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
    10
    11  public class DFAGraphRule extends AbstractJavaRule {
    12
    13      private List<ASTMethodDeclaration> methods;
    14      private List<ASTConstructorDeclaration> constructors;
    15
    16      public DFAGraphRule() {
    17  	super.setUsesDFA();
    18      }
    19
    20      public List<ASTMethodDeclaration> getMethods() {
    21  	return this.methods;
    22      }
    23
    24      public List<ASTConstructorDeclaration> getConstructors() {
    25  	return this.constructors;
    26      }
    27
    28      @Override
    29      public Object visit(ASTMethodDeclaration node, Object data) {
    30  	methods.add(node);
    31  	return super.visit(node, data);
    32      }
    33
    34      @Override
    35      public Object visit(ASTConstructorDeclaration node, Object data) {
    36  	constructors.add(node);
    37  	return super.visit(node, data);
    38      }
    39
    40      @Override
    41      public Object visit(ASTCompilationUnit acu, Object data) {
    42  	methods = new ArrayList<ASTMethodDeclaration>();
    43  	constructors = new ArrayList<ASTConstructorDeclaration>();
    44  	return super.visit(acu, data);
    45      }
    46  }