Skip to content

Commit

Permalink
Ignore MP code action request for non-MP diagnostics
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Kurz <[email protected]>
  • Loading branch information
scottkurz committed Nov 6, 2023
1 parent 7770741 commit 5400b87
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.lsp4j.CodeAction;
import org.eclipse.lsp4j.CodeLens;
import org.eclipse.lsp4j.CompletionList;
import org.eclipse.lsp4j.Diagnostic;
import org.eclipse.lsp4j.Hover;
import org.eclipse.lsp4j.Location;
import org.eclipse.lsp4j.PublishDiagnosticsParams;
Expand Down Expand Up @@ -151,8 +152,22 @@ public CompletableFuture<List<CodeAction>> getJavaCodeAction(MicroProfileJavaCod
return CompletableFutures.computeAsync((cancelChecker) -> {
IProgressMonitor monitor = getProgressMonitor(cancelChecker);
try {

// If all the diagnostics have non-microprofile source let's just ignore this.
boolean found = false;
List<Diagnostic> diagnostics = javaParams.getContext().getDiagnostics();
for (Diagnostic d : diagnostics) {
if (d.getSource().startsWith("microprofile")) {
found = true;
}
}
if (!found) {
return Collections.emptyList();
}

return (List<CodeAction>) PropertiesManagerForJava.getInstance().codeAction(javaParams, JDTUtilsLSImpl.getInstance(),
monitor);

} catch (JavaModelException e) {
LibertyToolsLSPlugin.logException(e.getLocalizedMessage(), e);
return Collections.emptyList();
Expand Down

0 comments on commit 5400b87

Please sign in to comment.