Runnable (@NotNull Editor editor, @NotNull PsiFile file, boolean applyDefaultState, boolean quick) { ApplicationManager.getApplication().assertReadAccessAllowed(); Project project = file.getProject(); Document document = editor.getDocument(); LOG.assertTrue(!PsiDocumentManager.getInstance(project).isUncommited(document)); if (document.getTextLength() != file.getTextLength()) { LOG.error(DebugUtil.diagnosePsiDocumentInconsistency(file, document)); return EmptyRunnable.INSTANCE; } CachedValue<Runnable> value = editor.getUserData(CODE_FOLDING_KEY); if (value != null && !applyDefaultState) { Supplier<Runnable> cached = value.getUpToDateOrNull(); if (cached != null) { return cached.get(); } } if (quick || applyDefaultState) return getUpdateResult(file, document, quick, project, editor, applyDefaultState).getValue(); return CachedValuesManager.getManager(project).getCachedValue( editor, CODE_FOLDING_KEY, () -> { PsiFile file1 = PsiDocumentManager.getInstance(project).getPsiFile(document); return getUpdateResult(file1, document, false, project, editor, false); }, false); }