forked from JavaTX/JavaCompilerCore
72 lines
2.9 KiB
Java
72 lines
2.9 KiB
Java
package strucType;
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
|
|
import de.dhbwstuttgart.core.JavaTXCompiler;
|
|
import de.dhbwstuttgart.strucTypes.printutils.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<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 + "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<SourceFile> sourceFiles= compiler.sourceFiles.values();
|
|
// for (SourceFile sourceFile : sourceFiles) {
|
|
// List<ClassOrInterface> klassenVektor = sourceFile.KlassenVektor;
|
|
// for (ClassOrInterface classOrInterface : klassenVektor) {
|
|
// JavaClassName className = classOrInterface.getClassName();
|
|
// System.out.println("class: "+ className);
|
|
// List<Field> fields = classOrInterface.getFieldDecl();
|
|
// List<Method> 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<Statement> blockStatements = method.block.getStatements();
|
|
// for (Statement statement : blockStatements) {
|
|
// RefTypeOrTPHOrWildcardOrGeneric statementType = statement.getType();
|
|
// System.out.println("statementType: " + statementType);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
}
|