package strucType; import java.io.File; import java.io.IOException; import java.io.Serializable; import java.util.ArrayList; import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.strucTypes.SyntaxTreePrinter; public class TestSyntaxTreePrinter { public static final String rootDirectory = System.getProperty("user.dir")+"/test/strucType/javFiles/"; @org.junit.Test public void test() throws ClassNotFoundException, IOException { ArrayList 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 + "testPaperExample.jav")); JavaTXCompiler compiler = new JavaTXCompiler(files); compiler.sourceFiles.keySet().forEach(f->{ String name = f.getName(); System.out.println("Filename: " + name); compiler.sourceFiles.get(f).accept(new SyntaxTreePrinter()); System.out.println(); }); // this.printSyntaxTree(compiler); System.out.println("test end"); } // private void printSyntaxTree(JavaTXCompiler compiler){ // Collection sourceFiles= compiler.sourceFiles.values(); // for (SourceFile sourceFile : sourceFiles) { // List klassenVektor = sourceFile.KlassenVektor; // for (ClassOrInterface classOrInterface : klassenVektor) { // JavaClassName className = classOrInterface.getClassName(); // System.out.println("class: "+ className); // List fields = classOrInterface.getFieldDecl(); // List methods = classOrInterface.getMethods(); // for (Field field : fields) { // String fName = field.getName(); // RefTypeOrTPHOrWildcardOrGeneric fType = field.getType(); // System.out.println("field: "+ fName + " : " + fType); // } // for (Method method : methods) { // String mName = method.getName(); // RefTypeOrTPHOrWildcardOrGeneric mReturnType = method.getReturnType(); // System.out.println("method: " + mName + " : " + mReturnType); // ParameterList mParameterList = method.getParameterList(); // for (FormalParameter formalParameter : mParameterList) { // String paraName = formalParameter.getName(); // RefTypeOrTPHOrWildcardOrGeneric paraType = formalParameter.getType(); // System.out.println("parameter: " + paraName + " : " + paraType); // } // RefTypeOrTPHOrWildcardOrGeneric blockType = method.block.getType(); // System.out.println("blockType: " + blockType); // List blockStatements = method.block.getStatements(); // for (Statement statement : blockStatements) { // RefTypeOrTPHOrWildcardOrGeneric statementType = statement.getType(); // System.out.println("statementType: " + statementType); // } // } // } // } // } }