Search in sources :

Example 1 with JavaQualifiedName

use of net.sourceforge.pmd.lang.java.ast.JavaQualifiedName in project pmd by pmd.

the class JavaMultifileVisitorTest method testBothClassesOperationsAreThere.

@Test
public void testBothClassesOperationsAreThere() {
    parseAndVisitForClass(MultifileVisitorTestData2.class);
    parseAndVisitForClass(MultifileVisitorTestData2.class);
    final ProjectMirror toplevel = PackageStats.INSTANCE;
    final JavaOperationSigMask operationSigMask = new JavaOperationSigMask();
    JavaQualifiedName clazz = QualifiedNameFactory.ofClass(MultifileVisitorTestData2.class);
    JavaQualifiedName clazz2 = QualifiedNameFactory.ofClass(MultifileVisitorTestData2.class);
    String[] opNames = { "getX()", "getY()", "setX(String)", "setY(String)", "mymethod1()", "mymethod2()", "mystatic1()", "mystatic2(String)", "mystatic2(String, String)" };
    Role[] roles = { Role.GETTER_OR_SETTER, Role.GETTER_OR_SETTER, Role.GETTER_OR_SETTER, Role.GETTER_OR_SETTER, Role.METHOD, Role.METHOD, Role.STATIC, Role.STATIC, Role.STATIC };
    for (int i = 0; i < opNames.length; i++) {
        operationSigMask.restrictRolesTo(roles[i]);
        JavaOperationQualifiedName name1 = (JavaOperationQualifiedName) QualifiedNameFactory.ofString(clazz.toString() + "#" + opNames[i]);
        JavaOperationQualifiedName name2 = (JavaOperationQualifiedName) QualifiedNameFactory.ofString(clazz2.toString() + "#" + opNames[i]);
        assertTrue(toplevel.hasMatchingSig(name1, operationSigMask));
        assertTrue(toplevel.hasMatchingSig(name2, operationSigMask));
    }
}
Also used : Role(net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSignature.Role) JavaOperationSigMask(net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask) JavaOperationQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName) JavaQualifiedName(net.sourceforge.pmd.lang.java.ast.JavaQualifiedName) Test(org.junit.Test)

Aggregations

JavaQualifiedName (net.sourceforge.pmd.lang.java.ast.JavaQualifiedName)1 JavaOperationSigMask (net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask)1 Role (net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSignature.Role)1 JavaOperationQualifiedName (net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName)1 Test (org.junit.Test)1