View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.java.dfa;
5   
6   import net.sourceforge.pmd.lang.DataFlowHandler;
7   import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
8   import net.sourceforge.pmd.lang.java.ast.ASTConstructorDeclaration;
9   import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration;
10  import net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter;
11  
12  /**
13   * @author raik
14   *         <p/>
15   *         TODO What about initializers?  This only processes methods and constructors
16   */
17  public class DataFlowFacade extends JavaParserVisitorAdapter {
18  
19      private StatementAndBraceFinder sbf;
20      private VariableAccessVisitor vav;
21  
22      public void initializeWith(DataFlowHandler dataFlowHandler, ASTCompilationUnit node) {
23          sbf = new StatementAndBraceFinder(dataFlowHandler);
24          vav = new VariableAccessVisitor();
25          node.jjtAccept(this, null);
26      }
27  
28      public Object visit(ASTMethodDeclaration node, Object data) {
29          sbf.buildDataFlowFor(node);
30          vav.compute(node);
31          return data;
32      }
33  
34      public Object visit(ASTConstructorDeclaration node, Object data) {
35          sbf.buildDataFlowFor(node);
36          vav.compute(node);
37          return data;
38      }
39  }