Skip to content

Commit

Permalink
Cache JCCompilationUnit from compilation job for reuse in problem con…
Browse files Browse the repository at this point in the history
…verter
  • Loading branch information
testforstephen committed Sep 26, 2024
1 parent bde3539 commit 4df1be7
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@
import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jdt.internal.core.builder.SourceFile;

import com.sun.source.util.TaskEvent;
import com.sun.source.util.TaskListener;
import com.sun.tools.javac.api.MultiTaskListener;
import com.sun.tools.javac.comp.*;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.CompileStates.CompileState;
import com.sun.tools.javac.comp.Env;
import com.sun.tools.javac.main.JavaCompiler;
import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Pair;

Expand Down Expand Up @@ -112,6 +116,14 @@ public void compile(ICompilationUnit[] sourceUnits) {
JavacTaskListener javacListener = new JavacTaskListener(this.compilerConfig, outputSourceMapping, this.problemFactory);
MultiTaskListener mtl = MultiTaskListener.instance(javacContext);
mtl.add(javacListener);
mtl.add(new TaskListener() {
@Override
public void finished(TaskEvent e) {
if (e.getSourceFile() instanceof JavacFileObject && e.getCompilationUnit() instanceof JCCompilationUnit u) {
problemConverter.registerUnit(e.getSourceFile(), u);
}
}
});

for (Entry<IContainer, List<ICompilationUnit>> outputSourceSet : outputSourceMapping.entrySet()) {
// Configure Javac to generate the class files in a mapped temporary location
Expand Down

0 comments on commit 4df1be7

Please sign in to comment.