Skip to content

Commit

Permalink
Merge pull request #471 from scottkurz/fix-377
Browse files Browse the repository at this point in the history
Ignore MP code action request for non-MP diagnostics
  • Loading branch information
scottkurz authored Nov 7, 2023
2 parents 7770741 + 6338496 commit a2852b0
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,6 +152,20 @@ 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;
break;
}
}
if (!found) {
return Collections.emptyList();
}

return (List<CodeAction>) PropertiesManagerForJava.getInstance().codeAction(javaParams, JDTUtilsLSImpl.getInstance(),
monitor);
} catch (JavaModelException e) {
Expand Down

0 comments on commit a2852b0

Please sign in to comment.