JavaTXCompilerInJavaTX/test/strucType/TestASTPrinter.java
2018-06-06 21:22:09 +02:00

39 lines
1.4 KiB
Java

package strucType;
import java.io.File;
import java.util.ArrayList;
import org.junit.Test;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.syntaxtree.SourceFile;
import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter;
import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter;
public class TestASTPrinter {
public static final String rootDirectory = System.getProperty("user.dir") + "/test/strucType/javFiles/";
@Test
public void testASTPrinter() throws Exception {
ArrayList<File> files = new ArrayList<>();
files.add(new File(rootDirectory + "testLocalVar.jav"));
files.add(new File(rootDirectory + "testCast.jav"));
files.add(new File(rootDirectory + "testNew.jav"));
files.add(new File(rootDirectory + "testFieldVar.jav"));
files.add(new File(rootDirectory + "testFieldMethod.jav"));
files.add(new File(rootDirectory + "testMethod.jav"));
files.add(new File(rootDirectory + "testPaperExample.jav"));
JavaTXCompiler compiler = new JavaTXCompiler(files);
for (File f : compiler.sourceFiles.keySet()) {
String name = f.getName();
System.out.println("Filename: " + name);
SourceFile sourceFile = compiler.sourceFiles.get(f);
String print = ASTPrinter.print(sourceFile);
System.out.println(print);
String print2 = ASTTypePrinter.print(sourceFile);
System.out.println(print2);
}
}
}