List<SamDescriptor> (@NotNull Session session) { PsiClass aClass = session.elementToSearch; Project project = PsiUtilCore.getProjectInReadAction(aClass); Callable<List<SamDescriptor>> runnable = () -> { if (!aClass.isValid() || !aClass.isInterface()) { return List.of(); } if (InjectedLanguageManager.getInstance(project).isInjectedFragment(aClass.getContainingFile()) || !hasJava8Modules(project)) { return List.of(); } PsiSearchHelper psiSearchHelper = PsiSearchHelper.getInstance(project); Set<PsiClass> visited = new HashSet<>(); processSubInterfaces(aClass, visited); List<SamDescriptor> descriptors = new ArrayList<>(); for (PsiClass samClass : visited) { if (LambdaUtil.isFunctionalClass(samClass)) { PsiMethod saMethod = Objects.requireNonNull(LambdaUtil.getFunctionalInterfaceMethod(samClass)); PsiType samType = saMethod.getReturnType(); if (samType == null) continue; if (session.method != null && !saMethod.equals(session.method) && !MethodSignatureUtil.isSuperMethod(saMethod, session.method)) { continue; } SearchScope scope = psiSearchHelper.getUseScope(samClass).intersectWith(session.scope); descriptors.add(new SamDescriptor(samClass, saMethod, samType, GlobalSearchScopeUtil.toGlobalSearchScope(scope, project))); } } return descriptors; }; return ReadAction.nonBlocking(runnable).inSmartMode(project).executeSynchronously(); }