Skip to content

Commit 6f319f8

Browse files
authored
fix freeze (#182)
1 parent ae487c9 commit 6f319f8

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ public static void findWorkspaceUrisForSpans(Project project, ListViewItem<?> th
2020
//and DocumentInfoService should find the method info and by that the language.
2121
//but if called from SummariesProvider there is no related file and probably no method id.
2222

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

2927
workspaceUris.forEach((k, v) -> theListView.getMoreData().put(k, v));
3028
}

java/src/main/java/org/digma/intellij/plugin/idea/psi/java/JavaLanguageService.java

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,20 +94,21 @@ public Language getLanguageForMethodCodeObjectId(@NotNull String methodId) {
9494
//the code object id for inner classes separates inner classes name with $, but intellij index them with a dot
9595
className = className.replace('$', '.');
9696

97-
//searching in project scope will find only project classes
98-
Collection<PsiClass> psiClasses =
99-
JavaFullClassNameIndex.getInstance().get(className, project, GlobalSearchScope.projectScope(project));
100-
//todo: maybe also search in method index and compare to find the same file
101-
// or try to verify that this class really has the method
102-
if (!psiClasses.isEmpty()) {
103-
Optional<PsiClass> psiClass = psiClasses.stream().findAny();
104-
//noinspection ConstantConditions
105-
if (psiClass.isPresent()) {
106-
return psiClass.get().getLanguage();
97+
var finalClassName = className;
98+
return ReadAction.compute(() -> {
99+
Collection<PsiClass> psiClasses =
100+
JavaFullClassNameIndex.getInstance().get(finalClassName, project, GlobalSearchScope.projectScope(project));
101+
//todo: maybe also search in method index and compare to find the same file
102+
// or try to verify that this class really has the method
103+
if (!psiClasses.isEmpty()) {
104+
Optional<PsiClass> psiClass = psiClasses.stream().findAny();
105+
//noinspection ConstantConditions
106+
if (psiClass.isPresent()) {
107+
return psiClass.get().getLanguage();
108+
}
107109
}
108-
}
109-
110-
return null;
110+
return null;
111+
});
111112
}
112113

113114

@@ -421,7 +422,6 @@ private void refreshDocumentInfoAndNotifyContextChanged(@NotNull PsiFile psiFile
421422
}
422423

423424

424-
425425
private void spanDiscovery(PsiFile psiFile, DocumentInfo documentInfo) {
426426
withSpanAnnotationSpanDiscovery(psiFile, documentInfo);
427427
startSpanMethodCallSpanDiscovery(psiFile, documentInfo);
@@ -481,5 +481,4 @@ public boolean isIntellijPlatformPluginLanguage() {
481481
}
482482

483483

484-
485484
}

0 commit comments

Comments
 (0)