FoldedRangeDescription (@NotNull Project project, @NotNull Document document, int lineNumber) { PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document); if (psiFile == null) return null; VirtualFile virtualFile = psiFile.getVirtualFile(); if (virtualFile == null) return null; if (document.getLineCount() <= lineNumber) return null; int offset = document.getLineStartOffset(lineNumber); FileBreadcrumbsCollector collector = FileBreadcrumbsCollector.findBreadcrumbsCollector(project, virtualFile); List<Crumb> crumbs = ContainerUtil.newArrayList(collector.computeCrumbs(virtualFile, document, offset, true)); if (crumbs.isEmpty()) return null; String description = StringUtil.join(crumbs, it -> it.getText(), " > "); Crumb lastCrumb = crumbs.get(crumbs.size() - 1); int anchorOffset = lastCrumb instanceof NavigatableCrumb ? ((NavigatableCrumb)lastCrumb).getAnchorOffset() : -1; int anchorLine = anchorOffset != -1 ? document.getLineNumber(anchorOffset) : -1; return new FoldedRangeDescription(description, anchorLine); }