1 11 package org.eclipse.ltk.internal.core.refactoring; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IPath; 15 16 import org.eclipse.core.filebuffers.FileBuffers; 17 import org.eclipse.core.filebuffers.ITextFileBuffer; 18 import org.eclipse.core.filebuffers.ITextFileBufferManager; 19 import org.eclipse.core.filebuffers.LocationKind; 20 21 import org.eclipse.core.resources.IFile; 22 23 import org.eclipse.jface.text.IDocument; 24 25 import org.eclipse.ltk.core.refactoring.RefactoringStatus; 26 27 30 public class TextChanges { 31 32 private TextChanges() { 33 } 35 36 public static IDocument getDocument(IFile file) throws CoreException { 37 ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager(); 38 IPath path= file.getFullPath(); 39 ITextFileBuffer buffer= manager.getTextFileBuffer(path, LocationKind.IFILE); 40 if (buffer == null) 41 return null; 42 return buffer.getDocument(); 43 44 } 45 46 public static RefactoringStatus isValid(IDocument document, int length) throws CoreException { 47 RefactoringStatus result= new RefactoringStatus(); 48 if (length != document.getLength()) { 49 result.addFatalError(RefactoringCoreMessages.TextChanges_error_document_content_changed); 50 } 51 return result; 52 } 53 } 54 | Popular Tags |