use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class VariableAccessVisitor method collectDeclarations.
private Set<Map<VariableNameDeclaration, List<NameOccurrence>>> collectDeclarations(DataFlowNode inode) {
Set<Map<VariableNameDeclaration, List<NameOccurrence>>> decls = new HashSet<>();
Map<VariableNameDeclaration, List<NameOccurrence>> varDecls;
for (int i = 0; i < inode.getFlow().size(); i++) {
DataFlowNode n = inode.getFlow().get(i);
if (n instanceof StartOrEndDataFlowNode) {
continue;
}
varDecls = ((JavaNode) n.getNode()).getScope().getDeclarations(VariableNameDeclaration.class);
if (!decls.contains(varDecls)) {
decls.add(varDecls);
}
}
return decls;
}
use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class DataFlowNodeTest method testRemovePathWithNonChild.
@Test
public void testRemovePathWithNonChild() {
DataFlowNode parent = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
DataFlowNode child = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 12, false);
assertFalse(parent.removePathToChild(child));
}
use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class DataFlowNodeTest method testReverseParentPathsTo.
@Test
public void testReverseParentPathsTo() {
DataFlowNode parent1 = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 10, false);
DataFlowNode parent2 = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 12, false);
DataFlowNode child1 = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 13, false);
DataFlowNode child2 = new StartOrEndDataFlowNode(new LinkedList<DataFlowNode>(), 13, false);
parent1.addPathToChild(child1);
parent2.addPathToChild(child1);
assertTrue(parent1.getChildren().contains(child1));
child1.reverseParentPathsTo(child2);
assertTrue(parent1.getChildren().contains(child2));
assertFalse(parent1.getChildren().contains(child1));
assertTrue(parent2.getChildren().contains(child2));
assertFalse(parent2.getChildren().contains(child1));
assertEquals(0, child1.getParents().size());
assertEquals(2, child2.getParents().size());
}
use of net.sourceforge.pmd.lang.dfa.StartOrEndDataFlowNode in project pmd by pmd.
the class VariableAccessVisitor method collectDeclarations.
private Set<Map<NameDeclaration, List<NameOccurrence>>> collectDeclarations(DataFlowNode inode) {
Set<Map<NameDeclaration, List<NameOccurrence>>> decls = new HashSet<>();
Map<NameDeclaration, List<NameOccurrence>> varDecls;
for (int i = 0; i < inode.getFlow().size(); i++) {
DataFlowNode n = inode.getFlow().get(i);
if (n instanceof StartOrEndDataFlowNode) {
continue;
}
varDecls = ((PLSQLNode) n.getNode()).getScope().getDeclarations();
if (!decls.contains(varDecls)) {
decls.add(varDecls);
}
}
return decls;
}
Aggregations