JavaTXCompilerInJavaTX/test/strucType/TestInterface.java

67 lines
2.6 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.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<File> 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<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);
// }
// }
// }
// }
// }
}