Search in sources :

Example 6 with JavaTypeQualifiedName

use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.

the class JavaQualifiedNameTest method testNestedEnum.

@Test
public void testNestedEnum() {
    final String TEST = "package foo.bar; class Foo { enum Bzaz{HOO;}}";
    List<ASTEnumDeclaration> nodes = getNodes(ASTEnumDeclaration.class, TEST);
    for (ASTEnumDeclaration coid : nodes) {
        JavaTypeQualifiedName qname = coid.getQualifiedName();
        assertEquals("foo.bar.Foo$Bzaz", qname.toString());
        assertEquals(2, qname.getPackageList().size());
        assertEquals(2, qname.getClassList().size());
    }
}
Also used : JavaTypeQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName) Test(org.junit.Test)

Example 7 with JavaTypeQualifiedName

use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.

the class JavaQualifiedNameTest method testNestedEmptyPackage.

@Test
public void testNestedEmptyPackage() {
    final String TEST = "class Bzaz{ class Bor{ class Foo{}}}";
    List<ASTClassOrInterfaceDeclaration> nodes = getNodes(ASTClassOrInterfaceDeclaration.class, TEST);
    for (ASTClassOrInterfaceDeclaration coid : nodes) {
        JavaTypeQualifiedName qname = coid.getQualifiedName();
        switch(coid.getImage()) {
            case "Foo":
                assertEquals("Bzaz$Bor$Foo", qname.toString());
                assertTrue(qname.getPackageList().isEmpty());
                assertTrue(qname.isUnnamedPackage());
                assertEquals(3, qname.getClassList().size());
                break;
            default:
                break;
        }
    }
}
Also used : JavaTypeQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName) Test(org.junit.Test)

Example 8 with JavaTypeQualifiedName

use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.

the class JavaQualifiedNameTest method testEnum.

@Test
public void testEnum() {
    final String TEST = "package foo.bar; enum Bzaz{HOO;}";
    List<ASTEnumDeclaration> nodes = getNodes(ASTEnumDeclaration.class, TEST);
    for (ASTEnumDeclaration coid : nodes) {
        JavaTypeQualifiedName qname = coid.getQualifiedName();
        assertEquals("foo.bar.Bzaz", qname.toString());
        assertEquals(2, qname.getPackageList().size());
        assertEquals(1, qname.getClassList().size());
    }
}
Also used : JavaTypeQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName) Test(org.junit.Test)

Example 9 with JavaTypeQualifiedName

use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.

the class JavaQualifiedNameTest method testParseClass.

@Test
public void testParseClass() {
    JavaTypeQualifiedName outer = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz");
    JavaTypeQualifiedName nested = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz$Bolg");
    assertEquals(1, outer.getClassList().size());
    assertEquals("Bzaz", outer.getClassList().get(0));
    assertEquals(2, nested.getClassList().size());
    assertEquals("Bzaz", nested.getClassList().get(0));
    assertEquals("Bolg", nested.getClassList().get(1));
}
Also used : JavaTypeQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName) Test(org.junit.Test)

Example 10 with JavaTypeQualifiedName

use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.

the class JavaQualifiedNameTest method testParsePackages.

@Test
public void testParsePackages() {
    JavaTypeQualifiedName packs = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("foo.bar.Bzaz$Bolg");
    JavaTypeQualifiedName nopacks = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("Bzaz");
    assertNotNull(packs.getPackageList());
    assertEquals("foo", packs.getPackageList().get(0));
    assertEquals("bar", packs.getPackageList().get(1));
    assertTrue(nopacks.getPackageList().isEmpty());
}
Also used : JavaTypeQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName) Test(org.junit.Test)

Aggregations

JavaTypeQualifiedName (net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName)15 Test (org.junit.Test)15 JavaFieldSigMask (net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSigMask)3 Visibility (net.sourceforge.pmd.lang.java.multifile.signature.JavaSignature.Visibility)2 ASTFieldDeclaration (net.sourceforge.pmd.lang.java.ast.ASTFieldDeclaration)1 JavaFieldSignature (net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSignature)1