use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class GlobalScopeTest method testClassDeclAppears.
@Test
public void testClassDeclAppears() {
parseCode(TEST1);
ASTCompilationUnit decl = acu;
Scope scope = decl.getScope();
Map<NameDeclaration, List<NameOccurrence>> m = scope.getDeclarations();
ClassNameDeclaration classNameDeclaration = (ClassNameDeclaration) m.keySet().iterator().next();
assertEquals(classNameDeclaration.getImage(), "Foo");
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class ImageFinderFunctionTest method testSeveralImages.
@Test
public void testSeveralImages() {
List<String> imgs = new ArrayList<>();
imgs.add("Foo.foo");
imgs.add("foo");
ImageFinderFunction f = new ImageFinderFunction(imgs);
ASTVariableDeclaratorId node = new ASTVariableDeclaratorId(1);
node.setImage("foo");
NameDeclaration decl = new VariableNameDeclaration(node);
f.applyTo(decl);
assertEquals(decl, f.getDecl());
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class ImageFinderFunctionTest method testSingleImage.
@Test
public void testSingleImage() {
ImageFinderFunction f = new ImageFinderFunction("foo");
ASTVariableDeclaratorId node = new ASTVariableDeclaratorId(1);
node.setImage("foo");
NameDeclaration decl = new VariableNameDeclaration(node);
f.applyTo(decl);
assertEquals(decl, f.getDecl());
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class LocalScopeTest method testPostfixUsageIsRecorded.
@Test
public void testPostfixUsageIsRecorded() {
parseCode(TEST3);
List<ASTVariableDeclaratorId> nodes = acu.findDescendantsOfType(ASTVariableDeclaratorId.class);
ASTVariableDeclaratorId node = nodes.get(0);
Map<NameDeclaration, List<NameOccurrence>> vars = node.getScope().getDeclarations();
NameDeclaration decl = vars.keySet().iterator().next();
List<NameOccurrence> usages = vars.get(decl);
JavaNameOccurrence occ = (JavaNameOccurrence) usages.get(0);
assertEquals(4, occ.getLocation().getBeginLine());
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class LocalScopeTest method testQualifiedNameOccurrence.
@Test
public void testQualifiedNameOccurrence() {
parseCode(TEST2);
List<ASTVariableDeclaratorId> nodes = acu.findDescendantsOfType(ASTVariableDeclaratorId.class);
ASTVariableDeclaratorId node = nodes.get(0);
Map<NameDeclaration, List<NameOccurrence>> vars = node.getScope().getDeclarations();
NameDeclaration decl = vars.keySet().iterator().next();
JavaNameOccurrence occ = (JavaNameOccurrence) vars.get(decl).get(0);
assertEquals("b", occ.getImage());
}
Aggregations