Location (@NotNull Project project, @NotNull GlobalSearchScope searchScope) { String locationUrl = getLocationUrl(); if (locationUrl == null || myLocator == null) { return null; } if (myLocationMapCachedValue == null) { myLocationMapCachedValue = CachedValuesManager.getManager(project).createCachedValue(() -> { Map<GlobalSearchScope, Ref<Location>> value = new ConcurrentHashMap<>(1); // In some implementations calling `SMTestLocator.getLocation` might update the `ModificationTracker` from // `SMTestLocator.getLocationCacheModificationTracker` call. // Thus, calculate the first result in advance to cache with the updated modification tracker. value.put(searchScope, Ref.create(computeLocation(project, searchScope, locationUrl))); return CachedValueProvider.Result.create(value, myLocator.getLocationCacheModificationTracker(project)); }, false); } Map<GlobalSearchScope, Ref<Location>> value = myLocationMapCachedValue.getValue(); // Ref<Location> allows to cache null locations Ref<Location> ref = value.computeIfAbsent(searchScope, scope -> Ref.create(computeLocation(project, searchScope, locationUrl))); return ref.get(); }