Skip to content

Commit 0ec9bbb

Browse files
committed
ReadAction in findWorkspaceUrisForSpans
1 parent ba35368 commit 0ec9bbb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ide-common/src/main/java/org/digma/intellij/plugin/insights/view/WorkspaceUrisHelper.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.digma.intellij.plugin.insights.view;
22

3+
import com.intellij.openapi.application.ReadAction;
34
import com.intellij.openapi.project.Project;
45
import org.digma.intellij.plugin.psi.LanguageService;
56
import org.digma.intellij.plugin.ui.model.listview.ListViewItem;
@@ -18,11 +19,13 @@ public static void findWorkspaceUrisForSpans(Project project, ListViewItem<?> th
1819
//if called while building SlowestSpansInsight then there is a method id and the related file is probably opened
1920
//and DocumentInfoService should find the method info and by that the language.
2021
//but if called from SummariesProvider there is no related file and probably no method id.
21-
var languageService = LanguageService.findLanguageServiceByMethodCodeObjectId(project, methodCodeObjectId);
2222

23-
var workspaceUris = languageService.findWorkspaceUrisForSpanIds(spanIds);
23+
var workspaceUris =
24+
ReadAction.compute(() -> {
25+
var languageService = LanguageService.findLanguageServiceByMethodCodeObjectId(project, methodCodeObjectId);
26+
return languageService.findWorkspaceUrisForSpanIds(spanIds);
27+
});
2428

2529
workspaceUris.forEach((k, v) -> theListView.getMoreData().put(k, v));
26-
2730
}
2831
}

ide-common/src/main/java/org/digma/intellij/plugin/psi/LanguageService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ default void dispose() {
4343
* the method id and we can find the language because the document is probably opened and DocumentInfoService has the
4444
* knowledge of the language. but if called when clicking an error in summary view the document is probably not
4545
* opened and we have to guess.
46+
* This method must be executed in ReadAction or EDT.
4647
*/
4748
@NotNull
4849
static LanguageService findLanguageServiceByMethodCodeObjectId(@NotNull Project project, @Nullable String methodCodeObjectId) {

0 commit comments

Comments
 (0)