org.eclipse.xtext.resource
Class DerivedStateAwareResource

java.lang.Object
  extended by org.eclipse.emf.common.notify.impl.BasicNotifierImpl
      extended by org.eclipse.emf.common.notify.impl.NotifierImpl
          extended by org.eclipse.emf.ecore.resource.impl.ResourceImpl
              extended by org.eclipse.xtext.resource.XtextResource
                  extended by org.eclipse.xtext.linking.lazy.LazyLinkingResource
                      extended by org.eclipse.xtext.resource.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, XbaseResource

public class DerivedStateAwareResource
extends LazyLinkingResource

Adds a hook for late initialization to be used to create derived state.

Since:
2.1
Author:
Sven Efftinge - Initial contribution and API

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.xtext.linking.lazy.LazyLinkingResource
LazyLinkingResource.DiagnosticMessageContext
 
Nested classes/interfaces inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl
org.eclipse.emf.ecore.resource.impl.ResourceImpl.ContentsEList<E extends java.lang.Object & org.eclipse.emf.ecore.EObject>, org.eclipse.emf.ecore.resource.impl.ResourceImpl.ModificationTrackingAdapter
 
Nested classes/interfaces inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EAdapterList<E extends java.lang.Object & org.eclipse.emf.common.notify.Adapter>
 
Field Summary
protected  boolean fullyInitialized
           
protected  boolean isInitializing
           
 
Fields inherited from class org.eclipse.xtext.resource.XtextResource
isUpdating, OPTION_ENCODING, OPTION_FORMAT, OPTION_RESOLVE_ALL, OPTION_SERIALIZATION_OPTIONS
 
Fields inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl
contents, defaultDeleteOptions, defaultLoadOptions, defaultSaveOptions, errors, intrinsicIDToEObjectMap, isLoaded, isLoading, isModified, modificationTrackingAdapter, resourceSet, timeStamp, unloadingContents, uri, warnings
 
Fields inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl
eAdapters, EDELIVER, eFlags, ELAST_NOTIFIER_FLAG
 
Constructor Summary
DerivedStateAwareResource()
           
 
Method Summary
 void discardDerivedState()
           
 org.eclipse.emf.common.util.EList<org.eclipse.emf.ecore.EObject> getContents()
          
protected  org.eclipse.emf.ecore.EObject getEObjectForURIFragmentRootSegment(java.lang.String uriFragmentRootSegment)
          
protected  java.lang.String getURIFragmentRootSegment(org.eclipse.emf.ecore.EObject eObject)
          
 void installDerivedState(boolean preIndexingPhase)
           
 void setDerivedStateComputer(IDerivedStateComputer lateInitialization)
           
protected  void updateInternalState(IParseResult newParseResult)
          Overridden to make sure that the cache is initialized during loading.
protected  void updateInternalState(IParseResult oldParseResult, IParseResult newParseResult)
           
 
Methods inherited from class org.eclipse.xtext.linking.lazy.LazyLinkingResource
createAndAddDiagnostic, createAndAddDiagnostic, createDiagnostic, createDiagnosticMessage, createDiagnosticMessageContext, doLinking, doLoad, getDiagnosticList, getDiagnosticMessageProvider, getEncoder, getEObject, getLinkingHelper, getLinkingService, getReferences, handleCyclicResolution, isEagerLinking, isUnresolveableProxyCacheable, removeDiagnostic, resolveLazyCrossReference, resolveLazyCrossReferences, setDiagnosticMessageProvider, setEagerLinking, setEncoder, setLinkingHelper, setLinkingService
 
Methods inherited from class org.eclipse.xtext.resource.XtextResource
addSyntaxErrors, clearErrorsAndWarnings, clearInternalState, doSave, doUnload, getCache, getConcreteSyntaxValidator, getEncoding, getFragmentProvider, getLanguageName, getLinker, getParser, getParseResult, getResourceServiceProvider, getSerializer, getUnloader, getURIFragment, isValidationDisabled, reattachModificationTracker, reparse, setCache, setEncodingFromOptions, setFragmentProvider, setInjectedParser, setLanguageName, setLinker, setParser, setParseResult, setResourceServiceProvider, setSerializer, setUnloader, setValidationDisabled, unload, update, validateConcreteSyntax
 
Methods inherited from class org.eclipse.emf.ecore.resource.impl.ResourceImpl
addModificationTrackingAdapters, attached, attachedHelper, basicSetResourceSet, createModificationTrackingAdapter, delete, detached, detachedHelper, getAllContents, getAllProperContents, getAllProperContents, getDefaultURIConverter, getEObject, getEObjectByID, getErrors, getIntrinsicIDToEObjectMap, getResourceSet, getTimeStamp, getURI, getURIConverter, getWarnings, isAttachedDetachedHelperRequired, isContentZipEntry, isLoaded, isLoading, isModified, isTrackingModification, load, load, mergeMaps, newContentZipEntry, removeModificationTrackingAdapters, save, save, saveOnlyIfChangedWithFileBuffer, saveOnlyIfChangedWithMemoryBuffer, setIntrinsicIDToEObjectMap, setLoaded, setModified, setTimeStamp, setTrackingModification, setURI, toKeyString, toString, unload, unloaded, useZip
 
Methods inherited from class org.eclipse.emf.common.notify.impl.NotifierImpl
eAdapters, eBasicAdapters, eDeliver, eSetDeliver
 
Methods inherited from class org.eclipse.emf.common.notify.impl.BasicNotifierImpl
eBasicAdapterArray, eBasicHasAdapters, eNotificationRequired, eNotify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fullyInitialized

protected volatile boolean fullyInitialized

isInitializing

protected volatile boolean isInitializing
Constructor Detail

DerivedStateAwareResource

public DerivedStateAwareResource()
Method Detail

setDerivedStateComputer

public void setDerivedStateComputer(IDerivedStateComputer lateInitialization)

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

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

updateInternalState

protected void updateInternalState(IParseResult newParseResult)
Overridden to make sure that the cache is initialized during loading.

Overrides:
updateInternalState in class XtextResource

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)