package strucType; import java.io.File; import java.io.IOException; import java.util.ArrayList; import de.dhbwstuttgart.core.JavaTXCompiler; import de.dhbwstuttgart.strucTypes.TypeExtract; public class TestInterface { 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 + "testInterface.jav")); JavaTXCompiler compiler = new JavaTXCompiler(files); compiler.sourceFiles.keySet().forEach(f->{ String name = f.getName(); System.out.println("Filename: " + name); compiler.sourceFiles.get(f).getClasses().forEach(c-> c.accept(new TypeExtract())); 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); // } // } // } // } // } }