org.eclipse.xtext.xbase.scoping.featurecalls
Class JvmFeatureScopeProvider

java.lang.Object
  extended by org.eclipse.xtext.xbase.scoping.featurecalls.JvmFeatureScopeProvider
All Implemented Interfaces:
IJvmFeatureScopeProvider

public class JvmFeatureScopeProvider
extends java.lang.Object
implements IJvmFeatureScopeProvider

Provides a feature scope for a type, based on the type hierarchy. It also allows to add additional secondary elements, it sorts invalid elements out and adds it to the end of the scope hierarchy, and it allows to apply lower prioritized, sugared versions of the JvmFeatureDescriptions contained in the provided Scope.

Author:
Sven Efftinge - Initial contribution and API

Nested Class Summary
protected static class JvmFeatureScopeProvider.JvmFeatureDescriptionList
           
 
Constructor Summary
JvmFeatureScopeProvider()
           
 
Method Summary
protected  JvmFeatureScopeProvider.JvmFeatureDescriptionList createFeatureScope(JvmTypeReference type, TypeArgumentContext context, IJvmFeatureDescriptionProvider jvmFeatureDescriptionProvider)
           
 JvmFeatureScope createFeatureScopeForTypeRef(IScope parent, JvmTypeReference typeReference, java.util.List<IJvmFeatureDescriptionProvider> jvmFeatureDescriptionProviders)
           Provides the feature scope for a given JvmTypeReference, using the given IJvmFeatureDescriptionProvider.
protected  java.util.List<JvmFeatureScopeProvider.JvmFeatureDescriptionList> createFeatureScopes(java.lang.Iterable<JvmTypeReference> hierarchy, TypeArgumentContext context, IJvmFeatureDescriptionProvider jvmFeatureDescriptionProvider)
           
protected  JvmFeatureScope createJvmFeatureScope(IScope current, JvmFeatureScopeProvider.JvmFeatureDescriptionList featureDescs)
           
protected  java.lang.Iterable<? extends JvmFeature> getFeaturesForType(JvmTypeReference type, IJvmFeatureDescriptionProvider descriptionProvider)
           
protected  boolean isValidFeature(JvmFeature input)
           
 java.lang.Iterable<JvmTypeReference> linearizeTypeHierarchy(JvmTypeReference typeRef)
           
 void setSuperTypeCollector(SuperTypeCollector superTypeCollector)
           
 void setTypeArgumentContextProvider(TypeArgumentContextProvider typeArgumentContextProvider)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JvmFeatureScopeProvider

public JvmFeatureScopeProvider()
Method Detail

setTypeArgumentContextProvider

public void setTypeArgumentContextProvider(TypeArgumentContextProvider typeArgumentContextProvider)

setSuperTypeCollector

public void setSuperTypeCollector(SuperTypeCollector superTypeCollector)

createFeatureScopeForTypeRef

public JvmFeatureScope createFeatureScopeForTypeRef(IScope parent,
                                                    JvmTypeReference typeReference,
                                                    java.util.List<IJvmFeatureDescriptionProvider> jvmFeatureDescriptionProviders)

Provides the feature scope for a given JvmTypeReference, using the given IJvmFeatureDescriptionProvider.

The default implementation traverses the type hierarchy of the given JvmTypeReference and asks the IJvmFeatureDescriptionProvider to create any number of JvmFeatureDescription for each JvmFeature.

In a second traversal the XFeatureCallSugarDescriptionProvider is asked to add additional sugar for each JvmFeatureDescription which gets less priority than all the descriptions from the first traversal (i.e. sugar is contained in parent scopes).

JvmFeatureDescriptions marked as invalid JvmFeatureDescription.isValid(), will be sorted last (even after sugar). This ensures that it is shadowed by valid elements and can be filtered out if not needed.

Specified by:
createFeatureScopeForTypeRef in interface IJvmFeatureScopeProvider
typeReference - the type whose features should be provided.

createJvmFeatureScope

protected JvmFeatureScope createJvmFeatureScope(IScope current,
                                                JvmFeatureScopeProvider.JvmFeatureDescriptionList featureDescs)

createFeatureScopes

protected java.util.List<JvmFeatureScopeProvider.JvmFeatureDescriptionList> createFeatureScopes(java.lang.Iterable<JvmTypeReference> hierarchy,
                                                                                                TypeArgumentContext context,
                                                                                                IJvmFeatureDescriptionProvider jvmFeatureDescriptionProvider)

createFeatureScope

protected JvmFeatureScopeProvider.JvmFeatureDescriptionList createFeatureScope(JvmTypeReference type,
                                                                               TypeArgumentContext context,
                                                                               IJvmFeatureDescriptionProvider jvmFeatureDescriptionProvider)

getFeaturesForType

protected java.lang.Iterable<? extends JvmFeature> getFeaturesForType(JvmTypeReference type,
                                                                      IJvmFeatureDescriptionProvider descriptionProvider)

isValidFeature

protected boolean isValidFeature(JvmFeature input)

linearizeTypeHierarchy

public java.lang.Iterable<JvmTypeReference> linearizeTypeHierarchy(JvmTypeReference typeRef)
Returns:
an iterable containing the given type and all its super types in a deterministic order. The order is more specific types come first. This method also adds any convertable types e.g. wrapper types for primitives