use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StructureTest method testAddResultsinDFANodeContainingAddedNode.
@Test
public void testAddResultsinDFANodeContainingAddedNode() {
Structure s = new Structure(LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler().getDataFlowHandler());
Node n = new ASTMethodDeclaration(1);
assertEquals(n, s.createNewNode(n).getNode());
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTBreakStatement node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.BREAK_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.BREAK_STATEMENT, node);
return super.visit(node, data);
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTStatementExpression node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("createNewNode ASTStatementExpression: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
dataFlow.createNewNode(node);
return super.visit(node, data);
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTThrowStatement node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.THROW_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.THROW_STATEMENT, node);
return super.visit(node, data);
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
// ----------------------------------------------------------------------------
// BRANCH OUT
@Override
public Object visit(ASTStatement node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
if (node.jjtGetParent() instanceof ASTForStatement) {
this.addForExpressionNode(node, dataFlow);
dataFlow.pushOnStack(NodeType.FOR_BEFORE_FIRST_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.FOR_BEFORE_FIRST_STATEMENT, node);
} else if (node.jjtGetParent() instanceof ASTDoStatement) {
dataFlow.pushOnStack(NodeType.DO_BEFORE_FIRST_STATEMENT, dataFlow.getLast());
dataFlow.createNewNode(node.jjtGetParent());
tryToLog(NodeType.DO_BEFORE_FIRST_STATEMENT, node);
}
super.visit(node, data);
if (node.jjtGetParent() instanceof ASTIfStatement) {
ASTIfStatement st = (ASTIfStatement) node.jjtGetParent();
if (!st.hasElse()) {
dataFlow.pushOnStack(NodeType.IF_LAST_STATEMENT_WITHOUT_ELSE, dataFlow.getLast());
tryToLog(NodeType.IF_LAST_STATEMENT_WITHOUT_ELSE, node);
} else if (st.hasElse() && !st.jjtGetChild(1).equals(node)) {
dataFlow.pushOnStack(NodeType.ELSE_LAST_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.ELSE_LAST_STATEMENT, node);
} else {
dataFlow.pushOnStack(NodeType.IF_LAST_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.IF_LAST_STATEMENT, node);
}
} else if (node.jjtGetParent() instanceof ASTWhileStatement) {
dataFlow.pushOnStack(NodeType.WHILE_LAST_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.WHILE_LAST_STATEMENT, node);
} else if (node.jjtGetParent() instanceof ASTForStatement) {
dataFlow.pushOnStack(NodeType.FOR_END, dataFlow.getLast());
tryToLog(NodeType.FOR_END, node);
} else if (node.jjtGetParent() instanceof ASTLabeledStatement) {
dataFlow.pushOnStack(NodeType.LABEL_LAST_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.LABEL_LAST_STATEMENT, node);
}
return data;
}
Aggregations