use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class VariableNameDeclarationTest method testPrimitiveTypeImage.
@Test
public void testPrimitiveTypeImage() {
parseCode(TEST3);
NameDeclaration decl = acu.findDescendantsOfType(ASTVariableDeclaratorId.class).get(0).getScope().getDeclarations().keySet().iterator().next();
assertEquals("int", ((TypedNameDeclaration) decl).getTypeImage());
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class VariableNameDeclarationTest method testConstructor.
@Test
public void testConstructor() {
parseCode(TEST1);
List<ASTVariableDeclaratorId> nodes = acu.findDescendantsOfType(ASTVariableDeclaratorId.class);
Scope s = nodes.get(0).getScope();
NameDeclaration decl = s.getDeclarations().keySet().iterator().next();
assertEquals("bar", decl.getImage());
assertEquals(3, decl.getNode().getBeginLine());
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class ClassScopeTest method testOneParamVararg.
@Test
public final void testOneParamVararg() {
parseCode15(ONE_PARAM_VARARG);
ASTClassOrInterfaceDeclaration n = acu.findDescendantsOfType(ASTClassOrInterfaceDeclaration.class).get(0);
Map<NameDeclaration, List<NameOccurrence>> m = ((ClassScope) n.getScope()).getDeclarations();
MethodNameDeclaration mnd = (MethodNameDeclaration) m.keySet().iterator().next();
assertEquals("(String...)", mnd.getParameterDisplaySignature());
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class ClassScopeTest method testTwoMethodsSameNameDiffArgs.
@Test
public void testTwoMethodsSameNameDiffArgs() {
// TODO this won't work with String and java.lang.String
parseCode(METHODS_WITH_DIFF_ARG);
ASTClassOrInterfaceDeclaration n = acu.findDescendantsOfType(ASTClassOrInterfaceDeclaration.class).get(0);
Map<NameDeclaration, List<NameOccurrence>> m = ((ClassScope) n.getScope()).getDeclarations();
assertEquals(2, m.size());
Iterator<NameDeclaration> i = m.keySet().iterator();
MethodNameDeclaration mnd = (MethodNameDeclaration) i.next();
assertEquals("bar", mnd.getImage());
assertEquals("bar", ((MethodNameDeclaration) i.next()).getImage());
}
use of net.sourceforge.pmd.lang.symboltable.NameDeclaration in project pmd by pmd.
the class ClassScopeTest method testTwoParams.
@Test
public final void testTwoParams() {
parseCode(TWO_PARAMS);
ASTClassOrInterfaceDeclaration n = acu.findDescendantsOfType(ASTClassOrInterfaceDeclaration.class).get(0);
Map<NameDeclaration, List<NameOccurrence>> m = ((ClassScope) n.getScope()).getDeclarations();
MethodNameDeclaration mnd = (MethodNameDeclaration) m.keySet().iterator().next();
assertEquals("(String,int)", mnd.getParameterDisplaySignature());
}
Aggregations