From 49a6d5b55478a5562ac8caa3982f05aa5d2f9c86 Mon Sep 17 00:00:00 2001 From: dessina-devasia <143582034+dessina-devasia@users.noreply.github.com> Date: Wed, 8 Jan 2025 18:42:07 +0530 Subject: [PATCH] Removed the ReadAction.nonBlocking() as collectDiagnostics() is already executed in a NonBlocking ReadAction. --- .../java/diagnostics/DiagnosticsHandler.java | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java index 844aa97a1..591a28667 100644 --- a/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java +++ b/src/main/java/io/openliberty/tools/intellij/lsp4mp4ij/psi/core/java/diagnostics/DiagnosticsHandler.java @@ -69,30 +69,23 @@ private void collectDiagnostics(String uri, IPsiUtils utils, DocumentFormat docu try { Module module = ApplicationManager.getApplication().runReadAction((ThrowableComputable) () -> utils.getModule(uri)); - Project project = module.getProject(); - ReadAction.nonBlocking(() -> { - // Collect all adapted diagnostic definitions - JavaDiagnosticsContext context = new JavaDiagnosticsContext(uri, typeRoot, utils, module, documentFormat, settings); - List definitions = JavaDiagnosticsDefinition.EP_NAME.getExtensionList() - .stream() - .filter(definition -> group.equals(definition.getGroup())) - .filter(definition -> definition.isAdaptedForDiagnostics(context)) - .toList(); - if (definitions.isEmpty()) { - return null; // Explicit return for Callable - } + // Collect all adapted diagnostic definitions + JavaDiagnosticsContext context = new JavaDiagnosticsContext(uri, typeRoot, utils, module, documentFormat, settings); + List definitions = JavaDiagnosticsDefinition.EP_NAME.getExtensionList() + .stream() + .filter(definition -> group.equals(definition.getGroup())) + .filter(definition -> definition.isAdaptedForDiagnostics(context)) + .toList(); - // Begin, collect, end participants - definitions.forEach(definition -> definition.beginDiagnostics(context)); - definitions.forEach(definition -> { - List collectedDiagnostics = definition.collectDiagnostics(context); - if (collectedDiagnostics != null && !collectedDiagnostics.isEmpty()) { - diagnostics.addAll(collectedDiagnostics); - } - }); - definitions.forEach(definition -> definition.endDiagnostics(context)); - return null; // Explicit return for Callable - }).inSmartMode(project).executeSynchronously(); + // Begin, collect, end participants + definitions.forEach(definition -> definition.beginDiagnostics(context)); + definitions.forEach(definition -> { + List collectedDiagnostics = definition.collectDiagnostics(context); + if (collectedDiagnostics != null && !collectedDiagnostics.isEmpty()) { + diagnostics.addAll(collectedDiagnostics); + } + }); + definitions.forEach(definition -> definition.endDiagnostics(context)); } catch (IOException e) { LOGGER.warn(e.getLocalizedMessage(), e); }