Search in sources :

Example 1 with StartOrEndDataFlowNode

use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.

the class StatementAndBraceFinderTest method testSimpleCaseStmtHasCorrectTypes.

@Test
public void testSimpleCaseStmtHasCorrectTypes() {
    ASTExpression exp = getOrderedNodes(ASTExpression.class, TEST6).get(0);
    DataFlowNode dfn = null;
    dfn = exp.getDataFlowNode().getFlow().get(0);
    assertTrue(dfn instanceof StartOrEndDataFlowNode);
    dfn = exp.getDataFlowNode().getFlow().get(1);
    assertEquals(2, dfn.getLine());
    assertTrue(dfn.getNode() instanceof ASTProgramUnit);
    dfn = exp.getDataFlowNode().getFlow().get(2);
    assertEquals(4, dfn.getLine());
    assertTrue(dfn.isType(NodeType.SWITCH_START));
    assertTrue(dfn.isType(NodeType.CASE_LAST_STATEMENT));
    dfn = exp.getDataFlowNode().getFlow().get(3);
    assertEquals(5, dfn.getLine());
    assertTrue(dfn.isType(NodeType.CASE_LAST_STATEMENT));
    assertTrue(dfn.isType(NodeType.BREAK_STATEMENT));
    dfn = exp.getDataFlowNode().getFlow().get(4);
    assertEquals(6, dfn.getLine());
    assertTrue(dfn.isType(NodeType.SWITCH_LAST_DEFAULT_STATEMENT));
    assertTrue(dfn.isType(NodeType.BREAK_STATEMENT));
    dfn = exp.getDataFlowNode().getFlow().get(5);
    assertEquals(7, dfn.getLine());
    assertTrue(dfn.isType(NodeType.SWITCH_END));
}
Also used : StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) DataFlowNode(net.sourceforge.pmd.lang.dfa.DataFlowNode) StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) ASTProgramUnit(net.sourceforge.pmd.lang.plsql.ast.ASTProgramUnit) ASTExpression(net.sourceforge.pmd.lang.plsql.ast.ASTExpression) Test(org.junit.Test)

Example 2 with StartOrEndDataFlowNode

use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.

the class StatementAndBraceFinderTest method testForStmtHasCorrectTypes.

@Test
public void testForStmtHasCorrectTypes() {
    ASTExpression exp = getOrderedNodes(ASTExpression.class, TEST5).get(0);
    DataFlowNode dfn = null;
    dfn = exp.getDataFlowNode().getFlow().get(0);
    assertTrue(dfn instanceof StartOrEndDataFlowNode);
    dfn = exp.getDataFlowNode().getFlow().get(1);
    assertTrue(dfn.getNode() instanceof ASTProgramUnit);
    assertEquals(2, dfn.getLine());
    dfn = exp.getDataFlowNode().getFlow().get(2);
    assertEquals(3, dfn.getLine());
    assertTrue(dfn.isType(NodeType.FOR_EXPR));
    assertTrue(dfn.isType(NodeType.FOR_BEFORE_FIRST_STATEMENT));
    dfn = exp.getDataFlowNode().getFlow().get(3);
    assertEquals(3, dfn.getLine());
    assertTrue(dfn.isType(NodeType.FOR_END));
}
Also used : StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) DataFlowNode(net.sourceforge.pmd.lang.dfa.DataFlowNode) StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) ASTProgramUnit(net.sourceforge.pmd.lang.plsql.ast.ASTProgramUnit) ASTExpression(net.sourceforge.pmd.lang.plsql.ast.ASTExpression) Test(org.junit.Test)

Example 3 with StartOrEndDataFlowNode

use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.

the class DataFlowNodeTest method testSetType.

@Test
public void testSetType() {
    DataFlowNode node = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
    node.setType(NodeType.BREAK_STATEMENT);
    assertTrue(node.isType(NodeType.BREAK_STATEMENT));
    assertFalse(node.isType(NodeType.CASE_LAST_STATEMENT));
}
Also used : StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) DataFlowNode(net.sourceforge.pmd.lang.dfa.DataFlowNode) Test(org.junit.Test)

Example 4 with StartOrEndDataFlowNode

use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.

the class DataFlowNodeTest method testAddPathToChild.

@Test
public void testAddPathToChild() {
    DataFlowNode parent = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
    DataFlowNode child = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 12, false);
    parent.addPathToChild(child);
    assertEquals(parent.getChildren().size(), 1);
    assertTrue(child.getParents().contains(parent));
    assertTrue(parent.getChildren().contains(child));
}
Also used : StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) DataFlowNode(net.sourceforge.pmd.lang.dfa.DataFlowNode) Test(org.junit.Test)

Example 5 with StartOrEndDataFlowNode

use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.

the class DataFlowNodeTest method testRemovePathToChild.

@Test
public void testRemovePathToChild() {
    DataFlowNode parent = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
    DataFlowNode child = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 12, false);
    parent.addPathToChild(child);
    assertTrue(parent.removePathToChild(child));
    assertFalse(child.getParents().contains(parent));
    assertFalse(parent.getChildren().contains(child));
}
Also used : StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) StartOrEndDataFlowNode(net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode) DataFlowNode(net.sourceforge.pmd.lang.dfa.DataFlowNode) Test(org.junit.Test)

Aggregations

DataFlowNode (net.sourceforge.pmd.lang.dfa.DataFlowNode)9 StartOrEndDataFlowNode (net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode)9 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 ASTExpression (net.sourceforge.pmd.lang.plsql.ast.ASTExpression)2 ASTProgramUnit (net.sourceforge.pmd.lang.plsql.ast.ASTProgramUnit)2 NameOccurrence (net.sourceforge.pmd.lang.symboltable.NameOccurrence)2 JavaNode (net.sourceforge.pmd.lang.java.ast.JavaNode)1 JavaNameOccurrence (net.sourceforge.pmd.lang.java.symboltable.JavaNameOccurrence)1 VariableNameDeclaration (net.sourceforge.pmd.lang.java.symboltable.VariableNameDeclaration)1 PLSQLNode (net.sourceforge.pmd.lang.plsql.ast.PLSQLNode)1 PLSQLNameOccurrence (net.sourceforge.pmd.lang.plsql.symboltable.PLSQLNameOccurrence)1 NameDeclaration (net.sourceforge.pmd.lang.symboltable.NameDeclaration)1