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);
allClasses.addAll(getAvailableClasses(sf));
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) {
var found = false;
for (var old : allClasses) {
if (clazz.getClassName().equals(old.getClassName())) {
found = true;
break;
}
}
if (!found) allClasses.add(clazz);
// Don't load classes that get recompiled
if (sf.getClasses().stream().anyMatch(nf -> nf.getClassName().equals(clazz.getClassName())))
continue;
if (allClasses.stream().noneMatch(old -> old.getClassName().equals(clazz.getClassName())))
allClasses.add(clazz);
}
}