Search in sources :

Example 6 with ImageFinderFunction

use of net.sourceforge.pmd.lang.symboltable.ImageFinderFunction in project pmd by pmd.

the class MethodScope method findVariableHere.

public Set<NameDeclaration> findVariableHere(JavaNameOccurrence occurrence) {
    if (occurrence.isThisOrSuper() || occurrence.isMethodOrConstructorInvocation()) {
        return Collections.emptySet();
    }
    ImageFinderFunction finder = new ImageFinderFunction(occurrence.getImage());
    Applier.apply(finder, getVariableDeclarations().keySet().iterator());
    if (finder.getDecl() != null) {
        return Collections.singleton(finder.getDecl());
    }
    return Collections.emptySet();
}
Also used : ImageFinderFunction(net.sourceforge.pmd.lang.symboltable.ImageFinderFunction)

Example 7 with ImageFinderFunction

use of net.sourceforge.pmd.lang.symboltable.ImageFinderFunction in project pmd by pmd.

the class SourceFileScope method findClassNameDeclaration.

public ClassNameDeclaration findClassNameDeclaration(String name) {
    ImageFinderFunction finder = new ImageFinderFunction(name);
    Applier.apply(finder, getClassDeclarations().keySet().iterator());
    return (ClassNameDeclaration) finder.getDecl();
}
Also used : ImageFinderFunction(net.sourceforge.pmd.lang.symboltable.ImageFinderFunction)

Example 8 with ImageFinderFunction

use of net.sourceforge.pmd.lang.symboltable.ImageFinderFunction in project pmd by pmd.

the class SourceFileScope method findVariableHere.

protected Set<NameDeclaration> findVariableHere(JavaNameOccurrence occ) {
    ImageFinderFunction finder = new ImageFinderFunction(occ.getImage());
    Applier.apply(finder, getDeclarations().keySet().iterator());
    if (finder.getDecl() != null) {
        return Collections.singleton(finder.getDecl());
    }
    return Collections.emptySet();
}
Also used : ImageFinderFunction(net.sourceforge.pmd.lang.symboltable.ImageFinderFunction)

Example 9 with ImageFinderFunction

use of net.sourceforge.pmd.lang.symboltable.ImageFinderFunction in project pmd by pmd.

the class MethodScope method findVariableHere.

public Set<NameDeclaration> findVariableHere(PLSQLNameOccurrence occurrence) {
    Set<NameDeclaration> result = new HashSet<>();
    if (occurrence.isThisOrSuper() || occurrence.isMethodOrConstructorInvocation()) {
        return result;
    }
    ImageFinderFunction finder = new ImageFinderFunction(occurrence.getImage());
    Applier.apply(finder, getVariableDeclarations().keySet().iterator());
    if (finder.getDecl() != null) {
        result.add(finder.getDecl());
    }
    return result;
}
Also used : ImageFinderFunction(net.sourceforge.pmd.lang.symboltable.ImageFinderFunction) NameDeclaration(net.sourceforge.pmd.lang.symboltable.NameDeclaration) HashSet(java.util.HashSet)

Example 10 with ImageFinderFunction

use of net.sourceforge.pmd.lang.symboltable.ImageFinderFunction in project pmd by pmd.

the class SourceFileScope method findVariableHere.

protected NameDeclaration findVariableHere(NameOccurrence occ) {
    ImageFinderFunction finder = new ImageFinderFunction(occ.getImage());
    Applier.apply(finder, getDeclarations().keySet().iterator());
    return finder.getDecl();
}
Also used : ImageFinderFunction(net.sourceforge.pmd.lang.symboltable.ImageFinderFunction)

Aggregations

ImageFinderFunction (net.sourceforge.pmd.lang.symboltable.ImageFinderFunction)10 NameDeclaration (net.sourceforge.pmd.lang.symboltable.NameDeclaration)6 HashSet (java.util.HashSet)4 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ASTVariableDeclaratorId (net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId)2 Test (org.junit.Test)2 ASTArgumentList (net.sourceforge.pmd.lang.java.ast.ASTArgumentList)1 ASTExtendsList (net.sourceforge.pmd.lang.java.ast.ASTExtendsList)1 ASTImplementsList (net.sourceforge.pmd.lang.java.ast.ASTImplementsList)1