use of net.sourceforge.pmd.lang.java.ast.ASTLabeledStatement 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