Search in sources :

Example 6 with IDocumentExtension4

use of org.eclipse.jface.text.IDocumentExtension4 in project che by eclipse.

the class MultiStateTextFileChange method performChangesInSynchronizationContext.

private void performChangesInSynchronizationContext(final IDocument document, final LinkedList undoList, final boolean preview) throws BadLocationException {
    DocumentRewriteSession session = null;
    try {
        if (document instanceof IDocumentExtension4)
            session = ((IDocumentExtension4) document).startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
        for (final Iterator iterator = fChanges.iterator(); iterator.hasNext(); ) {
            final ComposableBufferChange change = (ComposableBufferChange) iterator.next();
            final UndoEdit edit = createTextEditProcessor(change, document, undoList != null ? TextEdit.CREATE_UNDO : TextEdit.NONE, preview).performEdits();
            if (undoList != null)
                undoList.addFirst(edit);
        }
    } finally {
        if (session != null)
            ((IDocumentExtension4) document).stopRewriteSession(session);
    }
}
Also used : DocumentRewriteSession(org.eclipse.jface.text.DocumentRewriteSession) IDocumentExtension4(org.eclipse.jface.text.IDocumentExtension4) Iterator(java.util.Iterator) UndoEdit(org.eclipse.text.edits.UndoEdit)

Aggregations

IDocumentExtension4 (org.eclipse.jface.text.IDocumentExtension4)6 IDocument (org.eclipse.jface.text.IDocument)4 DocumentRewriteSession (org.eclipse.jface.text.DocumentRewriteSession)3 Iterator (java.util.Iterator)1 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)1 IFile (org.eclipse.core.resources.IFile)1 JavaFormattingStrategy (org.eclipse.jdt.internal.ui.text.java.JavaFormattingStrategy)1 JavaTextTools (org.eclipse.jdt.ui.text.JavaTextTools)1 Document (org.eclipse.jface.text.Document)1 FormattingContext (org.eclipse.jface.text.formatter.FormattingContext)1 IFormattingContext (org.eclipse.jface.text.formatter.IFormattingContext)1 MultiPassContentFormatter (org.eclipse.jface.text.formatter.MultiPassContentFormatter)1 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)1 TextEditProcessor (org.eclipse.text.edits.TextEditProcessor)1 UndoEdit (org.eclipse.text.edits.UndoEdit)1 IEditorInput (org.eclipse.ui.IEditorInput)1