Java Code Examples for org.eclipse.jface.text.IDocumentExtension4#UNKNOWN_MODIFICATION_STAMP

The following examples show how to use org.eclipse.jface.text.IDocumentExtension4#UNKNOWN_MODIFICATION_STAMP . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CleanUpPostSaveListener.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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);
		}
	}
}
 
Example 2
Source File: JavaEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
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;
	}
}
 
Example 3
Source File: XtextDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public UnchangedElementListener(ElementInfo element) {
	this.element = element;
	if (element.fDocument instanceof IDocumentExtension4) {
		modificationStamp = ((IDocumentExtension4) element.fDocument).getModificationStamp();
	} else {
		modificationStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
	}

}
 
Example 4
Source File: XtextDocumentProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public long getModificationStamp(Object element) {
	if (isWorkspaceExternalEditorInput(element)) {
		IFileStore fileStore = Adapters.adapt(element, IFileStore.class);
		if (fileStore != null) {
			IFileInfo info = fileStore.fetchInfo();
			if (info.exists()) {
				return info.getLastModified();
			}
		}
		return IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
	} else {
		return super.getModificationStamp(element);
	}
}
 
Example 5
Source File: AbstractThemeableEditor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void doSetInput(IEditorInput input) throws CoreException
{
	synchronized (modificationStampLock)
	{
		// Reset our cache when a new input is set.
		lastModificationStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
		lastAstForModificationStamp = null;

	}
	super.doSetInput(input);
}
 
Example 6
Source File: AbstractThemeableEditor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public ParseResult getParseResult()
{
	try
	{
		IDocument document = getDocument();
		if (document == null)
		{
			return null;
		}
		long modificationStamp = IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP;
		if (document instanceof IDocumentExtension4)
		{
			synchronized (modificationStampLock)
			{
				IDocumentExtension4 iDocumentExtension = (IDocumentExtension4) document;
				modificationStamp = iDocumentExtension.getModificationStamp();
				if (modificationStamp != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP
						&& modificationStamp == lastModificationStamp)
				{
					return lastAstForModificationStamp;
				}
			}
		}
		// Don't synchronize the actual parse!
		ParseResult ast = doGetAST(document);

		synchronized (modificationStampLock)
		{
			lastAstForModificationStamp = ast;
			lastModificationStamp = modificationStamp;
			return lastAstForModificationStamp;
		}
	}
	catch (Throwable e)
	{
		IdeLog.logTrace(CommonEditorPlugin.getDefault(), e.getMessage(), e, IDebugScopes.AST);
	}
	return null;
}
 
Example 7
Source File: PyChange.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public void checkModificationStamp(RefactoringStatus status, long stampToMatch) {
    if (fKind == DOCUMENT) {
        if (stampToMatch != IDocumentExtension4.UNKNOWN_MODIFICATION_STAMP
                && fModificationStamp != stampToMatch) {
            status.addFatalError(StringUtils.format("Resource %s has modifications", fResource.getFullPath()));
        }
    } else {
        if (stampToMatch != IResource.NULL_STAMP && fModificationStamp != stampToMatch) {
            status.addFatalError(StringUtils.format("Resource %s has modifications", fResource.getFullPath()));

        }
    }
}