Search in sources :

Example 6 with Compilation

use of apex.jorje.semantic.ast.compilation.Compilation in project pmd by pmd.

the class ApexProjectMirrorTest method parseAndVisitForString.

static ApexNode<Compilation> parseAndVisitForString(String source) {
    LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(ApexLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler();
    ApexNode<Compilation> acu = ApexParserTestHelpers.parse(source);
    languageVersionHandler.getSymbolFacade().start(acu);
    return acu;
}
Also used : Compilation(apex.jorje.semantic.ast.compilation.Compilation) LanguageVersionHandler(net.sourceforge.pmd.lang.LanguageVersionHandler)

Example 7 with Compilation

use of apex.jorje.semantic.ast.compilation.Compilation in project pmd by pmd.

the class ApexMultifileVisitorTest method testOperationsAreThere.

@Test
public void testOperationsAreThere() throws IOException {
    ApexNode<Compilation> acu = parseAndVisitForString(IOUtils.toString(ApexMultifileVisitorTest.class.getResourceAsStream("MetadataDeployController.cls")));
    final ApexSignatureMatcher toplevel = ApexProjectMirror.INSTANCE;
    final ApexOperationSigMask opMask = new ApexOperationSigMask();
    // We could parse qnames from string but probably simpler to do that
    acu.jjtAccept(new ApexParserVisitorAdapter() {

        @Override
        public Object visit(ASTMethod node, Object data) {
            if (!node.getImage().matches("(<clinit>|<init>|clone)")) {
                assertTrue(toplevel.hasMatchingSig(node.getQualifiedName(), opMask));
            }
            return data;
        }
    }, null);
}
Also used : Compilation(apex.jorje.semantic.ast.compilation.Compilation) ApexOperationSigMask(net.sourceforge.pmd.lang.apex.metrics.signature.ApexOperationSigMask) ASTMethod(net.sourceforge.pmd.lang.apex.ast.ASTMethod) ApexSignatureMatcher(net.sourceforge.pmd.lang.apex.metrics.ApexSignatureMatcher) ApexParserVisitorAdapter(net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter) Test(org.junit.Test) ApexParserTest(net.sourceforge.pmd.lang.apex.ast.ApexParserTest)

Aggregations

Compilation (apex.jorje.semantic.ast.compilation.Compilation)7 Test (org.junit.Test)4 LanguageVersionHandler (net.sourceforge.pmd.lang.LanguageVersionHandler)2 File (java.io.File)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 ApexParserOptions (net.sourceforge.pmd.lang.apex.ApexParserOptions)1 ASTMethod (net.sourceforge.pmd.lang.apex.ast.ASTMethod)1 ApexParserTest (net.sourceforge.pmd.lang.apex.ast.ApexParserTest)1 ApexParserVisitorAdapter (net.sourceforge.pmd.lang.apex.ast.ApexParserVisitorAdapter)1 ApexSignatureMatcher (net.sourceforge.pmd.lang.apex.metrics.ApexSignatureMatcher)1 ApexOperationSigMask (net.sourceforge.pmd.lang.apex.metrics.signature.ApexOperationSigMask)1 Node (net.sourceforge.pmd.lang.ast.Node)1 ParseException (net.sourceforge.pmd.lang.ast.ParseException)1