Java 类org.eclipse.jface.text.ISynchronizable 实例源码

项目:eclipse.jdt.ls    文件:DocumentAdapter.java   
@Override
public void setContents(String contents) {
    synchronized (lock) {
        if (fDocument == null) {
            if (fTextFileBuffer != null) {
                fDocument = fTextFileBuffer.getDocument();
            } else {
                ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
                fDocument =  manager.createEmptyDocument(fFile.getFullPath(), LocationKind.IFILE);
            }
            fDocument.addDocumentListener(this);
            ((ISynchronizable)fDocument).setLockObject(lock);
        }
    }
    if (!contents.equals(fDocument.get())) {
        fDocument.set(contents);
    }
}
项目:bts    文件:EmbeddedEditorModelAccess.java   
protected void setModel(XtextDocument document, String prefix, String editablePart, String suffix) {
    if (this.insertLineBreaks) {
        String delimiter = document.getDefaultLineDelimiter();
        prefix = prefix + delimiter;
        suffix = delimiter + suffix;
    }
    String model = prefix + editablePart + suffix;
    document.set(model);
    XtextResource resource = createResource(model);
    document.setInput(resource);
    AnnotationModel annotationModel = new AnnotationModel();
    if (document instanceof ISynchronizable) {
        Object lock = ((ISynchronizable) document).getLockObject();
        if (lock == null) {
            lock = new Object();
            ((ISynchronizable) document).setLockObject(lock);
        }
        ((ISynchronizable) annotationModel).setLockObject(lock);
    }
    this.viewer.setDocument(document, annotationModel, prefix.length(), editablePart.length());
}
项目:Eclipse-Postfix-Code-Completion    文件:DocumentAdapter.java   
private void initialize() {
    ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
    try {
        if (fFileStore != null) {
            manager.connectFileStore(fFileStore, new NullProgressMonitor());
            fTextFileBuffer= manager.getFileStoreTextFileBuffer(fFileStore);
        } else {
            manager.connect(fPath, fLocationKind, new NullProgressMonitor());
            fTextFileBuffer= manager.getTextFileBuffer(fPath, fLocationKind);
        }
        fDocument= fTextFileBuffer.getDocument();
    } catch (CoreException x) {
        fDocument= manager.createEmptyDocument(fPath, fLocationKind);
        if (fDocument instanceof ISynchronizable)
            ((ISynchronizable)fDocument).setLockObject(new Object());
    }
    fDocument.addDocumentListener(this);
    fIsClosed= false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:DocumentAdapter.java   
private void initialize() {
    ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
    try {
        if (fFileStore != null) {
            manager.connectFileStore(fFileStore, new NullProgressMonitor());
            fTextFileBuffer= manager.getFileStoreTextFileBuffer(fFileStore);
        } else {
            manager.connect(fPath, fLocationKind, new NullProgressMonitor());
            fTextFileBuffer= manager.getTextFileBuffer(fPath, fLocationKind);
        }
        fDocument= fTextFileBuffer.getDocument();
    } catch (CoreException x) {
        fDocument= manager.createEmptyDocument(fPath, fLocationKind);
        if (fDocument instanceof ISynchronizable)
            ((ISynchronizable)fDocument).setLockObject(new Object());
    }
    fDocument.addDocumentListener(this);
    fIsClosed= false;
}
项目:texlipse    文件:TeXSpellingReconcileStrategy.java   
/**
 * Initializes this collector with the given annotation model.
 *
 * @param annotationModel the annotation model
 */
public TeXSpellingProblemCollector(IAnnotationModel annotationModel) {
    Assert.isLegal(annotationModel != null);
    fAnnotationModel= annotationModel;
    if (fAnnotationModel instanceof ISynchronizable)
        fLockObject= ((ISynchronizable)fAnnotationModel).getLockObject();
    else
        fLockObject= fAnnotationModel;
}
项目:typescript.java    文件:TypeScriptEditor.java   
/**
 * Returns the lock object for the given annotation model.
 *
 * @param annotationModel
 *            the annotation model
 * @return the annotation model's lock object
 * 
 */
private Object getLockObject(IAnnotationModel annotationModel) {
    if (annotationModel instanceof ISynchronizable) {
        Object lock = ((ISynchronizable) annotationModel).getLockObject();
        if (lock != null)
            return lock;
    }
    return annotationModel;
}
项目:bts    文件:HighlightingPresenter.java   
/**
 * @param document
 *            the document
 * @return the document's lock object
 */
private Object getLockObject(IDocument document) {
    if (document instanceof ISynchronizable) {
        Object lock = ((ISynchronizable) document).getLockObject();
        if (lock != null)
            return lock;
    }
    return document;
}
项目:APICloud-Studio    文件:NonRuleBasedDamagerRepairer.java   
private static Object getLockObject(Object object)
{
    if (object instanceof ISynchronizable)
    {
        Object lock = ((ISynchronizable) object).getLockObject();
        if (lock != null)
        {
            return lock;
        }
    }
    return object;
}
项目:APICloud-Studio    文件:CommonPresentationReconciler.java   
private static Object getLockObject(Object object)
{
    if (object instanceof ISynchronizable)
    {
        Object lock = ((ISynchronizable) object).getLockObject();
        if (lock != null)
        {
            return lock;
        }
    }
    return object;
}
项目:APICloud-Studio    文件:CommonOccurrencesUpdater.java   
/**
 * getAnnotationModelLock
 * 
 * @param annotationModel
 * @return
 */
private Object getAnnotationModelLock(IAnnotationModel annotationModel) {
    Object result = annotationModel;

    if (annotationModel instanceof ISynchronizable) {
        Object lock = ((ISynchronizable) annotationModel).getLockObject();

        if (lock != null) {
            result = lock;
        }
    }

    return result;
}
项目:APICloud-Studio    文件:MultiRegionSpellingReconcileStrategy.java   
/**
 * Initializes this collector with the given annotation model.
 *
 * @param annotationModel
 *            the annotation model
 */
public SpellingProblemCollector(IAnnotationModel annotationModel) {
    Assert.isLegal(annotationModel != null);
    fAnnotationModel = annotationModel;
    if (fAnnotationModel instanceof ISynchronizable) {
        fLockObject = ((ISynchronizable) fAnnotationModel).getLockObject();
    } else {
        fLockObject = fAnnotationModel;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ClassFileDocumentProvider.java   
@Override
protected IDocument createEmptyDocument() {
    IDocument document= FileBuffers.getTextFileBufferManager().createEmptyDocument(null, LocationKind.IFILE);
    if (document instanceof ISynchronizable)
        ((ISynchronizable)document).setLockObject(new Object());
    return document;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaEditor.java   
/**
 * Returns the lock object for the given annotation model.
 *
 * @param annotationModel the annotation model
 * @return the annotation model's lock object
 * @since 3.0
 */
private Object getLockObject(IAnnotationModel annotationModel) {
    if (annotationModel instanceof ISynchronizable) {
        Object lock= ((ISynchronizable)annotationModel).getLockObject();
        if (lock != null)
            return lock;
    }
    return annotationModel;
}
项目:Eclipse-Postfix-Code-Completion    文件:OverrideIndicatorManager.java   
/**
 * Returns the lock object for the given annotation model.
 *
 * @param annotationModel the annotation model
 * @return the annotation model's lock object
 * @since 3.0
 */
private Object getLockObject(IAnnotationModel annotationModel) {
    if (annotationModel instanceof ISynchronizable) {
        Object lock= ((ISynchronizable)annotationModel).getLockObject();
        if (lock != null)
            return lock;
    }
    return annotationModel;
}
项目:Eclipse-Postfix-Code-Completion    文件:SemanticHighlightingPresenter.java   
/**
 * @param document the document
 * @return the document's lock object
 */
private Object getLockObject(IDocument document) {
    if (document instanceof ISynchronizable) {
        Object lock= ((ISynchronizable)document).getLockObject();
        if (lock != null)
            return lock;
    }
    return document;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ClassFileDocumentProvider.java   
@Override
protected IDocument createEmptyDocument() {
    IDocument document= FileBuffers.getTextFileBufferManager().createEmptyDocument(null, LocationKind.IFILE);
    if (document instanceof ISynchronizable)
        ((ISynchronizable)document).setLockObject(new Object());
    return document;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaEditor.java   
/**
 * Returns the lock object for the given annotation model.
 *
 * @param annotationModel the annotation model
 * @return the annotation model's lock object
 * @since 3.0
 */
private Object getLockObject(IAnnotationModel annotationModel) {
    if (annotationModel instanceof ISynchronizable) {
        Object lock= ((ISynchronizable)annotationModel).getLockObject();
        if (lock != null)
            return lock;
    }
    return annotationModel;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:OverrideIndicatorManager.java   
/**
 * Returns the lock object for the given annotation model.
 *
 * @param annotationModel the annotation model
 * @return the annotation model's lock object
 * @since 3.0
 */
private Object getLockObject(IAnnotationModel annotationModel) {
    if (annotationModel instanceof ISynchronizable) {
        Object lock= ((ISynchronizable)annotationModel).getLockObject();
        if (lock != null)
            return lock;
    }
    return annotationModel;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SemanticHighlightingPresenter.java   
/**
 * @param document the document
 * @return the document's lock object
 */
private Object getLockObject(IDocument document) {
    if (document instanceof ISynchronizable) {
        Object lock= ((ISynchronizable)document).getLockObject();
        if (lock != null)
            return lock;
    }
    return document;
}
项目:Pydev    文件:BaseMarkOccurrencesJob.java   
/**
 * Gotten from JavaEditor#getLockObject
 */
protected Object getLockObject(IAnnotationModel annotationModel) {
    if (annotationModel instanceof ISynchronizable) {
        return ((ISynchronizable) annotationModel).getLockObject();
    } else {
        return annotationModel;
    }
}
项目:Pydev    文件:DocUtils.java   
public static Object runWithDocumentSynched(IDocument document, ICallback<Object, IDocument> iCallback) {
    Object lockObject = null;
    if (document instanceof ISynchronizable) {
        ISynchronizable sync = (ISynchronizable) document;
        lockObject = sync.getLockObject();
    }
    if (lockObject != null) {
        synchronized (lockObject) {
            return iCallback.call(document);
        }
    } else { //unsynched
        return iCallback.call(document);
    }

}
项目:Pydev    文件:DocumentSync.java   
public static Object runWithDocumentSynched(IDocument document, ICallback<Object, IDocument> iCallback,
        boolean createCopy) {
    Object lockObject = null;
    if (document instanceof ISynchronizable) {
        ISynchronizable sync = (ISynchronizable) document;
        lockObject = sync.getLockObject();
    }
    DocCopy docCopy = null;
    try {
        if (lockObject != null) {
            if (createCopy) {
                synchronized (lockObject) {
                    docCopy = new DocCopy(document);
                }
                return iCallback.call(docCopy);
            } else {
                synchronized (lockObject) {
                    return iCallback.call(document);
                }
            }
        } else { //unsynched
            if (createCopy && !(document instanceof DocCopy)) {
                docCopy = new DocCopy(document);
                return iCallback.call(docCopy);
            }
            return iCallback.call(document);
        }
    } finally {
        if (docCopy != null) {
            docCopy.dispose();
        }
    }
}
项目:goclipse    文件:DocumentReconcileManager.java   
public static <R> R runUnderDocumentLock(IDocument doc, CallableX<R, RuntimeException> runnable) {
    if(doc instanceof ISynchronizable) {
        ISynchronizable synchronizable = (ISynchronizable) doc;

        Object lockObject = synchronizable.getLockObject();
        if(lockObject != null) {
            synchronized(lockObject) {
                return runnable.call();
            }
        }
    }

    return runnable.call();
}
项目:Pydev    文件:DocumentSync.java   
public static IDocument createUnsynchedDocIfNeeded(IDocument doc) {
    if (doc instanceof ISynchronizable) {
        return new DocCopy(doc);
    }
    return doc;
}
项目:Pydev    文件:PyReconciler.java   
@Override
public void endCollecting() {

    List<Object> toRemove = new ArrayList<Object>();

    Object fLockObject;
    if (fAnnotationModel instanceof ISynchronizable) {
        fLockObject = ((ISynchronizable) fAnnotationModel).getLockObject();
    } else {
        fLockObject = new Object();
    }

    //let other threads execute before getting the lock on the annotation model
    Thread.yield();

    Thread thread = Thread.currentThread();
    int initiaThreadlPriority = thread.getPriority();
    try {
        //before getting the lock, let's execute with normal priority, to optimize the time that we'll 
        //retain that object locked (the annotation model is used on lots of places, so, retaining the lock
        //on it on a minimum priority thread is not a good thing.
        thread.setPriority(Thread.NORM_PRIORITY);
        Iterator<Annotation> iter;

        synchronized (fLockObject) {
            iter = fAnnotationModel.getAnnotationIterator();
            while (iter.hasNext()) {
                Object n = iter.next();
                if (n instanceof SpellingAnnotation) {
                    toRemove.add(n);
                }
            }
            iter = null;
        }

        Annotation[] annotationsToRemove = toRemove.toArray(new Annotation[toRemove.size()]);

        //let other threads execute before getting the lock (again) on the annotation model
        Thread.yield();
        synchronized (fLockObject) {
            if (fAnnotationModel instanceof IAnnotationModelExtension) {
                ((IAnnotationModelExtension) fAnnotationModel).replaceAnnotations(annotationsToRemove,
                        fAddAnnotations);
            } else {
                for (int i = 0; i < annotationsToRemove.length; i++) {
                    fAnnotationModel.removeAnnotation(annotationsToRemove[i]);
                }
                for (iter = fAddAnnotations.keySet().iterator(); iter.hasNext();) {
                    Annotation annotation = iter.next();
                    fAnnotationModel.addAnnotation(annotation, fAddAnnotations.get(annotation));
                }
            }
        }

    } finally {
        thread.setPriority(initiaThreadlPriority);
    }
    fAddAnnotations = null;
}