本文整理匯總了Java中org.eclipse.ltk.core.refactoring.ContentStamp類的典型用法代碼示例。如果您正苦於以下問題:Java ContentStamp類的具體用法?Java ContentStamp怎麽用?Java ContentStamp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ContentStamp類屬於org.eclipse.ltk.core.refactoring包,在下文中一共展示了ContentStamp類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createUndoChange
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
/** {@inheritDoc} */
protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
try {
return new UndoCompilationUnitChange(getName(), fCUnit, edit, stampToRestore, getSaveMode());
} catch (CoreException e) {
JavaManipulationPlugin.log(e);
return null;
}
}
示例2: perform
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
/** {@inheritDoc} */
public Change perform(IProgressMonitor pm) throws CoreException {
if (fValidationState == null || fValidationState.isValid(needsSaving(), false).hasFatalError())
return new NullChange();
if (pm == null) pm = new NullProgressMonitor();
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
pm.beginTask("", 2); // $NON-NLS-1$
ITextFileBuffer buffer = null;
try {
manager.connect(fFile.getFullPath(), LocationKind.IFILE, new SubProgressMonitor(pm, 1));
buffer = manager.getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
IDocument document = buffer.getDocument();
ContentStamp currentStamp = ContentStamps.get(fFile, document);
// perform the changes
LinkedList list = new LinkedList();
for (int index = 0; index < fUndos.length; index++) {
UndoEdit edit = fUndos[index];
UndoEdit redo = edit.apply(document, TextEdit.CREATE_UNDO);
list.addFirst(redo);
}
// try to restore the document content stamp
boolean success = ContentStamps.set(document, fContentStampToRestore);
if (needsSaving()) {
buffer.commit(pm, false);
if (!success) {
// We weren't able to restore document stamp.
// Since we save restore the file stamp instead
ContentStamps.set(fFile, fContentStampToRestore);
}
}
return createUndoChange((UndoEdit[]) list.toArray(new UndoEdit[list.size()]), currentStamp);
} catch (BadLocationException e) {
throw Changes.asCoreException(e);
} finally {
if (buffer != null)
manager.disconnect(fFile.getFullPath(), LocationKind.IFILE, new SubProgressMonitor(pm, 1));
}
}
示例3: set
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
public static void set(IFile file, ContentStamp s) throws CoreException {
if (!(s instanceof ContentStampImpl)) return;
ContentStampImpl stamp = (ContentStampImpl) s;
long value = stamp.getFileValue();
Assert.isTrue(value != IResource.NULL_STAMP);
file.revertModificationStamp(value);
}
示例4: UndoCompilationUnitChange
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
public UndoCompilationUnitChange(
String name, ICompilationUnit unit, UndoEdit undo, ContentStamp stampToRestore, int saveMode)
throws CoreException {
super(name, getFile(unit), undo, stampToRestore, saveMode);
fCUnit = unit;
}
示例5: createUndoChange
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
/** {@inheritDoc} */
protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore)
throws CoreException {
return new UndoCompilationUnitChange(getName(), fCUnit, edit, stampToRestore, getSaveMode());
}
示例6: createFileStamp
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
private static ContentStamp createFileStamp(long value) {
return new ContentStampImpl(FILE, value, value);
}
示例7: createDocumentStamp
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
private static ContentStamp createDocumentStamp(long value, long fileValue) {
return new ContentStampImpl(DOCUMENT, value, fileValue);
}
示例8: createUndoChange
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
fUndoEdit= edit;
return super.createUndoChange(edit, stampToRestore);
}
示例9: MultiStateUndoChange
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
/**
* Create a new multi state undo change object.
*
* @param name the human readable name of the change
* @param file the file the change is working on
* @param stamp the content stamp to restore when the undo is executed
* @param undos the edit representing the undo modifications
* @param saveMode the save mode as specified by {@link TextFileChange}
* @see TextFileChange#KEEP_SAVE_STATE
* @see TextFileChange#FORCE_SAVE
* @see TextFileChange#LEAVE_DIRTY
*/
public MultiStateUndoChange(
String name, IFile file, UndoEdit[] undos, ContentStamp stamp, int saveMode) {
Assert.isNotNull(name);
Assert.isNotNull(file);
Assert.isNotNull(undos);
fName = name;
fFile = file;
fUndos = undos;
fContentStampToRestore = stamp;
fSaveMode = saveMode;
}
示例10: createUndoChange
import org.eclipse.ltk.core.refactoring.ContentStamp; //導入依賴的package包/類
/**
* Hook to create an undo change for the given undo edit. This hook gets called while performing
* the change to construct the corresponding undo change object.
*
* <p>Subclasses may override it to create a different undo change.
*
* @param edits the {@link UndoEdit undo edit} to create a undo change for
* @param stampToRestore the content stamp to restore when the undo edit is executed.
* @return the undo change
* @throws CoreException if an undo change can't be created
*/
protected Change createUndoChange(UndoEdit[] edits, ContentStamp stampToRestore)
throws CoreException {
return new MultiStateUndoChange(getName(), fFile, edits, stampToRestore, fSaveMode);
}