/** * Method will apply all edits to document as single modification. Needs to * be executed in UI thread. * * @param document * document to modify * @param edits * list of LSP TextEdits */ public static void applyEdits(IDocument document, TextEdit edit) { if (document == null) { return; } IDocumentUndoManager manager = DocumentUndoManagerRegistry.getDocumentUndoManager(document); if (manager != null) { manager.beginCompoundChange(); } try { RewriteSessionEditProcessor editProcessor = new RewriteSessionEditProcessor(document, edit, org.eclipse.text.edits.TextEdit.NONE); editProcessor.performEdits(); } catch (MalformedTreeException | BadLocationException e) { EditorConfigPlugin.logError(e); } if (manager != null) { manager.endCompoundChange(); } }
public void run() { try { if (!isClosed()) { fUndoEdit = new RewriteSessionEditProcessor( fDocument, fEdit, TextEdit.UPDATE_REGIONS | TextEdit.CREATE_UNDO) .performEdits(); } } catch (BadLocationException x) { // ignore } }
public void run() { try { if (!isClosed()) { fUndoEdit= new RewriteSessionEditProcessor(fDocument, fEdit, TextEdit.UPDATE_REGIONS | TextEdit.CREATE_UNDO).performEdits(); } } catch (BadLocationException x) { // ignore } }