Search in sources :

Example 11 with ASTMethodDeclarator

use of net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator in project pmd by pmd.

the class DAAPathFinderTest method testTwoUpdateDefs.

@Test
public void testTwoUpdateDefs() {
    ASTMethodDeclarator meth = getOrderedNodes(ASTMethodDeclarator.class, TWO_UPDATE_DEFS).get(0);
    DAAPathFinder a = new DAAPathFinder(meth.getDataFlowNode().getFlow().get(0), this);
// a.run();
}
Also used : ASTMethodDeclarator(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator) DAAPathFinder(net.sourceforge.pmd.lang.dfa.pathfinder.DAAPathFinder) Test(org.junit.Test)

Example 12 with ASTMethodDeclarator

use of net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator in project pmd by pmd.

the class GeneralFiddlingTest method test1.

@Test
public void test1() {
    ASTCompilationUnit acu = buildDFA(TEST1);
    ASTMethodDeclarator meth = acu.findDescendantsOfType(ASTMethodDeclarator.class).get(0);
    DataFlowNode n = meth.getDataFlowNode();
    List<DataFlowNode> f = n.getFlow();
    assertEquals(6, f.size());
    assertEquals("Undefinition(x)", String.valueOf(f.get(0).getVariableAccess().get(0)));
    assertEquals(0, f.get(1).getVariableAccess().size());
    assertEquals("Definition(x)", String.valueOf(f.get(2).getVariableAccess().get(0)));
    assertEquals("Reference(x)", String.valueOf(f.get(3).getVariableAccess().get(0)));
    assertEquals("Definition(x)", String.valueOf(f.get(4).getVariableAccess().get(0)));
    assertEquals("Undefinition(x)", String.valueOf(f.get(5).getVariableAccess().get(0)));
// for (DataFlowNode dfan : f) {
// System.out.println("Flow starting on line " + dfan.getLine());
// List<VariableAccess> va = dfan.getVariableAccess();
// for (VariableAccess o : va) {
// System.out.println(" variable: " + o);
// }
// }
}
Also used : ASTMethodDeclarator(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator) ASTCompilationUnit(net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit) DataFlowNode(net.sourceforge.pmd.lang.dfa.DataFlowNode) Test(org.junit.Test)

Aggregations

ASTMethodDeclarator (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator)12 Node (net.sourceforge.pmd.lang.ast.Node)4 ASTFormalParameter (net.sourceforge.pmd.lang.java.ast.ASTFormalParameter)4 ASTPrimitiveType (net.sourceforge.pmd.lang.java.ast.ASTPrimitiveType)3 DataFlowNode (net.sourceforge.pmd.lang.dfa.DataFlowNode)2 ASTClassOrInterfaceType (net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceType)2 ASTFormalParameters (net.sourceforge.pmd.lang.java.ast.ASTFormalParameters)2 ASTType (net.sourceforge.pmd.lang.java.ast.ASTType)2 ASTVariableDeclaratorId (net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId)2 Test (org.junit.Test)2 InvalidObjectException (java.io.InvalidObjectException)1 ObjectInputStream (java.io.ObjectInputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 AbstractNode (net.sourceforge.pmd.lang.ast.AbstractNode)1 DAAPathFinder (net.sourceforge.pmd.lang.dfa.pathfinder.DAAPathFinder)1 ASTAnnotation (net.sourceforge.pmd.lang.java.ast.ASTAnnotation)1 ASTArgumentList (net.sourceforge.pmd.lang.java.ast.ASTArgumentList)1 ASTArguments (net.sourceforge.pmd.lang.java.ast.ASTArguments)1