void () { EditorFoldingInfo info = EditorFoldingInfo.get(myEditor); FoldingModelEx foldingModel = (FoldingModelEx)myEditor.getFoldingModel(); removeZombieRegions(foldingModel); Map<TextRange,Boolean> rangeToExpandStatusMap = new HashMap<>(); removeInvalidRegions(info, foldingModel, rangeToExpandStatusMap); Map<FoldRegion, Boolean> shouldExpand = new HashMap<>(); Map<FoldingGroup, Boolean> groupExpand = new HashMap<>(); List<FoldRegion> newRegions = addNewRegions(info, foldingModel, rangeToExpandStatusMap, shouldExpand, groupExpand); applyExpandStatus(newRegions, shouldExpand, groupExpand); foldingModel.clearDocumentRangesModificationStatus(); }