@Override public void run() { synchronized (completionLock) { try { result[0]= fUndo.apply(fDocument, TextEdit.CREATE_UNDO); } catch (BadLocationException e) { exception[0]= e; } finally { completionLock.fDone= true; completionLock.notifyAll(); } } } };
@Override protected TextEdit doCopy() { return new UndoEdit(this); }
@Override protected void accept0(TextEditVisitor visitor) { boolean visitChildren= visitor.visit(this); if (visitChildren) { acceptChildren(visitor); } }
void defineRegion(int offset, int length) { internalSetOffset(offset); internalSetLength(length); }
void add(ReplaceEdit edit) { List<TextEdit> children= internalGetChildren(); if (children == null) { children= new ArrayList<>(2); internalSetChildren(children); } children.add(edit); }
public void disconnect(IDocument document) { if (undo != null) { document.removeDocumentListener(this); undo.defineRegion(fOffset, fLength); } }
@Override public void documentAboutToBeChanged(DocumentEvent event) { int offset= event.getOffset(); int currentLength= event.getLength(); String currentText= null; try { currentText= event.getDocument().get(offset, currentLength); } catch (BadLocationException cannotHappen) { Assert.isTrue(false, "Can't happen"); //$NON-NLS-1$ } /* * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93634 * If the same string is replaced on many documents (e.g. rename * package), the size of the undo can be reduced by using the same * String instance in all edits, instead of using the unique String * returned from IDocument.get(int, int). */ if (fLastCurrentText != null && fLastCurrentText.equals(currentText)) currentText= fLastCurrentText; else fLastCurrentText= currentText; String newText= event.getText(); undo.add(new ReplaceEdit(offset, newText != null ? newText.length() : 0, currentText)); } }
void add(ReplaceEdit edit) { List<TextEdit> children= internalGetChildren(); if (children == null) { children= new ArrayList<>(2); internalSetChildren(children); } children.add(edit); }
void defineRegion(int offset, int length) { internalSetOffset(offset); internalSetLength(length); }
public void disconnect(IDocument document) { if (undo != null) { document.removeDocumentListener(this); undo.defineRegion(fOffset, fLength); } }
@Override public void documentAboutToBeChanged(DocumentEvent event) { int offset= event.getOffset(); int currentLength= event.getLength(); String currentText= null; try { currentText= event.getDocument().get(offset, currentLength); } catch (BadLocationException cannotHappen) { Assert.isTrue(false, "Can't happen"); //$NON-NLS-1$ } /* * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93634 * If the same string is replaced on many documents (e.g. rename * package), the size of the undo can be reduced by using the same * String instance in all edits, instead of using the unique String * returned from IDocument.get(int, int). */ if (fLastCurrentText != null && fLastCurrentText.equals(currentText)) currentText= fLastCurrentText; else fLastCurrentText= currentText; String newText= event.getText(); undo.add(new ReplaceEdit(offset, newText != null ? newText.length() : 0, currentText)); } }
@Override public void run() { synchronized (completionLock) { try { result[0]= fUndo.apply(fDocument, TextEdit.CREATE_UNDO); } catch (BadLocationException e) { exception[0]= e; } finally { completionLock.fDone= true; completionLock.notifyAll(); } } } };
@Override protected TextEdit doCopy() { return new UndoEdit(this); }
@Override protected void accept0(TextEditVisitor visitor) { boolean visitChildren= visitor.visit(this); if (visitChildren) { acceptChildren(visitor); } }
private UndoEdit doPerformEdits(IDocument document, boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException { // perform the changes LinkedModeModel.closeAllModels(document); UndoEdit redo= fUndo.apply(document, TextEdit.CREATE_UNDO); // try to restore the document content stamp setContentStampSuccess[0]= ContentStamps.set(document, fContentStampToRestore); return redo; }
public void connect(IDocument document) { document.addDocumentListener(this); undo= new UndoEdit(); }
private UndoEdit doPerformEdits(IDocument document, boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException { // perform the changes LinkedModeModel.closeAllModels(document); UndoEdit redo= fUndo.apply(document, TextEdit.CREATE_UNDO); // try to restore the document content stamp setContentStampSuccess[0]= ContentStamps.set(document, fContentStampToRestore); return redo; }
public void connect(IDocument document) { document.addDocumentListener(this); undo= new UndoEdit(); }
private void performEdit(IDocument document, long oldFileValue, LinkedList<UndoEdit> editCollector, long[] oldDocValue, boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException { if (document instanceof IDocumentExtension4) { oldDocValue[0]= ((IDocumentExtension4)document).getModificationStamp(); } else { oldDocValue[0]= oldFileValue; } // perform the changes for (int index= 0; index < fUndos.length; index++) { UndoEdit edit= fUndos[index]; UndoEdit redo= edit.apply(document, TextEdit.CREATE_UNDO); editCollector.addFirst(redo); } if (document instanceof IDocumentExtension4 && fDocumentStamp != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP) { try { ((IDocumentExtension4)document).replace(0, 0, "", fDocumentStamp); //$NON-NLS-1$ setContentStampSuccess[0]= true; } catch (BadLocationException e) { throw wrapBadLocationException(e); } } } }
private void performEdit(IDocument document, long oldFileValue, LinkedList<UndoEdit> editCollector, long[] oldDocValue, boolean[] setContentStampSuccess) throws MalformedTreeException, BadLocationException, CoreException { if (document instanceof IDocumentExtension4) { oldDocValue[0]= ((IDocumentExtension4)document).getModificationStamp(); } else { oldDocValue[0]= oldFileValue; } // perform the changes for (int index= 0; index < fUndos.length; index++) { UndoEdit edit= fUndos[index]; UndoEdit redo= edit.apply(document, TextEdit.CREATE_UNDO); editCollector.addFirst(redo); } if (document instanceof IDocumentExtension4 && fDocumentStamp != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP) { try { ((IDocumentExtension4)document).replace(0, 0, "", fDocumentStamp); //$NON-NLS-1$ setContentStampSuccess[0]= true; } catch (BadLocationException e) { throw wrapBadLocationException(e); } } } }