use of net.sourceforge.pmd.lang.plsql.ast.ASTName in project pmd by pmd.
the class LocalScope method addNameOccurrence.
@Override
public Set<NameDeclaration> addNameOccurrence(NameOccurrence occ) {
PLSQLNameOccurrence occurrence = (PLSQLNameOccurrence) occ;
Set<NameDeclaration> declarations = findVariableHere(occurrence);
if (!declarations.isEmpty() && !occurrence.isThisOrSuper()) {
for (NameDeclaration decl : declarations) {
List<NameOccurrence> nameOccurrences = getVariableDeclarations().get(decl);
nameOccurrences.add(occurrence);
Node n = occurrence.getLocation();
if (n instanceof ASTName) {
((ASTName) n).setNameDeclaration(decl);
}
// TODO what to do with PrimarySuffix case?
}
}
return declarations;
}
use of net.sourceforge.pmd.lang.plsql.ast.ASTName in project pmd by pmd.
the class NameFinder method checkForNameChild.
private void checkForNameChild(Node node) {
if (node.getImage() != null) {
add(new PLSQLNameOccurrence((PLSQLNode) node, node.getImage()));
}
if (node.jjtGetNumChildren() > 0 && node.jjtGetChild(0) instanceof ASTName) {
ASTName grandchild = (ASTName) node.jjtGetChild(0);
for (StringTokenizer st = new StringTokenizer(grandchild.getImage(), "."); st.hasMoreTokens(); ) {
add(new PLSQLNameOccurrence(grandchild, st.nextToken()));
}
}
if (node instanceof ASTPrimarySuffix) {
ASTPrimarySuffix suffix = (ASTPrimarySuffix) node;
if (suffix.isArguments()) {
PLSQLNameOccurrence occurrence = names.get(names.size() - 1);
occurrence.setIsMethodOrConstructorInvocation();
ASTArguments args = (ASTArguments) ((ASTPrimarySuffix) node).jjtGetChild(0);
occurrence.setArgumentCount(args.getArgumentCount());
}
// else if (suffix.jjtGetNumChildren() == 1
// && suffix.jjtGetChild(0) instanceof ASTMemberSelector)
// {
// add(new NameOccurrence((SimpleNode)suffix.jjtGetChild(0),
// suffix.jjtGetChild(0).getImage()));
// }
}
}
use of net.sourceforge.pmd.lang.plsql.ast.ASTName in project pmd by pmd.
the class ClassScope method addNameOccurrence.
@Override
public Set<NameDeclaration> addNameOccurrence(NameOccurrence occ) {
PLSQLNameOccurrence occurrence = (PLSQLNameOccurrence) occ;
Set<NameDeclaration> declarations = findVariableHere(occurrence);
Map<MethodNameDeclaration, List<NameOccurrence>> methodNames = getMethodDeclarations();
if (!declarations.isEmpty() && occurrence.isMethodOrConstructorInvocation()) {
for (NameDeclaration decl : declarations) {
List<NameOccurrence> nameOccurrences = methodNames.get(decl);
if (nameOccurrences == null) {
// TODO may be a class name: Foo.this.super();
} else {
nameOccurrences.add(occurrence);
Node n = occurrence.getLocation();
if (n instanceof ASTName) {
((ASTName) n).setNameDeclaration(decl);
}
// TODO what to do with PrimarySuffix case?
}
}
} else if (!declarations.isEmpty() && !occurrence.isThisOrSuper()) {
Map<VariableNameDeclaration, List<NameOccurrence>> variableNames = getVariableDeclarations();
for (NameDeclaration decl : declarations) {
List<NameOccurrence> nameOccurrences = variableNames.get(decl);
if (nameOccurrences == null) {
// TODO may be a class name
} else {
nameOccurrences.add(occurrence);
Node n = occurrence.getLocation();
if (n instanceof ASTName) {
((ASTName) n).setNameDeclaration(decl);
}
// TODO what to do with PrimarySuffix case?
}
}
}
return declarations;
}
use of net.sourceforge.pmd.lang.plsql.ast.ASTName in project pmd by pmd.
the class MethodScope method addNameOccurrence.
@Override
public Set<NameDeclaration> addNameOccurrence(NameOccurrence occ) {
PLSQLNameOccurrence occurrence = (PLSQLNameOccurrence) occ;
Set<NameDeclaration> declarations = findVariableHere(occurrence);
if (!declarations.isEmpty() && !occurrence.isThisOrSuper()) {
for (NameDeclaration decl : declarations) {
getVariableDeclarations().get(decl).add(occurrence);
Node n = occurrence.getLocation();
if (n instanceof ASTName) {
((ASTName) n).setNameDeclaration(decl);
}
// TODO what to do with PrimarySuffix case?
}
}
return declarations;
}
Aggregations