2018-03-21 15:04:41 +00:00
|
|
|
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;
|
2018-06-06 19:22:09 +00:00
|
|
|
import de.dhbwstuttgart.strucTypes.model.InferredTypes;
|
2018-03-21 15:04:41 +00:00
|
|
|
import de.dhbwstuttgart.strucTypes.printutils.PrintConstraints;
|
|
|
|
import de.dhbwstuttgart.strucTypes.printutils.PrintInferredTypes;
|
|
|
|
import de.dhbwstuttgart.strucTypes.printutils.SyntaxTreePrinter;
|
2018-05-31 13:13:39 +00:00
|
|
|
import de.dhbwstuttgart.syntaxtree.ClassOrInterface;
|
2018-03-21 15:04:41 +00:00
|
|
|
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<>();
|
2018-03-23 20:41:31 +00:00
|
|
|
files.add(new File(rootDirectory + "testLocalVar.jav"));
|
|
|
|
files.add(new File(rootDirectory + "testCast.jav"));
|
|
|
|
files.add(new File(rootDirectory + "testNew.jav"));
|
2018-03-21 15:04:41 +00:00
|
|
|
files.add(new File(rootDirectory + "testFieldVar.jav"));
|
2018-03-23 20:41:31 +00:00
|
|
|
files.add(new File(rootDirectory + "testFieldMethod.jav"));
|
|
|
|
files.add(new File(rootDirectory + "testMethod.jav"));
|
|
|
|
files.add(new File(rootDirectory + "testPaperExample.jav"));
|
2018-03-21 15:04:41 +00:00
|
|
|
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);
|
2018-05-31 13:13:39 +00:00
|
|
|
// Print SourceFile Infos
|
2018-03-21 15:04:41 +00:00
|
|
|
sourceFile.accept(new SyntaxTreePrinter());
|
2018-05-31 13:13:39 +00:00
|
|
|
ClassOrInterface clsA = sourceFile.getClasses().get(0);
|
|
|
|
|
|
|
|
StrucTYPE strucTYPE = new StrucTYPE(clsA);
|
|
|
|
|
2018-03-21 15:04:41 +00:00
|
|
|
ConstraintsSet constraints = strucTYPE.getConstraints();
|
|
|
|
printConstraints.print(constraints);
|
2018-05-31 13:13:39 +00:00
|
|
|
|
2018-03-21 15:04:41 +00:00
|
|
|
InferredTypes inferredTypes = strucTYPE.getInferredTypes();
|
|
|
|
PrintInferredTypes.print(inferredTypes);
|
2018-05-31 13:13:39 +00:00
|
|
|
|
2018-03-21 15:04:41 +00:00
|
|
|
System.out.println("____________________________________________________________________________");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|