List<FoldedGroupState> (int index) { ApplicationManager.getApplication().assertReadAccessAllowed(); List<FoldedGroupState> ranges = new ArrayList<>(); DocumentEx document = myEditors[index].getDocument(); for (FoldedGroup group : myFoldings) { LineRange expanded = null; LineRange collapsed = null; String[] collapsedDescription = null; for (FoldedBlock folding : group.blocks) { FoldRegion region = folding.getRegion(index); if (region == null || !region.isValid()) continue; if (region.isExpanded()) { if (expanded == null) { int line1 = document.getLineNumber(region.getStartOffset()); int line2 = document.getLineNumber(region.getEndOffset()) + 1; expanded = new LineRange(line1, line2); } } else { int line1 = document.getLineNumber(region.getStartOffset()); int line2 = document.getLineNumber(region.getEndOffset()) + 1; collapsed = new LineRange(line1, line2); collapsedDescription = ContainerUtil.map(folding.myDescriptions, it -> it != null ? it.getCachedDescription() : null, ArrayUtil.EMPTY_STRING_ARRAY); break; } } if (expanded != null || collapsed != null) { ranges.add(new FoldedGroupState(expanded, collapsed, collapsedDescription)); } } return ranges; }