Class AbstractFeatureScopeSession
- java.lang.Object
-
- org.eclipse.xtext.xbase.scoping.batch.AbstractFeatureScopeSession
-
- All Implemented Interfaces:
IFeatureScopeSession
,IVisibilityHelper
- Direct Known Subclasses:
AbstractNestedFeatureScopeSession
,RootFeatureScopeSession
public abstract class AbstractFeatureScopeSession extends java.lang.Object implements IFeatureScopeSession
Skeleton implementation for feature scope sessions. It introduces a simple means to identify the nesting level (getId()
. Requested scopes for other things that features are delegated to thedefault scope provider
. The concrete scope computation is performed bya utility
.
-
-
Field Summary
-
Fields inherited from interface org.eclipse.xtext.xbase.typesystem.util.IVisibilityHelper
ALL
-
-
Constructor Summary
Constructors Constructor Description AbstractFeatureScopeSession()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addExtensionProviders(java.util.List<ExpressionBucket> result)
IFeatureScopeSession
addImports(ITypeImporter.Client importer)
Add types to the session that are either imported statically or as extension.IFeatureScopeSession
addLocalElement(org.eclipse.xtext.naming.QualifiedName name, org.eclipse.xtext.common.types.JvmIdentifiableElement element, ITypeReferenceOwner owner)
Add a locally defined identifiable to this scope.protected void
addLocalElements(java.util.List<org.eclipse.xtext.resource.IEObjectDescription> result)
IFeatureScopeSession
addLocalElements(java.util.Map<org.eclipse.xtext.naming.QualifiedName,org.eclipse.xtext.common.types.JvmIdentifiableElement> elements, ITypeReferenceOwner owner)
Add locally defined identifiables to this scope.IFeatureScopeSession
addNestedTypesToScope(org.eclipse.xtext.common.types.JvmDeclaredType type)
Make inherited and declared nested classes oftype
available by their simple names.IFeatureScopeSession
addToExtensionScope(java.util.Map<XExpression,LightweightTypeReference> extensionProviders)
Add receivers to the session that contribute extensions.IFeatureScopeSession
addTypesToStaticScope(java.util.List<? extends org.eclipse.xtext.common.types.JvmType> staticFeatureProviders, java.util.List<? extends org.eclipse.xtext.common.types.JvmType> extensionProviders)
Add types to the session that are imported statically either as plain static imports or with an extension semantic.IFeatureScopeSession
captureLocalElements()
Allows to capture the available local elements as if they have been defined on thethis
type as a member.protected org.eclipse.xtext.scoping.IScope
createConstructorScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes resolvedTypes)
protected org.eclipse.xtext.scoping.IScope
createFeatureCallScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes resolvedTypes)
protected org.eclipse.xtext.scoping.IScope
createTypeScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes resolvedTypes)
IFeatureScopeSession
dropLocalElements()
Allows to drop certain local elements from the current scope such as the enclosingthis
for static inner classes.protected abstract ConstructorScopes
getConstructorScopes()
protected abstract org.eclipse.xtext.scoping.IScopeProvider
getDefaultScopeProvider()
java.util.List<org.eclipse.xtext.common.types.JvmDeclaredType>
getEnclosingTypes()
Returns a list of enclosing types that provide an instance in the current context.java.util.List<ExpressionBucket>
getExtensionProviders()
All extension providers as expression buckets.protected abstract FeatureScopes
getFeatureScopes()
protected abstract int
getId()
A simple means to identify the session.java.util.List<org.eclipse.xtext.resource.IEObjectDescription>
getLocalElements()
Return all local elements that are known in this session.java.util.List<org.eclipse.xtext.common.types.JvmDeclaredType>
getNestedTypeDeclarators()
Returns enclosing types that declare available nested types.IFeatureScopeSession
getNextCaptureLayer()
Returns the next layer of the captured scopes.protected abstract IResolvedFeatures.Provider
getResolvedFeaturesProvider()
org.eclipse.xtext.scoping.IScope
getScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes types)
Return the scope for the givencontext
andreference
based on the known resolvedtypes
.java.util.List<TypeBucket>
getStaticallyImportedExtensionTypes()
All statically imported extension types as type buckets.java.util.List<TypeBucket>
getStaticallyImportedTypes()
All statically imported types as type buckets.protected abstract TypeScopes
getTypeScopes()
IFeatureScopeSession
toConstructorContext()
Forks this session with a constructor context.IFeatureScopeSession
toInstanceContext()
Forks this session with an instance context.protected AbstractNestedFeatureScopeSession
tryCreateNestedSessionWithVisibilityContext(java.util.Map<org.eclipse.xtext.naming.QualifiedName,org.eclipse.xtext.common.types.JvmIdentifiableElement> elements, ITypeReferenceOwner owner, org.eclipse.xtext.naming.QualifiedName thisName)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.xtext.xbase.scoping.batch.IFeatureScopeSession
getLocalElement, isConstructorContext, isInstanceContext, isVisible
-
Methods inherited from interface org.eclipse.xtext.xbase.typesystem.util.IVisibilityHelper
isVisible
-
-
-
-
Method Detail
-
getScope
public org.eclipse.xtext.scoping.IScope getScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes types)
Description copied from interface:IFeatureScopeSession
Return the scope for the givencontext
andreference
based on the known resolvedtypes
.- Specified by:
getScope
in interfaceIFeatureScopeSession
- Parameters:
context
- the context object. May not benull
.reference
- the reference that holds the unresolved proxy. May not benull
.types
- the already computed types.- See Also:
IScopeProvider.getScope(EObject, EReference)
-
addTypesToStaticScope
public IFeatureScopeSession addTypesToStaticScope(java.util.List<? extends org.eclipse.xtext.common.types.JvmType> staticFeatureProviders, java.util.List<? extends org.eclipse.xtext.common.types.JvmType> extensionProviders)
Description copied from interface:IFeatureScopeSession
Add types to the session that are imported statically either as plain static imports or with an extension semantic.- Specified by:
addTypesToStaticScope
in interfaceIFeatureScopeSession
- Parameters:
staticFeatureProviders
- the static feature providers. May not benull
.extensionProviders
- the static extension providers. May not benull
.- Returns:
- a configured session.
-
addImports
public IFeatureScopeSession addImports(ITypeImporter.Client importer)
Description copied from interface:IFeatureScopeSession
Add types to the session that are either imported statically or as extension.- Specified by:
addImports
in interfaceIFeatureScopeSession
- Parameters:
importer
- the description of the imported types.- Returns:
- a configured session.
-
getResolvedFeaturesProvider
protected abstract IResolvedFeatures.Provider getResolvedFeaturesProvider()
-
getFeatureScopes
protected abstract FeatureScopes getFeatureScopes()
-
getConstructorScopes
protected abstract ConstructorScopes getConstructorScopes()
-
getTypeScopes
protected abstract TypeScopes getTypeScopes()
-
getDefaultScopeProvider
protected abstract org.eclipse.xtext.scoping.IScopeProvider getDefaultScopeProvider()
-
getId
protected abstract int getId()
A simple means to identify the session.
-
addToExtensionScope
public IFeatureScopeSession addToExtensionScope(java.util.Map<XExpression,LightweightTypeReference> extensionProviders)
Description copied from interface:IFeatureScopeSession
Add receivers to the session that contribute extensions. The expressions in the map will be cloned on demand prior to adding them to the model. They are prototypes.- Specified by:
addToExtensionScope
in interfaceIFeatureScopeSession
- Parameters:
extensionProviders
- the expressions that yield extension receivers.- Returns:
- a configured session.
-
addNestedTypesToScope
public IFeatureScopeSession addNestedTypesToScope(org.eclipse.xtext.common.types.JvmDeclaredType type)
Description copied from interface:IFeatureScopeSession
Make inherited and declared nested classes oftype
available by their simple names.- Specified by:
addNestedTypesToScope
in interfaceIFeatureScopeSession
-
getEnclosingTypes
public java.util.List<org.eclipse.xtext.common.types.JvmDeclaredType> getEnclosingTypes()
Description copied from interface:IFeatureScopeSession
Returns a list of enclosing types that provide an instance in the current context. The first element in the list is the innermost type.- Specified by:
getEnclosingTypes
in interfaceIFeatureScopeSession
-
getNestedTypeDeclarators
public java.util.List<org.eclipse.xtext.common.types.JvmDeclaredType> getNestedTypeDeclarators()
Description copied from interface:IFeatureScopeSession
Returns enclosing types that declare available nested types. The first element in the list is the innermost type.- Specified by:
getNestedTypeDeclarators
in interfaceIFeatureScopeSession
-
getNextCaptureLayer
public IFeatureScopeSession getNextCaptureLayer()
Description copied from interface:IFeatureScopeSession
Returns the next layer of the captured scopes.- Specified by:
getNextCaptureLayer
in interfaceIFeatureScopeSession
-
toInstanceContext
public IFeatureScopeSession toInstanceContext()
Description copied from interface:IFeatureScopeSession
Forks this session with an instance context. References to 'this' are only valid in instance contexts.- Specified by:
toInstanceContext
in interfaceIFeatureScopeSession
- See Also:
IFeatureScopeSession.isInstanceContext()
-
toConstructorContext
public IFeatureScopeSession toConstructorContext()
Description copied from interface:IFeatureScopeSession
Forks this session with a constructor context. References to delegation constructors are only valid within this context.- Specified by:
toConstructorContext
in interfaceIFeatureScopeSession
- See Also:
IFeatureScopeSession.isInstanceContext()
-
dropLocalElements
public IFeatureScopeSession dropLocalElements()
Description copied from interface:IFeatureScopeSession
Allows to drop certain local elements from the current scope such as the enclosingthis
for static inner classes.- Specified by:
dropLocalElements
in interfaceIFeatureScopeSession
-
captureLocalElements
public IFeatureScopeSession captureLocalElements()
Description copied from interface:IFeatureScopeSession
Allows to capture the available local elements as if they have been defined on thethis
type as a member. This will provide a proper scope for non static nested or local classes.- Specified by:
captureLocalElements
in interfaceIFeatureScopeSession
-
addLocalElement
public IFeatureScopeSession addLocalElement(org.eclipse.xtext.naming.QualifiedName name, org.eclipse.xtext.common.types.JvmIdentifiableElement element, ITypeReferenceOwner owner)
Description copied from interface:IFeatureScopeSession
Add a locally defined identifiable to this scope. It will shadow previously registered locals. No validation of the given name is performed.- Specified by:
addLocalElement
in interfaceIFeatureScopeSession
- Parameters:
name
- the qualified name of the identifiable.element
- the element itself.- Returns:
- a configured session.
-
addLocalElements
public IFeatureScopeSession addLocalElements(java.util.Map<org.eclipse.xtext.naming.QualifiedName,org.eclipse.xtext.common.types.JvmIdentifiableElement> elements, ITypeReferenceOwner owner)
Description copied from interface:IFeatureScopeSession
Add locally defined identifiables to this scope. Since the elements have unique names, they cannot shadow each other. However, they will shadow previously added local elements.- Specified by:
addLocalElements
in interfaceIFeatureScopeSession
- Parameters:
elements
- the local elements.- Returns:
- a configured session.
-
tryCreateNestedSessionWithVisibilityContext
protected AbstractNestedFeatureScopeSession tryCreateNestedSessionWithVisibilityContext(java.util.Map<org.eclipse.xtext.naming.QualifiedName,org.eclipse.xtext.common.types.JvmIdentifiableElement> elements, ITypeReferenceOwner owner, org.eclipse.xtext.naming.QualifiedName thisName)
-
createFeatureCallScope
protected org.eclipse.xtext.scoping.IScope createFeatureCallScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes resolvedTypes)
-
createConstructorScope
protected org.eclipse.xtext.scoping.IScope createConstructorScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes resolvedTypes)
-
createTypeScope
protected org.eclipse.xtext.scoping.IScope createTypeScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, IResolvedTypes resolvedTypes)
-
getLocalElements
public java.util.List<org.eclipse.xtext.resource.IEObjectDescription> getLocalElements()
Description copied from interface:IFeatureScopeSession
Return all local elements that are known in this session.- Specified by:
getLocalElements
in interfaceIFeatureScopeSession
- Returns:
- all local elements. Never
null
.
-
addLocalElements
protected void addLocalElements(java.util.List<org.eclipse.xtext.resource.IEObjectDescription> result)
- Parameters:
result
- the list of all local elements. Shadowing semantics do not have to be applied.
-
getStaticallyImportedTypes
public java.util.List<TypeBucket> getStaticallyImportedTypes()
Description copied from interface:IFeatureScopeSession
All statically imported types as type buckets. The list has usually two elements:- The implicitly imported types as a single bucket.
- The explicitly imported types as a single bucket.
- Specified by:
getStaticallyImportedTypes
in interfaceIFeatureScopeSession
-
getStaticallyImportedExtensionTypes
public java.util.List<TypeBucket> getStaticallyImportedExtensionTypes()
Description copied from interface:IFeatureScopeSession
All statically imported extension types as type buckets. The list has usually two elements:- The implicitly available extensions as a single bucket.
- The explicitly imported extensions as a single bucket.
- Specified by:
getStaticallyImportedExtensionTypes
in interfaceIFeatureScopeSession
-
getExtensionProviders
public java.util.List<ExpressionBucket> getExtensionProviders()
Description copied from interface:IFeatureScopeSession
All extension providers as expression buckets.- Specified by:
getExtensionProviders
in interfaceIFeatureScopeSession
- Returns:
- the list of extension providers.
-
addExtensionProviders
protected void addExtensionProviders(java.util.List<ExpressionBucket> result)
- Parameters:
result
- an aggregating parameter that accepts the extension providers.
-
-