Change TIP creation

This commit is contained in:
JanUlrich 2017-07-05 17:42:41 +02:00
parent fc6040da39
commit 87d2edaaa6
2 changed files with 19 additions and 14 deletions

View File

@ -29,16 +29,6 @@ public class JavaTXCompiler {
protected List<SourceFile> sourceFiles = new ArrayList<>();
public List<TypeInsert> 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<Pair> cons = new ConstraintSet<>();
List<ClassOrInterface> 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;
}
}

View File

@ -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<TypeInsert> 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
{