FoldRegion (final int startOffset, final int endOffset, final String placeholder) { final FoldRegion[] result = new FoldRegion[1]; getEditor().getFoldingModel().runBatchFoldingOperation( () -> result[0] = getEditor().getFoldingModel().addFoldRegion(startOffset, endOffset, placeholder)); return result[0]; }