@@ -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