use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testParseLocalClasses.
@Test
public void testParseLocalClasses() {
final String SIMPLE = "foo.bar.Bzaz$1Local";
final String NESTED = "foo.Bar$1Local$Nested";
JavaTypeQualifiedName simple = (JavaTypeQualifiedName) QualifiedNameFactory.ofString(SIMPLE);
JavaTypeQualifiedName nested = (JavaTypeQualifiedName) QualifiedNameFactory.ofString(NESTED);
assertNotNull(simple);
assertTrue(simple.isLocalClass());
assertFalse(simple.isAnonymousClass());
assertNotNull(nested);
assertFalse(nested.isLocalClass());
assertFalse(simple.isAnonymousClass());
assertEquals(SIMPLE, simple.toString());
assertEquals(NESTED, nested.toString());
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testParseAnonymousClass.
@Test
public void testParseAnonymousClass() {
final String SIMPLE = "Bzaz$12$13";
JavaTypeQualifiedName simple = (JavaTypeQualifiedName) QualifiedNameFactory.ofString(SIMPLE);
assertNotNull(simple);
assertTrue(simple.isAnonymousClass());
assertFalse(simple.isLocalClass());
assertEquals("12", simple.getClassList().get(1));
assertEquals("13", simple.getClassList().get(2));
assertEquals(SIMPLE, simple.toString());
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testPackage.
@Test
public void testPackage() {
final String TEST = "package foo.bar; class Bzaz{}";
List<ASTClassOrInterfaceDeclaration> nodes = getNodes(ASTClassOrInterfaceDeclaration.class, TEST);
for (ASTClassOrInterfaceDeclaration coid : nodes) {
JavaTypeQualifiedName qname = coid.getQualifiedName();
assertEquals("foo.bar.Bzaz", qname.toString());
assertEquals(2, qname.getPackageList().size());
assertEquals(1, qname.getClassList().size());
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaMultifileVisitorTest method testBothClassesFieldsAreThere.
@Test
public void testBothClassesFieldsAreThere() {
parseAndVisitForClass(MultifileVisitorTestData2.class);
parseAndVisitForClass(MultifileVisitorTestData2.class);
final ProjectMirror toplevel = PackageStats.INSTANCE;
final JavaFieldSigMask fieldSigMask = new JavaFieldSigMask();
JavaTypeQualifiedName clazz = QualifiedNameFactory.ofClass(MultifileVisitorTestData2.class);
JavaTypeQualifiedName clazz2 = QualifiedNameFactory.ofClass(MultifileVisitorTestData2.class);
String[] fieldNames = { "x", "y", "z", "t" };
Visibility[] visibilities = { Visibility.PUBLIC, Visibility.PRIVATE, Visibility.PROTECTED, Visibility.PACKAGE };
for (int i = 0; i < fieldNames.length; i++) {
fieldSigMask.restrictVisibilitiesTo(visibilities[i]);
assertTrue(toplevel.hasMatchingSig(clazz, fieldNames[i], fieldSigMask));
assertTrue(toplevel.hasMatchingSig(clazz2, fieldNames[i], fieldSigMask));
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class PackageStatsTest method testAddClass.
@Test
public void testAddClass() {
JavaTypeQualifiedName qname = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("org.foo.Boo");
assertNull(pack.getClassStats(qname, false));
assertNotNull(pack.getClassStats(qname, true));
// now it's added, this shouldn't return null
assertNotNull(pack.getClassStats(qname, false));
}
Aggregations