public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived) throws CoreException { RefactoringStatus result= super.isValid(needsSaving, resilientForDerived); if (result.hasFatalError()) return result; ModificationStamp currentStamp= getModificationStamp(); // we don't need to check the kind here since the document stamp // and file stamp are in sync for documents implementing // IDocumentExtension4. If both are file stamps the file must // not be dirty if (fModificationStamp.getValue() != currentStamp.getValue() // we know here that the stamp value are equal. However, if // the stamp is a null stamp then the king must be equal as well. || (fModificationStamp.isFileStamp() && fModificationStamp.getValue() == IResource.NULL_STAMP && !currentStamp.isFileStamp()) || (fModificationStamp.isDocumentStamp() && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && !currentStamp.isDocumentStamp()) || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) { result.addFatalError(Messages.format( RefactoringCoreMessages.TextChanges_error_content_changed, fFile.getFullPath().toString() )); } return result; } }
@Override public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived) throws CoreException { RefactoringStatus result= super.isValid(needsSaving, resilientForDerived); if (result.hasFatalError()) return result; ModificationStamp currentStamp= getModificationStamp(); // we don't need to check the kind here since the document stamp // and file stamp are in sync for documents implementing // IDocumentExtension4. If both are file stamps the file must // not be dirty if (fModificationStamp.getValue() != currentStamp.getValue() // we know here that the stamp value are equal. However, if // the stamp is a null stamp then the king must be equal as well. || (fModificationStamp.isFileStamp() && fModificationStamp.getValue() == IResource.NULL_STAMP && !currentStamp.isFileStamp()) || (fModificationStamp.isDocumentStamp() && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && !currentStamp.isDocumentStamp()) || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) { result.addFatalError(Messages.format( RefactoringCoreMessages.TextChanges_error_content_changed, BasicElementLabels.getPathLabel(fFile.getFullPath(), false) )); } return result; } }
@Override public RefactoringStatus isValid(boolean needsSaving, boolean resilientForDerived) throws CoreException { RefactoringStatus result= super.isValid(needsSaving, resilientForDerived); if (result.hasFatalError()) return result; ModificationStamp currentStamp= getModificationStamp(); // we don't need to check the kind here since the document stamp // and file stamp are in sync for documents implementing // IDocumentExtension4. If both are file stamps the file must // not be dirty if (fModificationStamp.getValue() != currentStamp.getValue() // we know here that the stamp value are equal. However, if // the stamp is a null stamp then the king must be equal as well. || (fModificationStamp.isFileStamp() && fModificationStamp.getValue() == IResource.NULL_STAMP && !currentStamp.isFileStamp()) || (fModificationStamp.isDocumentStamp() && fModificationStamp.getValue() == IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP && !currentStamp.isDocumentStamp()) || (fModificationStamp.isFileStamp() && currentStamp.isFileStamp() && isDirty(fFile))) { result.addFatalError(Messages.format( RefactoringCoreMessages.TextChanges_error_content_changed, BasicElementLabels.getPathLabel(fFile.getFullPath(), false) )); } return result; } }
protected ModificationStamp getModificationStamp() { ITextFileBuffer buffer= getBuffer(fFile); if (buffer == null) { return ModificationStamp.createFile(fFile.getModificationStamp()); } else { IDocument document= buffer.getDocument(); if (document instanceof IDocumentExtension4) { return ModificationStamp.createDocument(((IDocumentExtension4)document).getModificationStamp()); } else { return ModificationStamp.createFile(fFile.getModificationStamp()); } } } }
protected ModificationStamp getModificationStamp() { ITextFileBuffer buffer= getBuffer(fFile); if (buffer == null) { return ModificationStamp.createFile(fFile.getModificationStamp()); } else { IDocument document= buffer.getDocument(); if (document instanceof IDocumentExtension4) { return ModificationStamp.createDocument(((IDocumentExtension4)document).getModificationStamp()); } else { return ModificationStamp.createFile(fFile.getModificationStamp()); } } } }
protected ModificationStamp getModificationStamp() { ITextFileBuffer buffer= getBuffer(fFile); if (buffer == null) { return ModificationStamp.createFile(fFile.getModificationStamp()); } else { IDocument document= buffer.getDocument(); if (document instanceof IDocumentExtension4) { return ModificationStamp.createDocument(((IDocumentExtension4)document).getModificationStamp()); } else { return ModificationStamp.createFile(fFile.getModificationStamp()); } } } }
public static ModificationStamp createDocument(long value) { return new ModificationStamp(DOCUMENT, value); } private ModificationStamp(int kind, long value) {
public static ModificationStamp createFile(long value) { return new ModificationStamp(FILE, value); } public static ModificationStamp createDocument(long value) {
public static ModificationStamp createDocument(long value) { return new ModificationStamp(DOCUMENT, value); } private ModificationStamp(int kind, long value) {
public static ModificationStamp createFile(long value) { return new ModificationStamp(FILE, value); } public static ModificationStamp createDocument(long value) {
public static ModificationStamp createFile(long value) { return new ModificationStamp(FILE, value); } public static ModificationStamp createDocument(long value) {
public static ModificationStamp createDocument(long value) { return new ModificationStamp(DOCUMENT, value); } private ModificationStamp(int kind, long value) {