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

52 lines
2.1 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.StrucTYPE;
import de.dhbwstuttgart.strucTypes.constraint.ConstraintsSet;
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
import de.dhbwstuttgart.strucTypes.printutils.PrintConstraints;
import de.dhbwstuttgart.strucTypes.printutils.PrintInferredTypes;
import de.dhbwstuttgart.strucTypes.printutils.SyntaxTreePrinter;
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
import de.dhbwstuttgart.syntaxtree.SourceFile;
public class TestStrucType {
public static final String rootDirectory = System.getProperty("user.dir") + "/test/strucType/javFiles/";
private final PrintConstraints printConstraints = new PrintConstraints();
@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 + "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);
// Print SourceFile Infos
sourceFile.accept(new SyntaxTreePrinter());
ClassOrInterface clsA = sourceFile.getClasses().get(0);
StrucTYPE strucTYPE = new StrucTYPE(clsA);
ConstraintsSet constraints = strucTYPE.getConstraints();
printConstraints.print(constraints);
InferredTypes inferredTypes = strucTYPE.getInferredTypes();
PrintInferredTypes.print(inferredTypes);
System.out.println("____________________________________________________________________________");
}
}
}