void (int regionStartOffset, int regionEndOffset, int customRegionStartLine, int customRegionEndLine, boolean allowed) { try { assertNotNull(addFoldRegion(regionStartOffset, regionEndOffset, ".")); CustomFoldRegion customRegion = addCustomFoldRegion(customRegionStartLine, customRegionEndLine); assertEquals(allowed, customRegion != null); } finally { // cleanup FoldingModelEx model = (FoldingModelEx)getEditor().getFoldingModel(); model.runBatchFoldingOperation(() -> model.clearFoldRegions()); } }