void (@NotNull PsiFile root, long restrictRange, long priorityRange, @NotNull Processor<? super DividedElements> processor) { long modificationStamp = root.getModificationStamp(); DividedElements cached = SoftReference.dereference(root.getUserData(DIVIDED_ELEMENTS_KEY)); DividedElements elements; if (cached != null && cached.modificationStamp == modificationStamp && cached.restrictRange == restrictRange && TextRangeScalarUtil.contains(cached.priorityRange, priorityRange)) { elements = cached; } else { List<PsiElement> inside = new ArrayList<>(); LongList insideRanges = new LongArrayList(); List<PsiElement> outside = new ArrayList<>(); LongList outsideRanges = new LongArrayList(); List<PsiElement> parents = new ArrayList<>(); LongList parentRanges = new LongArrayList(); divideInsideAndOutsideInOneRoot(root, restrictRange, priorityRange, inside, insideRanges, outside, outsideRanges, parents, parentRanges); elements = new DividedElements(root, modificationStamp, restrictRange, priorityRange, inside, insideRanges, outside, outsideRanges, parents, parentRanges); root.putUserData(DIVIDED_ELEMENTS_KEY, new java.lang.ref.SoftReference<>(elements)); } processor.process(elements); }