use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaMultifileVisitorTest method testFieldsAreThere.
@Test
public void testFieldsAreThere() {
parseAndVisitForClass(MultifileVisitorTestData2.class);
final ProjectMirror toplevel = PackageStats.INSTANCE;
final JavaFieldSigMask fieldSigMask = new JavaFieldSigMask();
JavaTypeQualifiedName clazz = 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));
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class PackageStatsTest method testAddField.
@Test
public void testAddField() {
final String TEST = "package org.foo; class Boo{ " + "public String bar;}";
ASTFieldDeclaration node = getOrderedNodes(ASTFieldDeclaration.class, TEST).get(0);
JavaTypeQualifiedName qname = (JavaTypeQualifiedName) QualifiedNameFactory.ofString("org.foo.Boo");
String fieldName = "bar";
JavaFieldSignature signature = JavaFieldSignature.buildFor(node);
assertFalse(pack.hasMatchingSig(qname, fieldName, new JavaFieldSigMask()));
ClassStats clazz = pack.getClassStats(qname, true);
clazz.addField(fieldName, signature);
assertTrue(pack.hasMatchingSig(qname, fieldName, new JavaFieldSigMask()));
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testNestedClass.
@Test
public void testNestedClass() {
final String TEST = "package foo.bar; 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("foo.bar.Bzaz$Bor$Foo", qname.toString());
assertEquals(3, qname.getClassList().size());
break;
default:
break;
}
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testEmptyPackage.
@Test
public void testEmptyPackage() {
final String TEST = "class Foo {}";
List<ASTClassOrInterfaceDeclaration> nodes = getNodes(ASTClassOrInterfaceDeclaration.class, TEST);
for (ASTClassOrInterfaceDeclaration coid : nodes) {
JavaTypeQualifiedName qname = coid.getQualifiedName();
assertEquals("Foo", qname.toString());
assertTrue(qname.getPackageList().isEmpty());
assertTrue(qname.isUnnamedPackage());
assertEquals(1, qname.getClassList().size());
}
}
use of net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName in project pmd by pmd.
the class JavaQualifiedNameTest method testGetType.
@Test
public void testGetType() {
JavaTypeQualifiedName qname = QualifiedNameFactory.ofClass(ASTAdditiveExpression.class);
assertEquals(qname.getType(), ASTAdditiveExpression.class);
}
Aggregations