View Javadoc

    1   package net.sourceforge.pmd.symboltable;
    2
    3   import java.io.StringReader;
    4
    5   import net.sourceforge.pmd.lang.Language;
    6   import net.sourceforge.pmd.lang.LanguageVersion;
    7   import net.sourceforge.pmd.lang.LanguageVersionHandler;
    8   import net.sourceforge.pmd.lang.java.ast.ASTCompilationUnit;
    9   import net.sourceforge.pmd.lang.java.symboltable.SymbolFacade;
    10
    11  public abstract class STBBaseTst {
    12
    13      protected ASTCompilationUnit acu;
    14      protected SymbolFacade stb;
    15
    16      protected void parseCode(String code) {
    17          parseCode(code, LanguageVersion.JAVA_14);
    18      }
    19
    20      protected void parseCode15(String code) {
    21          parseCode(code, LanguageVersion.JAVA_15);
    22      }
    23
    24      protected void parseCode(String code, LanguageVersion languageVersion) {
    25     	  LanguageVersionHandler languageVersionHandler = Language.JAVA.getDefaultVersion().getLanguageVersionHandler();
    26  	acu = (ASTCompilationUnit)languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions()).parse(null, new StringReader(code));
    27          stb = new SymbolFacade();
    28          stb.initializeWith(acu);
    29      }
    30  }