use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class VariableAccessVisitor method collectDeclarations.
private Set<Map<NameDeclaration, List<NameOccurrence>>> collectDeclarations(DataFlowNode inode) {
Set<Map<NameDeclaration, List<NameOccurrence>>> decls = new HashSet<>();
Map<NameDeclaration, List<NameOccurrence>> varDecls;
for (int i = 0; i < inode.getFlow().size(); i++) {
DataFlowNode n = inode.getFlow().get(i);
if (n instanceof StartOrEndDataFlowNode) {
continue;
}
varDecls = ((PLSQLNode) n.getNode()).getScope().getDeclarations();
if (!decls.contains(varDecls)) {
decls.add(varDecls);
}
}
return decls;
}
use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class NPathComplexityRule method complexityMultipleOf.
private int complexityMultipleOf(PLSQLNode node, int npathStart, Object data) {
LOGGER.entering(CLASS_NAME, "complexityMultipleOf(SimpleNode)");
int npath = npathStart;
PLSQLNode n;
for (int i = 0; i < node.jjtGetNumChildren(); i++) {
n = (PLSQLNode) node.jjtGetChild(i);
npath *= (Integer) n.jjtAccept(this, data);
}
LOGGER.exiting(CLASS_NAME, "complexityMultipleOf(SimpleNode)", npath);
return npath;
}
use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class NPathComplexityRule method visit.
@Override
public Object visit(ASTElseClause node, Object data) {
LOGGER.entering(CLASS_NAME, "visit(ASTElseClause)");
// (npath of if + npath of else (or 1) + bool_comp of if) * npath of
// next
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 ELSE clause statement " + node.getBeginLine() + ", column " + node.getBeginColumn());
}
for (PLSQLNode element : statementChildren) {
complexity += (Integer) element.jjtAccept(this, data);
}
LOGGER.exiting(CLASS_NAME, "visit(ASTElseClause)", complexity);
return Integer.valueOf(complexity);
}
use of net.sourceforge.pmd.lang.plsql.ast.PLSQLNode in project pmd by pmd.
the class NPathComplexityRule method visit.
@Override
public Object visit(ASTCaseStatement node, Object data) {
LOGGER.entering(CLASS_NAME, "visit(ASTCaseStatement)");
// bool_comp of switch + sum(npath(case_range))
int boolCompSwitch = sumExpressionComplexity(node.getFirstChildOfType(ASTExpression.class));
int npath = 0;
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(ASTCaseStatement)", 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(ASTPackageSpecification node, Object data) {
createClassScope(node);
Scope s = ((PLSQLNode) node.jjtGetParent()).getScope();
s.addDeclaration(new ClassNameDeclaration(node));
cont(node);
return data;
}
Aggregations