forked from JavaTX/JavaCompilerCore
Fixed bug #184
This commit is contained in:
parent
691d31df5e
commit
abdff6c8d2
@ -88,22 +88,26 @@ public class JavaTXCompiler {
|
|||||||
INSTANCE = this;
|
INSTANCE = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConstraintSet<Pair> getConstraints() throws ClassNotFoundException {
|
public ConstraintSet<Pair> getConstraints() throws ClassNotFoundException, IOException {
|
||||||
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
List<ClassOrInterface> allClasses = new ArrayList<>();//environment.getAllAvailableClasses();
|
||||||
for (SourceFile sf : sourceFiles.values()) {
|
for (SourceFile sf : sourceFiles.values()) {
|
||||||
allClasses.addAll(sf.getClasses());
|
allClasses.addAll(sf.getClasses());
|
||||||
}
|
}
|
||||||
List<ClassOrInterface> importedClasses = new ArrayList<>();
|
List<ClassOrInterface> importedClasses = new ArrayList<>();
|
||||||
//Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
//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()) {
|
for (JavaClassName name : sourceFiles.get(forSourceFile).getImports()) {
|
||||||
//TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
|
//TODO: Hier werden imports von eigenen (.jav) Klassen nicht beachtet
|
||||||
ClassOrInterface importedClass = ASTFactory.createClass(
|
ClassOrInterface importedClass = ASTFactory.createClass(
|
||||||
classLoader.loadClass(name.toString()));
|
classLoader.loadClass(name.toString()));
|
||||||
importedClasses.add(importedClass);
|
importedClasses.add(importedClass);
|
||||||
}
|
}
|
||||||
|
for(Class c : CompilationEnvironment.loadDefaultPackageClasses(forSourceFile, classLoader)){
|
||||||
|
ClassOrInterface importedClass = ASTFactory.createClass(c);
|
||||||
|
importedClasses.add(importedClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
allClasses.addAll(importedClasses);
|
allClasses.addAll(importedClasses);
|
||||||
|
|
||||||
return new TYPE(sourceFiles.values(), allClasses).getConstraints();
|
return new TYPE(sourceFiles.values(), allClasses).getConstraints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +293,7 @@ public class JavaTXCompiler {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public UnifyResultModel typeInferenceAsync(UnifyResultListener resultListener, Writer logFile)
|
public UnifyResultModel typeInferenceAsync(UnifyResultListener resultListener, Writer logFile)
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException, IOException {
|
||||||
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
||||||
// Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
// Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
||||||
for (SourceFile sf : this.sourceFiles.values()) {
|
for (SourceFile sf : this.sourceFiles.values()) {
|
||||||
@ -457,7 +461,7 @@ public class JavaTXCompiler {
|
|||||||
return urm;
|
return urm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ResultSet> typeInference() throws ClassNotFoundException {
|
public List<ResultSet> typeInference() throws ClassNotFoundException, IOException {
|
||||||
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
List<ClassOrInterface> allClasses = new ArrayList<>();// environment.getAllAvailableClasses();
|
||||||
// Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
// Alle Importierten Klassen in allen geparsten Sourcefiles kommen ins FC
|
||||||
for (SourceFile sf : this.sourceFiles.values()) {
|
for (SourceFile sf : this.sourceFiles.values()) {
|
||||||
@ -743,7 +747,7 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
|
|
||||||
public List<GenericGenratorResultForSourceFile> getGeneratedGenericResultsForAllSourceFiles()
|
public List<GenericGenratorResultForSourceFile> getGeneratedGenericResultsForAllSourceFiles()
|
||||||
throws ClassNotFoundException {
|
throws ClassNotFoundException, IOException {
|
||||||
List<GenericGenratorResultForSourceFile> result = new ArrayList<>();
|
List<GenericGenratorResultForSourceFile> result = new ArrayList<>();
|
||||||
for (File f : sourceFiles.keySet()) {
|
for (File f : sourceFiles.keySet()) {
|
||||||
SourceFile sf = sourceFiles.get(f);
|
SourceFile sf = sourceFiles.get(f);
|
||||||
|
@ -79,7 +79,7 @@ public class CompilationEnvironment {
|
|||||||
return new JavaClassRegistry(allNames);
|
return new JavaClassRegistry(allNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Class> loadDefaultPackageClasses(File forSourceFile, ClassLoader classLoader) throws IOException, ClassNotFoundException {
|
public static List<Class> loadDefaultPackageClasses(File forSourceFile, ClassLoader classLoader) throws IOException, ClassNotFoundException {
|
||||||
List<Class> ret = new ArrayList<>();
|
List<Class> ret = new ArrayList<>();
|
||||||
String packageName = getPackageName(JavaTXParser.parse(forSourceFile));
|
String packageName = getPackageName(JavaTXParser.parse(forSourceFile));
|
||||||
//Set classLoader to include default package for this specific source file
|
//Set classLoader to include default package for this specific source file
|
||||||
@ -96,7 +96,7 @@ public class CompilationEnvironment {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPackageName(CompilationUnitContext forTree){
|
private static String getPackageName(CompilationUnitContext forTree){
|
||||||
String packageName = "";
|
String packageName = "";
|
||||||
for(TerminalNode subPackage : forTree.packageDeclaration().Identifier()){
|
for(TerminalNode subPackage : forTree.packageDeclaration().Identifier()){
|
||||||
packageName += subPackage.toString() + ".";
|
packageName += subPackage.toString() + ".";
|
||||||
|
Loading…
Reference in New Issue
Block a user