Class WorkingCopyReconciler

  • All Implemented Interfaces:
    org.eclipse.jface.text.ITextViewerLifecycle, org.eclipse.jface.text.reconciler.IReconciler
    Direct Known Subclasses:
    EditorWorkingCopyReconciler

    public abstract class WorkingCopyReconciler
    extends org.eclipse.jface.text.reconciler.AbstractReconciler
    An abstract base class of a working copy reconciler that is activated on viewer activation and forces reconciling on a significant change in the underlying model.
    • Constructor Summary

      Constructors 
      Constructor Description
      WorkingCopyReconciler​(java.util.function.Function<org.eclipse.jface.text.IDocument,​ISourceFile> documentToSourceFile)
      Creates a new working copy reconciler with a function that is used to determine the source file for the reconciler's document.
      WorkingCopyReconciler​(IWorkingCopyManager workingCopyManager)
      Creates a new working copy reconciler with the given working copy manager.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract void addElementChangeListener​(IElementChangeListener listener)
      Registers the given element change listener with the underlying model.
      protected void elementChanged​(IElementChangeEvent event)
      Notifies that this reconciler is affected in some way by the given element change event.
      protected void forceReconciling()  
      protected java.lang.Object getReconcilerLock()
      Returns the mutex for this reconciler.
      org.eclipse.jface.text.reconciler.IReconcilingStrategy getReconcilingStrategy​(java.lang.String contentType)
      protected void initialProcess()
      void install​(org.eclipse.jface.text.ITextViewer textViewer)
      protected boolean isActive()
      Returns whether this reconciler is currently active.
      protected boolean isAffectedBy​(IElementChangeEvent event)
      Returns whether this reconciler is affected in some way by the given element change event.
      protected boolean isAffectedBy​(IElementDelta delta, ISourceFile sourceFile)
      Returns whether this reconciler is affected by the given element delta with regard to the given source file.
      protected void process​(org.eclipse.jface.text.reconciler.DirtyRegion dirtyRegion)  
      protected void reconcilerDocumentChanged​(org.eclipse.jface.text.IDocument newDocument)  
      protected abstract void removeElementChangeListener​(IElementChangeListener listener)
      Removes the given element change listener from the underlying model.
      protected void setActive​(boolean active)
      Indicates a change in the active state of this reconciler.
      void setProgressMonitor​(org.eclipse.core.runtime.IProgressMonitor monitor)  
      void setReconcilingStrategy​(org.eclipse.jface.text.reconciler.IReconcilingStrategy strategy)
      Sets the reconciling strategy that is to be used by this reconciler.
      void uninstall()  
      • Methods inherited from class org.eclipse.jface.text.reconciler.AbstractReconciler

        aboutToBeReconciled, aboutToWork, getDocument, getProgressMonitor, getTextViewer, isIncrementalReconciler, isRunningInReconcilerThread, reconcilerReset, setDelay, setIsAllowedToModifyDocument, setIsIncrementalReconciler, signalWaitForFinish, startReconciling
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WorkingCopyReconciler

        public WorkingCopyReconciler​(IWorkingCopyManager workingCopyManager)
        Creates a new working copy reconciler with the given working copy manager. The working copy manager is used to determine the working copy for the reconciler's document. The reconciler is configured with a single reconciling strategy (by default, a WorkingCopyReconcilingStrategy) that is used irrespective of where a dirty region is located in the reconciler's document.
        Parameters:
        workingCopyManager - not null
      • WorkingCopyReconciler

        public WorkingCopyReconciler​(java.util.function.Function<org.eclipse.jface.text.IDocument,​ISourceFile> documentToSourceFile)
        Creates a new working copy reconciler with a function that is used to determine the source file for the reconciler's document. The reconciler is configured with a single reconciling strategy (by default, a WorkingCopyReconcilingStrategy) that is used irrespective of where a dirty region is located in the reconciler's document.
        Parameters:
        documentToSourceFile - not null
        Since:
        1.5
    • Method Detail

      • setReconcilingStrategy

        public void setReconcilingStrategy​(org.eclipse.jface.text.reconciler.IReconcilingStrategy strategy)
        Sets the reconciling strategy that is to be used by this reconciler.
        Parameters:
        strategy - not null
      • setProgressMonitor

        public void setProgressMonitor​(org.eclipse.core.runtime.IProgressMonitor monitor)
        Overrides:
        setProgressMonitor in class org.eclipse.jface.text.reconciler.AbstractReconciler
      • install

        public void install​(org.eclipse.jface.text.ITextViewer textViewer)

        WorkingCopyReconciler extends this method to register an element change listener that notifies when a change in the underlying model affects the reconciler in some way, and also to register a shell listener that sets the active state of the reconciler when the reconciler's text viewer is activated or deactivated.

        Specified by:
        install in interface org.eclipse.jface.text.reconciler.IReconciler
        Specified by:
        install in interface org.eclipse.jface.text.ITextViewerLifecycle
        Overrides:
        install in class org.eclipse.jface.text.reconciler.AbstractReconciler
      • uninstall

        public void uninstall()
        Specified by:
        uninstall in interface org.eclipse.jface.text.reconciler.IReconciler
        Specified by:
        uninstall in interface org.eclipse.jface.text.ITextViewerLifecycle
        Overrides:
        uninstall in class org.eclipse.jface.text.reconciler.AbstractReconciler
      • getReconcilingStrategy

        public org.eclipse.jface.text.reconciler.IReconcilingStrategy getReconcilingStrategy​(java.lang.String contentType)

        This implementation always returns the single strategy of this reconciler.

      • initialProcess

        protected void initialProcess()

        If the reconciling strategy of this reconciler supports IReconcilingStrategyExtension, this implementation invokes initialReconcile() on the strategy under the reconciler's lock.

        Overrides:
        initialProcess in class org.eclipse.jface.text.reconciler.AbstractReconciler
      • process

        protected void process​(org.eclipse.jface.text.reconciler.DirtyRegion dirtyRegion)
        Specified by:
        process in class org.eclipse.jface.text.reconciler.AbstractReconciler
      • forceReconciling

        protected void forceReconciling()
        Overrides:
        forceReconciling in class org.eclipse.jface.text.reconciler.AbstractReconciler
      • reconcilerDocumentChanged

        protected void reconcilerDocumentChanged​(org.eclipse.jface.text.IDocument newDocument)
        Specified by:
        reconcilerDocumentChanged in class org.eclipse.jface.text.reconciler.AbstractReconciler
      • getReconcilerLock

        protected java.lang.Object getReconcilerLock()
        Returns the mutex for this reconciler. See Bug 66176 for a description of the underlying problem.

        Default implementation returns this. Subclasses may override.

        Returns:
        the mutex for the reconciler (never null)
      • addElementChangeListener

        protected abstract void addElementChangeListener​(IElementChangeListener listener)
        Registers the given element change listener with the underlying model.
        Parameters:
        listener - never null
      • removeElementChangeListener

        protected abstract void removeElementChangeListener​(IElementChangeListener listener)
        Removes the given element change listener from the underlying model.
        Parameters:
        listener - never null
      • isAffectedBy

        protected boolean isAffectedBy​(IElementChangeEvent event)
        Returns whether this reconciler is affected in some way by the given element change event.

        This implementation delegates to isAffectedBy(IElementDelta, ISourceFile), passing the source file for the reconciler's document.

        Parameters:
        event - never null
        Returns:
        true if the reconciler is affected by the given element change event, and false otherwise
      • isAffectedBy

        protected boolean isAffectedBy​(IElementDelta delta,
                                       ISourceFile sourceFile)
        Returns whether this reconciler is affected by the given element delta with regard to the given source file.
        Parameters:
        delta - never null
        sourceFile - may be null
        Returns:
        true if the reconciler is affected by the given delta, and false otherwise
      • elementChanged

        protected void elementChanged​(IElementChangeEvent event)
        Notifies that this reconciler is affected in some way by the given element change event.

        Note: This method may be called in any thread. The event object (and the deltas within it) is valid only for the duration of the invocation of this method.

        This implementation schedules a runnable to execute on the UI thread, to synchronize with setActive(boolean). The runnable will force reconciling if the reconciler is active at that time; it will also record the fact that a significant change occurred in the underlying model.

        Parameters:
        event - never null
      • isActive

        protected boolean isActive()
        Returns whether this reconciler is currently active.
        Returns:
        true if this reconciler is currently active, and false otherwise
      • setActive

        protected void setActive​(boolean active)
        Indicates a change in the active state of this reconciler. This method can only be executed by the UI thread.

        This implementation sets the active state of the reconciler to the given value. Also, it forces reconciling if a significant model change occurred while the reconciler was not active.

        Parameters:
        active - the boolean value to set for the reconciler active state