Search in sources :

Example 6 with JavaOperationQualifiedName

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

the class JavaQualifiedNameTest method testParseLambdaName.

@Test
public void testParseLambdaName() {
    final String IN_LAMBDA = "foo.bar.Bzaz$1Local#lambda$null$12";
    final String STATIC = "foo.bar.Bzaz#lambda$static$12";
    final String NEW = "foo.bar.Bzaz#lambda$new$1";
    final String IN_METHOD = "Bzaz#lambda$myMethod$4";
    for (String s : Arrays.asList(IN_LAMBDA, STATIC, NEW, IN_METHOD)) {
        JavaOperationQualifiedName qname = (JavaOperationQualifiedName) QualifiedNameFactory.ofString(s);
        assertNotNull(qname);
        assertTrue(qname.isLambda());
        assertEquals(s, qname.toString());
        assertEquals(qname, QualifiedNameFactory.ofString(qname.toString()));
    }
}
Also used : JavaOperationQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName) Test(org.junit.Test)

Example 7 with JavaOperationQualifiedName

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

the class JavaQualifiedNameTest method testEnumMethodMember.

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

Example 8 with JavaOperationQualifiedName

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

the class PackageStatsTest method testAddOperation.

@Test
public void testAddOperation() {
    final String TEST = "package org.foo; class Boo{ " + "public void foo(){}}";
    ASTMethodOrConstructorDeclaration node = getOrderedNodes(ASTMethodDeclaration.class, TEST).get(0);
    JavaOperationQualifiedName qname = node.getQualifiedName();
    JavaOperationSignature signature = JavaOperationSignature.buildFor(node);
    assertFalse(pack.hasMatchingSig(qname, new JavaOperationSigMask()));
    ClassStats clazz = pack.getClassStats(qname.getClassName(), true);
    clazz.addOperation("foo()", signature);
    assertTrue(pack.hasMatchingSig(qname, new JavaOperationSigMask()));
}
Also used : ASTMethodDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration) JavaOperationSigMask(net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask) JavaOperationSignature(net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSignature) JavaOperationQualifiedName(net.sourceforge.pmd.lang.java.qname.JavaOperationQualifiedName) ASTMethodOrConstructorDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodOrConstructorDeclaration) Test(org.junit.Test)

Aggregations

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