Don't load classes that get compiled by a source file

This commit is contained in:
Daniel Holle 2023-07-04 11:40:23 +02:00
parent d07b2bdf0a
commit b04201de42

View File

@ -548,16 +548,13 @@ public class JavaTXCompiler {
SourceFile sf = sourceFiles.get(f); SourceFile sf = sourceFiles.get(f);
allClasses.addAll(getAvailableClasses(sf)); allClasses.addAll(getAvailableClasses(sf));
allClasses.addAll(sf.getClasses()); allClasses.addAll(sf.getClasses());
var newClasses = CompilationEnvironment.loadDefaultPackageClasses(f,classLoader).stream().map(ASTFactory::createClass).collect(Collectors.toList()); var newClasses = CompilationEnvironment.loadDefaultPackageClasses(f,classLoader).stream().map(ASTFactory::createClass).toList();
for (var clazz : newClasses) { for (var clazz : newClasses) {
var found = false; // Don't load classes that get recompiled
for (var old : allClasses) { if (sf.getClasses().stream().anyMatch(nf -> nf.getClassName().equals(clazz.getClassName())))
if (clazz.getClassName().equals(old.getClassName())) { continue;
found = true; if (allClasses.stream().noneMatch(old -> old.getClassName().equals(clazz.getClassName())))
break; allClasses.add(clazz);
}
}
if (!found) allClasses.add(clazz);
} }
} }