use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class StatementAndBraceFinderTest method testOnlyWorksForMethodsAndConstructors.
@Test
public void testOnlyWorksForMethodsAndConstructors() {
StatementAndBraceFinder sbf = new StatementAndBraceFinder(LanguageRegistry.getLanguage(PLSQLLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler().getDataFlowHandler());
PLSQLNode node = new ASTMethodDeclaration(1);
((AbstractNode) node).testingOnlySetBeginColumn(1);
sbf.buildDataFlowFor(node);
// sbf.buildDataFlowFor(new ASTConstructorDeclaration(1));
node = new ASTProgramUnit(1);
((AbstractNode) node).testingOnlySetBeginColumn(1);
sbf.buildDataFlowFor(node);
}
use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class NPathComplexityRule method visit.
@Override
public Object visit(ASTIfStatement node, Object data) {
LOGGER.entering(CLASS_NAME, "visit(ASTIfStatement)");
// (npath of if + npath of else (or 1) + bool_comp of if) * npath of
// next
int boolCompIf = sumExpressionComplexity(node.getFirstChildOfType(ASTExpression.class));
int complexity = 0;
List<PLSQLNode> statementChildren = new ArrayList<>();
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
if (node.jjtGetChild(i).getClass() == ASTStatement.class || node.jjtGetChild(i).getClass() == ASTElsifClause.class || node.jjtGetChild(i).getClass() == ASTElseClause.class) {
statementChildren.add((PLSQLNode) node.jjtGetChild(i));
}
}
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest(statementChildren.size() + " statementChildren found for IF statement " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
for (PLSQLNode element : statementChildren) {
complexity += (Integer) element.jjtAccept(this, data);
}
LOGGER.exiting(CLASS_NAME, "visit(ASTIfStatement)", boolCompIf + complexity);
return Integer.valueOf(boolCompIf + complexity);
}
use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class NPathComplexityRule method visit.
@Override
public Object visit(ASTElsifClause node, Object data) {
LOGGER.entering(CLASS_NAME, "visit(ASTElsifClause)");
// (npath of if + npath of else (or 1) + bool_comp of if) * npath of
// next
int boolCompIf = sumExpressionComplexity(node.getFirstChildOfType(ASTExpression.class));
int complexity = 0;
List<PLSQLNode> statementChildren = new ArrayList<>();
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
if (node.jjtGetChild(i).getClass() == ASTStatement.class) {
statementChildren.add((PLSQLNode) node.jjtGetChild(i));
}
}
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest(statementChildren.size() + " statementChildren found for ELSIF statement " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
for (PLSQLNode element : statementChildren) {
complexity += (Integer) element.jjtAccept(this, data);
}
LOGGER.exiting(CLASS_NAME, "visit(ASTElsifClause)", boolCompIf + complexity);
return Integer.valueOf(boolCompIf + complexity);
}
use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class NPathComplexityRule method visit.
@Override
public Object visit(ASTCaseWhenClause node, Object data) {
LOGGER.entering(CLASS_NAME, "visit(ASTCaseWhenClause)");
// bool_comp of switch + sum(npath(case_range))
int boolCompSwitch = sumExpressionComplexity(node.getFirstChildOfType(ASTExpression.class));
int npath = 1;
int caseRange = 0;
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
PLSQLNode n = (PLSQLNode) node.jjtGetChild(i);
// Fall-through labels count as 1 for complexity
Integer complexity = (Integer) n.jjtAccept(this, data);
caseRange *= complexity;
}
// add in npath of last label
npath += caseRange;
LOGGER.exiting(CLASS_NAME, "visit(ASTCaseWhenClause)", boolCompSwitch + npath);
return Integer.valueOf(boolCompSwitch + npath);
}
use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class ScopeAndDeclarationFinder method visit.
@Override
public Object visit(ASTPackageBody node, Object data) {
createClassScope(node);
Scope s = ((PLSQLNode) node.jjtGetParent()).getScope();
s.addDeclaration(new ClassNameDeclaration(node));
cont(node);
return data;
}
Aggregations