ClassesAndAmbiguities (@NotNull Project project, @NotNull String classShortName) { Map<String, Reference<ClassesAndAmbiguities>> cache = CachedValuesManager.getManager(project).getCachedValue(project, () -> CachedValueProvider.Result.create(new ConcurrentHashMap<>(), PsiModificationTracker.MODIFICATION_COUNT)); ClassesAndAmbiguities result = dereference(cache.get(classShortName)); if (result == null) { PsiClass[] classes = PsiShortNamesCache.getInstance(project).getClassesByName(classShortName, GlobalSearchScope.allScope(project)); String ambiguity = null; PsiFile[] files = new PsiFile[classes.length]; for (int i = 0; i < classes.length; i++) { PsiClass psiClass = classes[i]; ambiguity = hasAmbiguitiesSoFar(psiClass, ambiguity); files[i] = psiClass.getContainingFile(); } boolean ambiguities = Strings.areSameInstance(ambiguity, AMBIGUITY_FOUND); result = new ClassesAndAmbiguities(classes, files, ambiguities); cache.put(classShortName, new SoftReference<>(result)); } return result; }