RefCountHolder (@NotNull PsiFile file, @NotNull TextRange dirtyScope) { Reference<RefCountHolder> ref = file.getUserData(REF_COUNT_HOLDER_IN_FILE_KEY); RefCountHolder storedHolder = com.intellij.reference.SoftReference.dereference(ref); boolean wholeFile = dirtyScope.equals(file.getTextRange()); if (storedHolder == null && !wholeFile) { // RefCountHolder was GCed and queried for subrange of the file, can't return anything meaningful return null; } return storedHolder == null || wholeFile ? new RefCountHolder(file, MultiMap.createConcurrentSet(), ConcurrentCollectionFactory.createConcurrentSet(), ConcurrentCollectionFactory.createConcurrentMap()) : storedHolder.removeInvalidRefs(); }