use of net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSignature in project pmd by pmd.
the class SigMaskTest method testEmptyFieldMask.
/**
* Ensure any field is covered by a newly created mask.
*/
@Test
public void testEmptyFieldMask() {
List<ASTFieldDeclaration> nodes = getOrderedNodes(ASTFieldDeclaration.class, TEST_FIELDS);
SigMask<JavaFieldSignature> mask = new JavaFieldSigMask();
for (ASTFieldDeclaration node : nodes) {
assertTrue(mask.covers(JavaFieldSignature.buildFor(node)));
}
}
use of net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSignature in project pmd by pmd.
the class SignatureTest method isFinalFieldTest.
@Test
public void isFinalFieldTest() {
final String TEST = "class Bzaz{" + "public String x;" + "private int y;" + "private final int a;" + "protected final double u;" + "final long v;" + "}";
List<ASTFieldDeclaration> nodes = getOrderedNodes(ASTFieldDeclaration.class, TEST);
List<JavaFieldSignature> sigs = new ArrayList<>();
for (ASTFieldDeclaration node : nodes) {
sigs.add(JavaFieldSignature.buildFor(node));
}
assertFalse(sigs.get(0).isFinal);
assertFalse(sigs.get(1).isFinal);
assertTrue(sigs.get(2).isFinal);
assertTrue(sigs.get(3).isFinal);
assertTrue(sigs.get(4).isFinal);
}
use of net.sourceforge.pmd.lang.java.multifile.signature.JavaFieldSignature 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.multifile.signature.JavaFieldSignature in project pmd by pmd.
the class SignatureTest method isStaticFieldTest.
@Test
public void isStaticFieldTest() {
final String TEST = "class Bzaz{" + "public final String x;" + "private int y;" + "private static int a;" + "protected static final double u;" + "static long v;" + "}";
List<ASTFieldDeclaration> nodes = getOrderedNodes(ASTFieldDeclaration.class, TEST);
List<JavaFieldSignature> sigs = new ArrayList<>();
for (ASTFieldDeclaration node : nodes) {
sigs.add(JavaFieldSignature.buildFor(node));
}
assertFalse(sigs.get(0).isStatic);
assertFalse(sigs.get(1).isStatic);
assertTrue(sigs.get(2).isStatic);
assertTrue(sigs.get(3).isStatic);
assertTrue(sigs.get(4).isStatic);
}
Aggregations