use of apex.jorje.semantic.ast.compilation.Compilation in project pmd by pmd.
the class ApexMultifileVisitorTest 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);
languageVersionHandler.getMultifileFacade().start(acu);
return acu;
}
use of apex.jorje.semantic.ast.compilation.Compilation in project pmd by pmd.
the class ApexParser method parse.
public ApexNode<Compilation> parse(final Reader reader) {
try {
final String sourceCode = IOUtils.toString(reader);
final Compilation astRoot = parseApex(sourceCode);
final ApexTreeBuilder treeBuilder = new ApexTreeBuilder(sourceCode);
suppressMap = new HashMap<>();
if (astRoot == null) {
throw new ParseException("Couldn't parse the source - there is not root node - Syntax Error??");
}
return treeBuilder.build(astRoot);
} catch (IOException e) {
throw new ParseException(e);
}
}
use of apex.jorje.semantic.ast.compilation.Compilation in project pmd by pmd.
the class ApexCompilerSoqlTest method testSoqlCompilation.
@Test
public void testSoqlCompilation() {
ApexParser parser = new ApexParser(new ApexParserOptions());
ApexNode<Compilation> cu = parser.parse(new StringReader(CODE));
Assert.assertNotNull(cu);
}
use of apex.jorje.semantic.ast.compilation.Compilation in project pmd by pmd.
the class ApexParserTest method parsesRealWorldClasses.
@Test
public void parsesRealWorldClasses() throws Exception {
File directory = new File("src/test/resources");
File[] fList = directory.listFiles();
for (File file : fList) {
if (file.isFile() && file.getName().endsWith(".cls")) {
String sourceCode = FileUtils.readFileToString(file);
ApexNode<Compilation> rootNode = parse(sourceCode);
Assert.assertNotNull(rootNode);
}
}
}
use of apex.jorje.semantic.ast.compilation.Compilation in project pmd by pmd.
the class ApexParserTest method verifyEndLine.
@Test
public void verifyEndLine() {
String code = // line 1
"public class SimpleClass {\n" + // line 2
" public void method1() {\n" + // line 3
" }\n" + // line 4
" public void method2() {\n" + // line 5
" }\n" + // line 6
"}\n";
ApexNode<Compilation> rootNode = parse(code);
Node method1 = rootNode.jjtGetChild(1);
assertEquals("Wrong begin line", 2, method1.getBeginLine());
assertEquals("Wrong end line", 3, method1.getEndLine());
Node method2 = rootNode.jjtGetChild(2);
assertEquals("Wrong begin line", 4, method2.getBeginLine());
assertEquals("Wrong end line", 5, method2.getEndLine());
}
Aggregations