void (@NotNull Document document, Consumer<? super Editor> task) { EditorFactory factory = EditorFactory.getInstance(); Editor editor = factory.createEditor(document); try { task.accept(editor); } finally { factory.releaseEditor(editor); } }