use of net.sourceforge.pmd.lang.plsql.ast.ASTExpression in project pmd by pmd.
the class StatementAndBraceFinderTest method testWhileStmtHasCorrectTypes.
@Test
public void testWhileStmtHasCorrectTypes() {
ASTExpression exp = getOrderedNodes(ASTExpression.class, TEST4).get(0);
DataFlowNode dfn = exp.getDataFlowNode().getFlow().get(2);
assertTrue(dfn.isType(NodeType.WHILE_EXPR));
dfn = exp.getDataFlowNode().getFlow().get(3);
assertTrue(dfn.isType(NodeType.WHILE_LAST_STATEMENT));
}
use of net.sourceforge.pmd.lang.plsql.ast.ASTExpression in project pmd by pmd.
the class StatementAndBraceFinderTest method testIfStmtHasCorrectTypes.
@Test
public void testIfStmtHasCorrectTypes() {
ASTExpression exp = getOrderedNodes(ASTExpression.class, TEST3).get(0);
assertEquals(5, exp.getDataFlowNode().getFlow().size());
DataFlowNode dfn = exp.getDataFlowNode().getFlow().get(2);
assertTrue(dfn.isType(NodeType.IF_EXPR));
assertEquals(3, dfn.getLine());
dfn = exp.getDataFlowNode().getFlow().get(3);
assertTrue(dfn.isType(NodeType.IF_LAST_STATEMENT_WITHOUT_ELSE));
assertEquals(3, dfn.getLine());
}
use of net.sourceforge.pmd.lang.plsql.ast.ASTExpression in project pmd by pmd.
the class StatementAndBraceFinderTest method testExpressionParentChildLinks.
/**
* Java ASTStatementExpression equivalent is inferred as an Expression()
* which has an UnlabelledStatement as a parent.
*/
@Test
public void testExpressionParentChildLinks() {
ASTExpression ex = getOrderedNodes(ASTExpression.class, TEST1).get(0);
DataFlowNode dfn = ex.getDataFlowNode();
assertEquals(3, dfn.getLine());
assertTrue(dfn.getNode() instanceof ASTExpression);
List<DataFlowNode> dfns = dfn.getParents();
assertEquals(1, dfns.size());
DataFlowNode parentDfn = dfns.get(0);
assertEquals(2, parentDfn.getLine());
assertTrue(parentDfn.getNode() instanceof ASTProgramUnit);
ASTProgramUnit exParent = (ASTProgramUnit) parentDfn.getNode();
// Validate the two-way link between Program Unit and Statement
assertEquals(ex, exParent.getDataFlowNode().getChildren().get(0).getNode());
assertEquals(exParent, ex.getDataFlowNode().getParents().get(0).getNode());
}
Aggregations