PsiClass (@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) { ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly Map<String, Optional<PsiClass>> map = myClassCache.computeIfAbsent(scope, scope1 -> CollectionFactory.createConcurrentWeakValueMap()); Optional<PsiClass> result = map.get(qualifiedName); if (result == null) { RecursionGuard.StackStamp stamp = RecursionManager.markStack(); result = Optional.ofNullable(doFindClass(qualifiedName, scope)); if (stamp.mayCacheNow()) { map.put(qualifiedName, result); } } return result.orElse(null); }