diff --git a/src/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/de/dhbwstuttgart/core/JavaTXCompiler.java index cb39277d..aa07361c 100644 --- a/src/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -29,16 +29,6 @@ public class JavaTXCompiler { protected List sourceFiles = new ArrayList<>(); - public List getTypeInserts(File forFile){ - ResultSet result = typeInference(); - for(SourceFile sf : sourceFiles){ - if(sf.getFile().equals(forFile)){ - return TypeInsertFactory.createTypeInsertPoints(sf, result); - } - } - throw new DebugException("Die Datei "+forFile+" wurde nicht geparst"); - } - public ResultSet typeInference(){ ConstraintSet cons = new ConstraintSet<>(); List allClasses = new ArrayList<>(); @@ -82,8 +72,10 @@ public class JavaTXCompiler { return ret; } - public void parse(File sourceFile) throws IOException, ClassNotFoundException { - sourceFiles.add(new JavaTXParser().parse(sourceFile)); + public SourceFile parse(File sourceFile) throws IOException, ClassNotFoundException { + SourceFile ret = new JavaTXParser().parse(sourceFile); + sourceFiles.add(ret); + return ret; } } diff --git a/test/typeinference/JavaTXCompilerTest.java b/test/typeinference/JavaTXCompilerTest.java index 696a56d4..a698980b 100644 --- a/test/typeinference/JavaTXCompilerTest.java +++ b/test/typeinference/JavaTXCompilerTest.java @@ -1,13 +1,16 @@ package typeinference; import de.dhbwstuttgart.core.JavaTXCompiler; +import de.dhbwstuttgart.exceptions.DebugException; import de.dhbwstuttgart.parser.ClassNotFoundException; +import de.dhbwstuttgart.syntaxtree.SourceFile; import de.dhbwstuttgart.syntaxtree.SyntaxTreeNode; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; import de.dhbwstuttgart.syntaxtree.visual.ASTPrinter; import de.dhbwstuttgart.syntaxtree.visual.ASTTypePrinter; import de.dhbwstuttgart.syntaxtree.visual.OutputGenerator; import de.dhbwstuttgart.typedeployment.TypeInsert; +import de.dhbwstuttgart.typedeployment.TypeInsertFactory; import de.dhbwstuttgart.typedeployment.TypeInsertPoint; import de.dhbwstuttgart.typeinference.ResultSet; import org.junit.Test; @@ -30,8 +33,8 @@ public class JavaTXCompilerTest extends JavaTXCompiler { @Test public void test() throws IOException, ClassNotFoundException { - filesToTest.add(new File(rootDirectory+"Faculty.jav")); - //filesToTest.add(new File(rootDirectory+"mathStruc.jav")); + //filesToTest.add(new File(rootDirectory+"Faculty.jav")); + filesToTest.add(new File(rootDirectory+"mathStruc.jav")); //filesToTest.add(new File(rootDirectory+"Lambda.jav")); //filesToTest.add(new File(rootDirectory+"Lambda2.jav")); //filesToTest.add(new File(rootDirectory+"Lambda3.jav")); @@ -51,6 +54,16 @@ public class JavaTXCompilerTest extends JavaTXCompiler { } + public List getTypeInserts(File forFile){ + ResultSet result = typeInference(); + for(SourceFile sf : sourceFiles){ + if(sf.getFile().equals(forFile)){ + return TypeInsertFactory.createTypeInsertPoints(sf, result); + } + } + throw new DebugException("Die Datei "+forFile+" wurde nicht geparst"); + } + static String readFile(String path, Charset encoding) throws IOException {