1 11 package org.eclipse.ltk.core.refactoring; 12 13 import org.eclipse.text.edits.UndoEdit; 14 15 import org.eclipse.core.runtime.Assert; 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IProgressMonitor; 18 19 import org.eclipse.jface.text.IDocument; 20 21 import org.eclipse.ltk.internal.core.refactoring.TextChanges; 22 import org.eclipse.ltk.internal.core.refactoring.UndoDocumentChange; 23 24 37 public class DocumentChange extends TextChange { 38 39 private IDocument fDocument; 40 private int fLength; 41 42 49 public DocumentChange(String name, IDocument document) { 50 super(name); 51 Assert.isNotNull(document); 52 fDocument= document; 53 } 54 55 58 public Object getModifiedElement(){ 59 return fDocument; 60 } 61 62 65 public void initializeValidationData(IProgressMonitor pm) { 66 fLength= fDocument.getLength(); 69 } 70 71 74 public RefactoringStatus isValid(IProgressMonitor pm) throws CoreException { 75 pm.beginTask("", 1); RefactoringStatus result= TextChanges.isValid(fDocument, fLength); 77 pm.worked(1); 78 return result; 79 } 80 81 84 protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException { 85 return fDocument; 86 } 87 88 91 protected void commit(IDocument document, IProgressMonitor pm) throws CoreException { 92 } 94 95 98 protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException { 99 } 101 102 105 protected Change createUndoChange(UndoEdit edit) { 106 return new UndoDocumentChange(getName(), fDocument, edit); 107 } 108 } 109 110 | Popular Tags |