Search in sources :

Example 1 with Visibility

use of net.sourceforge.pmd.lang.java.multifile.signature.JavaSignature.Visibility 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));
    }
}
Also used : Visibility(net.sourceforge.pmd.lang.java.multifile.signature.JavaSignature.Visibility) JavaFieldSigMask(net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSigMask) JavaTypeQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName) Test(org.junit.Test)

Example 2 with Visibility

use of net.sourceforge.pmd.lang.java.multifile.signature.JavaSignature.Visibility 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));
    }
}
Also used : Visibility(net.sourceforge.pmd.lang.java.multifile.signature.JavaSignature.Visibility) JavaFieldSigMask(net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSigMask) JavaTypeQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName) Test(org.junit.Test)

Aggregations

JavaFieldSigMask (net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSigMask)2 Visibility (net.sourceforge.pmd.lang.java.multifile.signature.JavaSignature.Visibility)2 JavaTypeQualifiedName (net.sourceforge.pmd.lang.java.qname.JavaTypeQualifiedName)2 Test (org.junit.Test)2