Skip to content

Commit

Permalink
Removed the ReadAction.nonBlocking() as collectDiagnostics() is alrea…
Browse files Browse the repository at this point in the history
…dy executed in a NonBlocking ReadAction.
  • Loading branch information
dessina-devasia committed Jan 8, 2025
1 parent 380129c commit 49a6d5b
Showing 1 changed file with 16 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,30 +69,23 @@ private void collectDiagnostics(String uri, IPsiUtils utils, DocumentFormat docu

try {
Module module = ApplicationManager.getApplication().runReadAction((ThrowableComputable<Module, IOException>) () -> 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<JavaDiagnosticsDefinition> 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<Void>
}
// Collect all adapted diagnostic definitions
JavaDiagnosticsContext context = new JavaDiagnosticsContext(uri, typeRoot, utils, module, documentFormat, settings);
List<JavaDiagnosticsDefinition> 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<Diagnostic> collectedDiagnostics = definition.collectDiagnostics(context);
if (collectedDiagnostics != null && !collectedDiagnostics.isEmpty()) {
diagnostics.addAll(collectedDiagnostics);
}
});
definitions.forEach(definition -> definition.endDiagnostics(context));
return null; // Explicit return for Callable<Void>
}).inSmartMode(project).executeSynchronously();
// Begin, collect, end participants
definitions.forEach(definition -> definition.beginDiagnostics(context));
definitions.forEach(definition -> {
List<Diagnostic> 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);
}
Expand Down

0 comments on commit 49a6d5b

Please sign in to comment.