use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTIfStatement node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
LOGGER.finest("ElsifClause) super.visit line");
super.visit(node, data);
/*
* PLSQL AST now has explicit ELSIF and ELSE clauses All of the
* ELSE_END_STATEMENTS in an IF clause should point to the outer last
* clause because we have to convert a single PL/SQL IF/ELSIF/ELSE
* satement into the equivalent set of nested Java if/else {if/else
* {if/else}} statements
*/
List<ASTElsifClause> elsifs = node.findChildrenOfType(ASTElsifClause.class);
ASTElseClause elseClause = node.getFirstChildOfType(ASTElseClause.class);
// statement
if (null == elseClause && elsifs.isEmpty()) {
dataFlow.pushOnStack(NodeType.IF_LAST_STATEMENT_WITHOUT_ELSE, dataFlow.getLast());
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("pushOnStack (ASTIfClause - no ELSIFs) IF_LAST_STATEMENT_WITHOUT_ELSE: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
} else {
if (!elsifs.isEmpty()) {
ASTElsifClause lastElsifClause = elsifs.get(elsifs.size() - 1);
for (ASTElsifClause elsifClause : elsifs) {
/*
* If last ELSIF clause is not followed by a ELSE clause
* then the last ELSIF is equivalent to an if statement
* without an else Otherwise, it is equivalent to an if/else
* statement
*/
if (lastElsifClause.equals(elsifClause) && elseClause == null) {
dataFlow.pushOnStack(NodeType.IF_LAST_STATEMENT_WITHOUT_ELSE, dataFlow.getLast());
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("pushOnStack (ASTIfClause - with ELSIFs) IF_LAST_STATEMENT_WITHOUT_ELSE: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
}
{
dataFlow.pushOnStack(NodeType.ELSE_LAST_STATEMENT, dataFlow.getLast());
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("pushOnStack (ASTIfClause - with ELSIFs) ELSE_LAST_STATEMENT : line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
}
}
}
if (null != elseClause) {
// Output one terminating else
dataFlow.pushOnStack(NodeType.ELSE_LAST_STATEMENT, dataFlow.getLast());
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("pushOnStack (ASTIfClause - with ELSE) ELSE_LAST_STATEMENT : line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
}
}
return data;
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
@Override
public Object visit(ASTCloseStatement node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
dataFlow.createNewNode(node);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("createNewNode ASTCloseStatement: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
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(ASTSqlStatement node, Object data) {
if (!(data instanceof Structure)) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("immediate return ASTSqlStatement: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
return data;
}
Structure dataFlow = (Structure) data;
dataFlow.createNewNode(node);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("createNewNode ASTSqlStatement: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
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(ASTFetchStatement node, Object data) {
if (!(data instanceof Structure)) {
return data;
}
Structure dataFlow = (Structure) data;
dataFlow.createNewNode(node);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("createNewNode ASTFetchStatement: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
return super.visit(node, data);
}
use of net.sourceforge.pmd.lang.dfa.Structure in project pmd by pmd.
the class StatementAndBraceFinder method visit.
/**
* PL/SQL does not have a do/while statement or repeat/until statement: the
* equivalent is a LOOP statement. A PL/SQL LOOP statement is exited using
* an explicit EXIT ( == break;) statement It does not have a test
* expression, so the Java control processing (on the expression) does not
* fire. The best way to cope it to push a DO_EXPR after the loop.
*/
@Override
public Object visit(ASTLoopStatement node, Object data) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("entry ASTLoopStatement: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
if (!(data instanceof Structure)) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("immediate return ASTLoopStatement: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
return data;
}
Structure dataFlow = (Structure) data;
// process the contents on the LOOP statement
super.visit(node, data);
dataFlow.createNewNode(node);
dataFlow.pushOnStack(NodeType.DO_EXPR, dataFlow.getLast());
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest("pushOnStack (ASTLoopStatement) DO_EXPR: line " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
return data;
}
Aggregations