Class DerivedStateAwareResource

  • All Implemented Interfaces:
    org.eclipse.emf.common.notify.Notifier, org.eclipse.emf.ecore.resource.Resource, org.eclipse.emf.ecore.resource.Resource.Internal
    Direct Known Subclasses:
    GrammarResource

    public class DerivedStateAwareResource
    extends StorageAwareResource
    Adds a hook for late initialization to be used to create derived state.
    Since:
    2.1
    • Field Detail

      • fullyInitialized

        protected volatile boolean fullyInitialized
        If true, the contents list of the resource is complete. Does not necessarily apply to the contents of the elements itself.
      • isInitializing

        protected volatile boolean isInitializing
        true if this resource is currently running its derivedStateComputer to install new elements.
    • Constructor Detail

      • DerivedStateAwareResource

        public DerivedStateAwareResource()
    • Method Detail

      • setDerivedStateComputer

        public void setDerivedStateComputer​(IDerivedStateComputer lateInitialization)
      • isFullyInitialized

        public boolean isFullyInitialized()
        If true, the contents list of the resource is complete. Does not necessarily apply to the contents of the elements itself.
        Since:
        2.7
      • setFullyInitialized

        public void setFullyInitialized​(boolean fullyInitialized)
        External means to mark a resource as fully initialized, e.g. if it was created programmatically.
        Since:
        2.8
      • isInitializing

        public boolean isInitializing()
        true if this resource is currently running its derivedStateComputer to install new elements.
        Since:
        2.7
      • getContents

        public org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getContents()

        As soon as an external client tries to access the content of the resource, the derived state will be added to the content of this resource.

        Specified by:
        getContents in interface org.eclipse.emf.ecore.resource.Resource
        Overrides:
        getContents in class org.eclipse.emf.ecore.resource.impl.ResourceImpl
      • doGetContents

        protected org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> doGetContents()
        Returns:
        the contents without the side effect of installing the derived the state.
        Since:
        2.4
      • getUnloadingContents

        protected java.util.List<org.eclipse.emf.ecore.EObject> getUnloadingContents()
        Overrides:
        getUnloadingContents in class org.eclipse.emf.ecore.resource.impl.ResourceImpl
        Since:
        2.8
      • updateInternalState

        protected void updateInternalState​(IParseResult oldParseResult,
                                           IParseResult newParseResult)
        Overrides:
        updateInternalState in class XtextResource
        Parameters:
        oldParseResult - the previous parse result that should be detached if necessary.
        newParseResult - the current parse result that should be attached to the content of this resource
      • getURIFragmentRootSegment

        protected java.lang.String getURIFragmentRootSegment​(org.eclipse.emf.ecore.EObject eObject)

        Overridden to make sure that we do not initialize a resource just to compute the root URI fragment for the parse result.

        Overrides:
        getURIFragmentRootSegment in class org.eclipse.emf.ecore.resource.impl.ResourceImpl
      • getEObjectForURIFragmentRootSegment

        protected org.eclipse.emf.ecore.EObject getEObjectForURIFragmentRootSegment​(java.lang.String uriFragmentRootSegment)

        Not specialized because we want to obtain a fully working root instance when the resource is queried with the root fragment.

        Overrides:
        getEObjectForURIFragmentRootSegment in class org.eclipse.emf.ecore.resource.impl.ResourceImpl
      • discardDerivedState

        public void discardDerivedState()
      • installDerivedState

        public void installDerivedState​(boolean preIndexingPhase)
      • doDiscardDerivedState

        protected void doDiscardDerivedState()
        Since:
        2.9