本文整理汇总了Java中org.eclipse.jface.text.IDocumentExtension4类的典型用法代码示例。如果您正苦于以下问题:Java IDocumentExtension4类的具体用法?Java IDocumentExtension4怎么用?Java IDocumentExtension4使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDocumentExtension4类属于org.eclipse.jface.text包,在下文中一共展示了IDocumentExtension4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyAllInSameDocument
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
/**
* Applies all given changes to the given document. This method assumes that 'changes' contains only changes
* intended for the given document; the actual URI stored in the changes is ignored.
*/
public void applyAllInSameDocument(Collection<? extends IAtomicChange> changes, IDocument document)
throws BadLocationException {
DocumentRewriteSession rewriteSession = null;
try {
// prepare
if (document instanceof IDocumentExtension4) {
rewriteSession = ((IDocumentExtension4) document).startRewriteSession(
DocumentRewriteSessionType.UNRESTRICTED);
}
// perform replacements
for (IAtomicChange currRepl : changes) {
currRepl.apply(document);
}
} finally {
// cleanup
if (rewriteSession != null)
((IDocumentExtension4) document).stopRewriteSession(rewriteSession);
}
}
示例2: ImportRewriter
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private ImportRewriter(IDocument document, Resource resource) {
if (document instanceof IDocumentExtension4) {
lineDelimiter = ((IDocumentExtension4) document).getDefaultLineDelimiter();
} else {
lineDelimiter = Strings.newLine();
}
this.script = (Script) resource.getContents().get(0);
this.existingImports = Lists.newArrayList();
for (ScriptElement element : script.getScriptElements()) {
if (element instanceof ImportDeclaration)
existingImports.add((ImportDeclaration) element);
}
this.requestedImports = Sets.newLinkedHashSet();
this.lazySpacer = new Lazy<>(() -> spacerPreference.getSpacingPreference(resource));
}
示例3: updateModel
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public void updateModel(String prefix, String editablePart, String suffix) {
IDocument document = this.viewer.getDocument();
if (this.insertLineBreaks) {
String delimiter = document.getLegalLineDelimiters()[0];
if (document instanceof IDocumentExtension4) {
delimiter = ((IDocumentExtension4) document).getDefaultLineDelimiter();
}
prefix = prefix + delimiter;
suffix = delimiter + suffix;
}
String model = prefix + editablePart + suffix;
this.viewer.setRedraw(false);
this.viewer.getUndoManager().disconnect();
document.set(model);
this.viewer.setVisibleRegion(prefix.length(), editablePart.length());
this.viewer.getUndoManager().connect(this.viewer);
this.viewer.setRedraw(true);
}
示例4: updatePrefix
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public void updatePrefix(String prefix) {
try {
IDocument document = this.viewer.getDocument();
IRegion visibleRegion = this.viewer.getVisibleRegion();
String editablePart = document.get(visibleRegion.getOffset(), visibleRegion.getLength());
int suffixOffset = visibleRegion.getOffset() + visibleRegion.getLength();
String suffix = "";
if (document.getLength() - suffixOffset > 0) {
suffix = document.get(suffixOffset, document.getLength() - suffixOffset);
if (this.insertLineBreaks) {
String delimiter = document.getLegalLineDelimiters()[0];
if (document instanceof IDocumentExtension4) {
delimiter = ((IDocumentExtension4) document).getDefaultLineDelimiter();
}
suffix = suffix.substring(delimiter.length());
}
}
updateModel(prefix, editablePart, suffix);
} catch (BadLocationException e) {
throw new RuntimeException(e);
}
}
示例5: create
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public static BufferValidationState create(IFile file) {
ITextFileBuffer buffer = getBuffer(file);
if (buffer == null) {
return new ModificationStampValidationState(file);
} else {
IDocument document = buffer.getDocument();
if (document instanceof IDocumentExtension4) {
return new ModificationStampValidationState(file);
} else {
if (buffer.isDirty()) {
return new NoStampValidationState(file);
} else {
return new ModificationStampValidationState(file);
}
}
}
}
示例6: isValid
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
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;
}
示例7: checkModificationStamp
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public void checkModificationStamp(RefactoringStatus status, long stampToMatch) {
if (fKind == DOCUMENT) {
if (stampToMatch != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP
&& fModificationStamp != stampToMatch) {
status.addFatalError(
Messages.format(
RefactoringCoreMessages.ResourceChange_error_has_been_modified,
BasicElementLabels.getPathLabel(fResource.getFullPath(), false)));
}
} else {
if (stampToMatch != IResource.NULL_STAMP && fModificationStamp != stampToMatch) {
status.addFatalError(
Messages.format(
RefactoringCoreMessages.ResourceChange_error_has_been_modified,
BasicElementLabels.getPathLabel(fResource.getFullPath(), false)));
}
}
}
示例8: initializeFile
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private void initializeFile(IFile file) {
fTextFileBuffer = getBuffer(file);
if (fTextFileBuffer == null) {
initializeResource(file);
} else {
IDocument document = fTextFileBuffer.getDocument();
fDirty = fTextFileBuffer.isDirty();
fReadOnly = Resources.isReadOnly(file);
if (document instanceof IDocumentExtension4) {
fKind = DOCUMENT;
fModificationStamp = ((IDocumentExtension4) document).getModificationStamp();
} else {
fKind = RESOURCE;
fModificationStamp = file.getModificationStamp();
}
}
}
示例9: performEdits
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
/**
* Executes the text edits on the given document. Subclasses that override this method should call
* <code>super.performEdits(document)</code>.
*
* @param document the document
* @return an object representing the undo of the executed edits
* @exception MalformedTreeException is thrown if the edit tree isn't in a valid state. This
* exception is thrown before any edit is executed. So the document is still in its original
* state.
* @exception BadLocationException is thrown if one of the edits in the tree can't be executed.
* The state of the document is undefined if this exception is thrown.
* @since 3.5
*/
protected UndoEdit performEdits(IDocument document)
throws BadLocationException, MalformedTreeException {
DocumentRewriteSession session = null;
try {
if (document instanceof IDocumentExtension4) {
session =
((IDocumentExtension4) document)
.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED);
}
LinkedModeModel.closeAllModels(document);
TextEditProcessor processor = createTextEditProcessor(document, TextEdit.CREATE_UNDO, false);
return processor.performEdits();
} finally {
if (session != null) {
((IDocumentExtension4) document).stopRewriteSession(session);
}
}
}
示例10: performEdit
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
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);
}
}
}
示例11: getDocumentStamp
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private long getDocumentStamp(IFile file, IProgressMonitor monitor) throws CoreException {
final ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
final IPath path= file.getFullPath();
monitor.beginTask("", 2); //$NON-NLS-1$
ITextFileBuffer buffer= null;
try {
manager.connect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
buffer= manager.getTextFileBuffer(path, LocationKind.IFILE);
IDocument document= buffer.getDocument();
if (document instanceof IDocumentExtension4) {
return ((IDocumentExtension4)document).getModificationStamp();
} else {
return file.getModificationStamp();
}
} finally {
if (buffer != null)
manager.disconnect(path, LocationKind.IFILE, new SubProgressMonitor(monitor, 1));
monitor.done();
}
}
示例12: removeOccurrenceAnnotations
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
void removeOccurrenceAnnotations() {
fMarkOccurrenceModificationStamp= IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
fMarkOccurrenceTargetRegion= null;
IDocumentProvider documentProvider= getDocumentProvider();
if (documentProvider == null)
return;
IAnnotationModel annotationModel= documentProvider.getAnnotationModel(getEditorInput());
if (annotationModel == null || fOccurrenceAnnotations == null)
return;
synchronized (getLockObject(annotationModel)) {
if (annotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
} else {
for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++)
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
}
fOccurrenceAnnotations= null;
}
}
示例13: DocCopy
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public DocCopy(IDocument document) {
this.contents = document.get();
this.document = document;
categoryToPos = new HashMap<>();
String[] positionCategories = document.getPositionCategories();
for (String string : positionCategories) {
try {
categoryToPos.put(string, document.getPositions(string));
} catch (BadPositionCategoryException e) {
Log.log(e);
}
}
IDocumentExtension4 doc4 = (IDocumentExtension4) document;
modificationStamp = doc4.getModificationStamp();
}
示例14: initializeFile
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
private void initializeFile(IFile file) {
fTextFileBuffer = getBuffer(file);
if (fTextFileBuffer == null) {
initializeResource(file);
} else {
IDocument document = fTextFileBuffer.getDocument();
fDirty = fTextFileBuffer.isDirty();
fReadOnly = isReadOnly(file);
if (document instanceof IDocumentExtension4) {
fKind = DOCUMENT;
fModificationStamp = ((IDocumentExtension4) document).getModificationStamp();
} else {
fKind = RESOURCE;
fModificationStamp = file.getModificationStamp();
}
}
}
示例15: getModificationStamp
import org.eclipse.jface.text.IDocumentExtension4; //导入依赖的package包/类
public long getModificationStamp(IResource resource) {
if (!(resource instanceof IFile)) {
return resource.getModificationStamp();
}
IFile file = (IFile) resource;
ITextFileBuffer buffer = getBuffer(file);
if (buffer == null) {
return file.getModificationStamp();
} else {
IDocument document = buffer.getDocument();
if (document instanceof IDocumentExtension4) {
return ((IDocumentExtension4) document).getModificationStamp();
} else {
return file.getModificationStamp();
}
}
}