    1   package test.net.sourceforge.pmd.symboltable;
    2
    3   import junit.framework.TestCase;
    4   import net.sourceforge.pmd.TargetJDK1_4;
    5   import net.sourceforge.pmd.TargetJDK1_5;
    6   import net.sourceforge.pmd.TargetJDKVersion;
    7   import net.sourceforge.pmd.ast.ASTCompilationUnit;
    8   import net.sourceforge.pmd.ast.JavaParser;
    9   import net.sourceforge.pmd.symboltable.SymbolFacade;
    10
    11  import java.io.StringReader;
    12
    13  public abstract class STBBaseTst extends TestCase {
    14
    15      protected ASTCompilationUnit acu;
    16      protected SymbolFacade stb;
    17
    18      protected void parseCode(String code) {
    19          parseCode(code, new TargetJDK1_4());
    20      }
    21
    22      protected void parseCode15(String code) {
    23          parseCode(code, new TargetJDK1_5());
    24      }
    25
    26      protected void parseCode(String code, TargetJDKVersion jdk) {
    27          JavaParser parser = jdk.createParser(new StringReader(code));
    28          acu = parser.CompilationUnit();
    29          stb = new SymbolFacade();
    30          stb.initializeWith(acu);
    31      }
    32  }