Search in sources :

Example 1 with ScopeAndDeclarationFinder

use of net.sourceforge.pmd.lang.java.symboltable.ScopeAndDeclarationFinder in project pmd by pmd.

the class JavaRuleViolationTest method parse.

private ASTCompilationUnit parse(final String code) {
    final LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(JavaLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler();
    final ParserOptions options = languageVersionHandler.getDefaultParserOptions();
    final ASTCompilationUnit ast = (ASTCompilationUnit) languageVersionHandler.getParser(options).parse(null, new StringReader(code));
    // set scope of AST nodes
    ast.jjtAccept(new ScopeAndDeclarationFinder(), null);
    return ast;
}
Also used : ScopeAndDeclarationFinder(net.sourceforge.pmd.lang.java.symboltable.ScopeAndDeclarationFinder) ParserOptions(net.sourceforge.pmd.lang.ParserOptions) ASTCompilationUnit(net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit) StringReader(java.io.StringReader) LanguageVersionHandler(net.sourceforge.pmd.lang.LanguageVersionHandler)

Aggregations

StringReader (java.io.StringReader)1 LanguageVersionHandler (net.sourceforge.pmd.lang.LanguageVersionHandler)1 ParserOptions (net.sourceforge.pmd.lang.ParserOptions)1 ASTCompilationUnit (net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit)1 ScopeAndDeclarationFinder (net.sourceforge.pmd.lang.java.symboltable.ScopeAndDeclarationFinder)1