use of org.eclipse.text.edits.UndoEdit 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);
}
}
use of org.eclipse.text.edits.UndoEdit in project che by eclipse.
the class MultiStateTextFileChange method perform.
/*
* @see org.eclipse.ltk.core.refactoring.Change#perform(org.eclipse.core.runtime.IProgressMonitor)
*/
public final Change perform(final IProgressMonitor monitor) throws CoreException {
//$NON-NLS-1$
monitor.beginTask("", 3);
IDocument document = null;
try {
document = acquireDocument(new SubProgressMonitor(monitor, 1));
final LinkedList undoList = new LinkedList();
performChanges(document, undoList, false);
if (needsSaving())
fBuffer.commit(new SubProgressMonitor(monitor, 1), false);
return new MultiStateUndoChange(getName(), fFile, (UndoEdit[]) undoList.toArray(new UndoEdit[undoList.size()]), fContentStamp, fSaveMode);
} catch (BadLocationException exception) {
throw Changes.asCoreException(exception);
} finally {
if (document != null) {
releaseDocument(document, new SubProgressMonitor(monitor, 1));
}
monitor.done();
}
}
Aggregations