Skip to content

Commit 70d9695

Browse files
committed
fix: Irrelevant Quick Fixes after applying code action
Fixes redhat-developer#410 Signed-off-by: azerr <[email protected]>
1 parent e3f1d6e commit 70d9695

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/main/java/com/redhat/devtools/lsp4ij/features/codeAction/LSPLazyCodeActionIntentionAction.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,21 @@ private void apply(@Nullable CodeAction codeaction,
122122
executeCommand(codeaction.getCommand(), file, editor, languageServerItem);
123123
}
124124
}
125+
clearCodeActionsCache();
125126
}
126127

127-
private static void executeCommand(@NotNull Command command,
128+
private void clearCodeActionsCache() {
129+
if (lazyCodeActions != null) {
130+
lazyCodeActions.clear();
131+
}
132+
}
133+
134+
private void executeCommand(@NotNull Command command,
128135
@NotNull PsiFile file,
129136
@NotNull Editor editor,
130137
@NotNull LanguageServerItem languageServer) {
131138
CommandExecutor.executeCommand(new LSPCommandContext(command, file, LSPCommandContext.ExecutedBy.CODE_ACTION, editor, languageServer));
139+
clearCodeActionsCache();
132140
}
133141

134142
private LanguageServerItem getLanguageServer() {

src/main/java/com/redhat/devtools/lsp4ij/features/codeAction/LSPLazyCodeActionProvider.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ public interface LSPLazyCodeActionProvider {
2424
* @return a code action at the given index and false otherwise.
2525
*/
2626
Either<CodeActionData, Boolean /* false when code action is not already loaded*/> getCodeActionAt(int index);
27+
28+
void clear();
2729
}

src/main/java/com/redhat/devtools/lsp4ij/features/codeAction/intention/LSPIntentionCodeActionSupport.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,9 @@ private static boolean isValidCodeAction(@Nullable Either<org.eclipse.lsp4j.Comm
145145
}
146146
return true;
147147
}
148+
149+
@Override
150+
public void clear() {
151+
super.cancel();
152+
}
148153
}

src/main/java/com/redhat/devtools/lsp4ij/features/codeAction/quickfix/LSPLazyCodeActions.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,10 @@ public void cancel() {
193193
lspCodeActionRequest.cancel(true);
194194
}
195195
}
196+
197+
@Override
198+
public void clear() {
199+
cancel();
200+
lspCodeActionRequest = null;
201+
}
196202
}

0 commit comments

Comments
 (0)