diff --git a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java index 498ea41bf..13d752cbe 100644 --- a/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java +++ b/src/main/java/de/dhbwstuttgart/core/JavaTXCompiler.java @@ -88,22 +88,26 @@ public class JavaTXCompiler { INSTANCE = this; } - public ConstraintSet getConstraints() throws ClassNotFoundException { + public ConstraintSet getConstraints() throws ClassNotFoundException, IOException { List allClasses = new ArrayList<>();//environment.getAllAvailableClasses(); for (SourceFile sf : sourceFiles.values()) { allClasses.addAll(sf.getClasses()); } List importedClasses = new ArrayList<>(); //Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC - for (File forSourceFile : sourceFiles.keySet()) + for (File forSourceFile : sourceFiles.keySet()){ for (JavaClassName name : sourceFiles.get(forSourceFile).getImports()) { //TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet ClassOrInterface importedClass = ASTFactory.createClass( classLoader.loadClass(name.toString())); importedClasses.add(importedClass); } + for(Class c : CompilationEnvironment.loadDefaultPackageClasses(forSourceFile, classLoader)){ + ClassOrInterface importedClass = ASTFactory.createClass(c); + importedClasses.add(importedClass); + } + } allClasses.addAll(importedClasses); - return new TYPE(sourceFiles.values(), allClasses).getConstraints(); } @@ -289,7 +293,7 @@ public class JavaTXCompiler { */ public UnifyResultModel typeInferenceAsync(UnifyResultListener resultListener, Writer logFile) - throws ClassNotFoundException { + throws ClassNotFoundException, IOException { List allClasses = new ArrayList<>();// environment.getAllAvailableClasses(); // Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC for (SourceFile sf : this.sourceFiles.values()) { @@ -457,7 +461,7 @@ public class JavaTXCompiler { return urm; } - public List typeInference() throws ClassNotFoundException { + public List typeInference() throws ClassNotFoundException, IOException { List allClasses = new ArrayList<>();// environment.getAllAvailableClasses(); // Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC for (SourceFile sf : this.sourceFiles.values()) { @@ -743,7 +747,7 @@ public class JavaTXCompiler { public List getGeneratedGenericResultsForAllSourceFiles() - throws ClassNotFoundException { + throws ClassNotFoundException, IOException { List result = new ArrayList<>(); for (File f : sourceFiles.keySet()) { SourceFile sf = sourceFiles.get(f); diff --git a/src/main/java/de/dhbwstuttgart/environment/CompilationEnvironment.java b/src/main/java/de/dhbwstuttgart/environment/CompilationEnvironment.java index 05a8055cd..7433d6619 100644 --- a/src/main/java/de/dhbwstuttgart/environment/CompilationEnvironment.java +++ b/src/main/java/de/dhbwstuttgart/environment/CompilationEnvironment.java @@ -79,7 +79,7 @@ public class CompilationEnvironment { return new JavaClassRegistry(allNames); } - public List loadDefaultPackageClasses(File forSourceFile, ClassLoader classLoader) throws IOException, ClassNotFoundException { + public static List loadDefaultPackageClasses(File forSourceFile, ClassLoader classLoader) throws IOException, ClassNotFoundException { List ret = new ArrayList<>(); String packageName = getPackageName(JavaTXParser.parse(forSourceFile)); //Set classLoader to include default package for this specific source file @@ -96,7 +96,7 @@ public class CompilationEnvironment { return ret; } - private String getPackageName(CompilationUnitContext forTree){ + private static String getPackageName(CompilationUnitContext forTree){ String packageName = ""; for(TerminalNode subPackage : forTree.packageDeclaration().Identifier()){ packageName += subPackage.toString() + ".";