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()));
}
}
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());
}
}
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()));
}
Aggregations