use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method buildDataFlowFor.
public void buildDataFlowFor(JavaNode node) {
if (!(node instanceof ASTMethodDeclaration) && !(node instanceof ASTConstructorDeclaration)) {
throw new RuntimeException("Can't build a data flow for anything other than a method or a constructor");
}
this.dataFlow = new Structure(dataFlowHandler);
this.dataFlow.createStartNode(node.getBeginLine());
this.dataFlow.createNewNode(node);
node.jjtAccept(this, dataFlow);
this.dataFlow.createEndNode(node.getEndLine());
if (LOGGER.isLoggable(Level.FINE)) {
// TODO SRT Remove after development
LOGGER.fine("DataFlow is " + this.dataFlow.dump());
}
Linker linker = new Linker(dataFlowHandler, dataFlow.getBraceStack(), dataFlow.getContinueBreakReturnStack());
try {
linker.computePaths();
} catch (SequenceException | LinkerException e) {
e.printStackTrace();
}
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTForInit node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
super.visit(node, data);
dataFlow.pushOnStack(NodeType.FOR_INIT, dataFlow.getLast());
tryToLog(NodeType.FOR_INIT, node);
this.addForExpressionNode(node, dataFlow);
return data;
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTSwitchLabel node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
// super.visit(node, data);
if (node.jjtGetNumChildren() == 0) {
dataFlow.pushOnStack(NodeType.SWITCH_LAST_DEFAULT_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.SWITCH_LAST_DEFAULT_STATEMENT, node);
} else {
dataFlow.pushOnStack(NodeType.CASE_LAST_STATEMENT, dataFlow.getLast());
tryToLog(NodeType.CASE_LAST_STATEMENT, node);
}
return data;
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTSwitchStatement node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
super.visit(node, data);
dataFlow.pushOnStack(NodeType.SWITCH_END, dataFlow.getLast());
tryToLog(NodeType.SWITCH_END, node);
return data;
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTForUpdate node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
this.addForExpressionNode(node, dataFlow);
super.visit(node, data);
dataFlow.pushOnStack(NodeType.FOR_UPDATE, dataFlow.getLast());
tryToLog(NodeType.FOR_UPDATE, node);
return data;
}
Aggregations