|
25 | 25 | import java.util.concurrent.ForkJoinPool;
|
26 | 26 | import java.util.stream.Collectors;
|
27 | 27 |
|
| 28 | +import javax.tools.Diagnostic; |
| 29 | + |
28 | 30 | import org.apache.commons.lang3.StringUtils;
|
29 | 31 | import org.eclipse.core.runtime.CoreException;
|
30 | 32 | import org.eclipse.core.runtime.IProgressMonitor;
|
|
50 | 52 | import org.eclipse.jdt.ls.core.internal.corrections.QuickFixProcessor;
|
51 | 53 | import org.eclipse.jdt.ls.core.internal.corrections.RefactorProcessor;
|
52 | 54 | import org.eclipse.jdt.ls.core.internal.corrections.proposals.NewCUProposal;
|
| 55 | +import org.eclipse.jdt.ls.core.internal.handlers.CodeActionHandler.CodeActionData; |
53 | 56 | import org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager;
|
54 | 57 | import org.eclipse.jdt.ls.core.internal.preferences.Preferences;
|
55 | 58 | import org.eclipse.jdt.ls.core.internal.text.correction.AssignToVariableAssistCommandProposal;
|
|
67 | 70 | import org.eclipse.lsp4j.CodeActionOptions;
|
68 | 71 | import org.eclipse.lsp4j.CodeActionParams;
|
69 | 72 | import org.eclipse.lsp4j.Command;
|
70 |
| -import org.eclipse.lsp4j.Diagnostic; |
71 | 73 | import org.eclipse.lsp4j.DiagnosticSeverity;
|
72 |
| -import org.eclipse.lsp4j.Range; |
73 | 74 | import org.eclipse.lsp4j.WorkspaceEdit;
|
74 | 75 | import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
75 | 76 |
|
76 | 77 | import com.google.gson.JsonArray;
|
77 | 78 | import com.google.gson.JsonElement;
|
78 | 79 |
|
79 | 80 | public class CodeActionHandler {
|
| 81 | + // Store a few of the latest Code Action results because any one of them might be resolved further. |
| 82 | + // Multiple Code Actions are computed in parallel through ForkJoinPool's common pool leading to a race condition where |
| 83 | + // the last Code Action request to finish processing is not the client's latest request. History size must scale with pool size. |
80 | 84 | public static final ResponseStore<Either<ChangeCorrectionProposalCore, CodeActionProposal>> codeActionStore
|
81 |
| - = new ResponseStore<>(ForkJoinPool.commonPool().getParallelism()); |
| 85 | + = new ResponseStore<>(Math.max(ForkJoinPool.getCommonPoolParallelism(), 8)); |
82 | 86 | public static final String COMMAND_ID_APPLY_EDIT = "java.apply.workspaceEdit";
|
83 | 87 |
|
84 | 88 | public static CodeActionOptions createOptions(PreferenceManager preferenceManager) {
|
|
0 commit comments