Search in sources :

Example 1 with JavaParserVisitorAdapter

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

the class SignatureTest method testGetterDetection.

@Test
public void testGetterDetection() {
    ASTCompilationUnit compilationUnit = parseJava17(GetterDetection.class);
    compilationUnit.jjtAccept(new JavaParserVisitorAdapter() {

        @Override
        public Object visit(ASTMethodDeclaration node, Object data) {
            assertEquals(Role.GETTER_OR_SETTER, Role.get(node));
            return data;
        }
    }, null);
}
Also used : ASTCompilationUnit(net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit) ASTMethodDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration) JavaParserVisitorAdapter(net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter) Test(org.junit.Test)

Example 2 with JavaParserVisitorAdapter

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

the class JavaMultifileVisitorTest method testOperationsAreThere.

@Test
public void testOperationsAreThere() {
    ASTCompilationUnit acu = parseAndVisitForClass(MultifileVisitorTestData2.class);
    final ProjectMirror toplevel = PackageStats.INSTANCE;
    final JavaOperationSigMask opMask = new JavaOperationSigMask();
    // We could parse qnames from string but probably simpler to do that
    acu.jjtAccept(new JavaParserVisitorAdapter() {

        @Override
        public Object visit(ASTMethodDeclaration node, Object data) {
            assertTrue(toplevel.hasMatchingSig(node.getQualifiedName(), opMask));
            return data;
        }
    }, null);
}
Also used : ASTCompilationUnit(net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit) ASTMethodDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration) JavaOperationSigMask(net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask) JavaParserVisitorAdapter(net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter) Test(org.junit.Test)

Example 3 with JavaParserVisitorAdapter

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

the class SignatureTest method testSetterDetection.

@Test
public void testSetterDetection() {
    ASTCompilationUnit compilationUnit = parseJava17(SetterDetection.class);
    compilationUnit.jjtAccept(new JavaParserVisitorAdapter() {

        @Override
        public Object visit(ASTMethodDeclaration node, Object data) {
            assertEquals(Role.GETTER_OR_SETTER, Role.get(node));
            return data;
        }
    }, null);
}
Also used : ASTCompilationUnit(net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit) ASTMethodDeclaration(net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration) JavaParserVisitorAdapter(net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter) Test(org.junit.Test)

Aggregations

ASTCompilationUnit (net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit)3 ASTMethodDeclaration (net.sourceforge.pmd.lang.java.ast.ASTMethodDeclaration)3 JavaParserVisitorAdapter (net.sourceforge.pmd.lang.java.ast.JavaParserVisitorAdapter)3 Test (org.junit.Test)3 JavaOperationSigMask (net.sourceforge.pmd.lang.java.multifile.signature.JavaOperationSigMask)1