org.eclipse.xtext.xbase.scoping
Class XbaseScopeProvider

java.lang.Object
  extended by org.eclipse.xtext.scoping.impl.AbstractScopeProvider
      extended by org.eclipse.xtext.xbase.scoping.XtypeScopeProvider
          extended by org.eclipse.xtext.xbase.scoping.XbaseScopeProvider
All Implemented Interfaces:
IDelegatingScopeProvider, IScopeProvider
Direct Known Subclasses:
XbaseWithAnnotationsScopeProvider

public class XbaseScopeProvider
extends XtypeScopeProvider

The scope provider for languages that use Xbase.

Author:
Sven Efftinge - Initial contribution and API, Sebastian Zarnekow - Refactored feature scoping to acceptor pattern

Nested Class Summary
protected  class XbaseScopeProvider.AbstractJvmFeatureScopeAcceptor
           
protected  class XbaseScopeProvider.GenericTypeArgumentContextFactory
           
static interface XbaseScopeProvider.IJvmFeatureScopeAcceptor
           
protected  class XbaseScopeProvider.JvmFeatureScopeAcceptor
           
protected  class XbaseScopeProvider.SimpleAcceptor
           
 
Field Summary
protected static int DEFAULT_IMPLICIT_STATIC_FEATURE_PRIORITY
           
protected static int DEFAULT_IT_PRIORITY
           
protected static int DEFAULT_MEMBER_CALL_PRIORITY
           
protected static int DEFAULT_STATIC_EXTENSION_PRIORITY_OFFSET
           
protected static int DEFAULT_SUGAR_PRIORITY_OFFSET
           
protected static int DEFAULT_THIS_PRIORITY
           
static QualifiedName IT
           
protected  IJvmFeatureScopeProvider jvmFeatureScopeProvider
           
static QualifiedName SUPER
           
static QualifiedName THIS
           
 
Constructor Summary
XbaseScopeProvider()
           
 
Method Summary
protected  boolean adaptsToJvmElement(org.eclipse.emf.ecore.EObject context)
           
protected  void addFeatureCallScopes(org.eclipse.emf.ecore.EObject expression, IScope localVariableScope, QualifiedName variableName, int priority, XbaseScopeProvider.IJvmFeatureScopeAcceptor featureScopeDescriptions)
           
protected  void addFeatureCallScopes(org.eclipse.emf.ecore.EObject featureCall, IScope localVariableScope, XbaseScopeProvider.IJvmFeatureScopeAcceptor featureScopeDescriptions)
           
protected  void addFeatureDescriptionProviders(JvmDeclaredType contextType, IFeaturesForTypeProvider featureProvider, XExpression implicitReceiver, XExpression implicitArgument, int priority, boolean preferStatics, IAcceptor<IJvmFeatureDescriptionProvider> acceptor)
           
protected  void addFeatureDescriptionProviders(org.eclipse.emf.ecore.resource.Resource resource, JvmDeclaredType contextType, XExpression implicitReceiver, XExpression implicitArgument, int priority, IAcceptor<IJvmFeatureDescriptionProvider> acceptor)
           
protected  void addFeatureDescriptionProvidersForAssignment(JvmDeclaredType contextType, IFeaturesForTypeProvider featureProvider, XExpression implicitReceiver, XExpression implicitArgument, int priority, boolean preferStatics, IAcceptor<IJvmFeatureDescriptionProvider> acceptor)
           
protected  void addFeatureDescriptionProvidersForAssignment(org.eclipse.emf.ecore.resource.Resource resource, JvmDeclaredType contextType, XExpression implicitReceiver, XExpression implicitArgument, int priority, IAcceptor<IJvmFeatureDescriptionProvider> acceptor)
           
protected  void addFeatureScopes(JvmTypeReference receiverType, org.eclipse.emf.ecore.EObject expression, JvmDeclaredType contextType, XExpression implicitReceiver, XExpression implicitArgument, int priority, XbaseScopeProvider.IJvmFeatureScopeAcceptor acceptor)
           
protected  void addStaticFeatureDescriptionProviders(org.eclipse.emf.ecore.resource.Resource resource, JvmDeclaredType contextType, IAcceptor<IJvmFeatureDescriptionProvider> acceptor)
           
protected  IScope createConstructorCallScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
           
protected  IScope createFeatureCallScope(XAbstractFeatureCall call, org.eclipse.emf.ecore.EReference reference)
          creates the feature scope for XAbstractFeatureCall, including the local variables in case it is a feature call without receiver (XFeatureCall).
 IScope createFeatureCallScopeForReceiver(XExpression context, XExpression receiver, org.eclipse.emf.ecore.EReference reference)
          This method serves as an entry point for the content assist scoping for features.
protected  IScope createFeatureScopeForTypeRef(JvmTypeReference declaringType, org.eclipse.emf.ecore.EObject expression, XExpression implicitReceiver, IScope parent)
           
protected  IScope createImplicitFeatureCallScope(org.eclipse.emf.ecore.EObject call, org.eclipse.emf.ecore.resource.Resource resource, IScope parent, IScope localVariableScope)
          override to add any other implicit feature calls.
protected  IScope createLocalScopeForParameter(JvmFormalParameter p, IScope parentScope)
           
protected  IValidatedEObjectDescription createLocalVarDescription(JvmFormalParameter p)
           
protected  IValidatedEObjectDescription createLocalVarDescription(XVariableDeclaration varDecl)
           
protected  LocalVariableScopeContext createLocalVariableScopeContext(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, boolean includeCurrentBlock, int idx)
           
protected  IScope createLocalVarScope(IScope parentScope, LocalVariableScopeContext scopeContext)
           
protected  IScope createLocalVarScopeForBlock(XBlockExpression block, int indexOfContextExpressionInBlock, boolean referredFromClosure, IScope parentScope)
           
protected  IScope createLocalVarScopeForCatchClause(XCatchClause catchClause, int indexOfContextExpressionInBlock, IScope parentScope)
          Allows to hook into the local variable definition for catch clauses.
protected  IScope createLocalVarScopeForClosure(XClosure closure, IScope parentScope)
           
protected  IScope createLocalVarScopeForJvmConstructor(JvmConstructor context, IScope parentScope)
           
protected  IScope createLocalVarScopeForJvmDeclaredType(JvmDeclaredType type, IScope parentScope)
           
protected  IScope createLocalVarScopeForJvmOperation(JvmOperation context, IScope parentScope)
           
protected  IScope createLocalVarScopeForSwitchExpression(XSwitchExpression context, IScope parentScope)
           
protected  IScope createLocalVarScopeForTypeGuardedCase(XCasePart context, IScope parentScope)
          Allows to hook into the case guards to introduce new local variables with a specialized type.
 IScope createSimpleFeatureCallScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.resource.Resource resource, boolean includeCurrentBlock, int idx)
          This method serves as an entry point for the content assist scoping for simple feature calls.
protected  IScope createTypeScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
           
protected  IScope createTypeScope(JvmIdentifiableElement context, org.eclipse.emf.ecore.EReference reference, IScope parentScope)
           
protected  JvmDeclaredType getContextType(org.eclipse.emf.ecore.EObject obj)
           
protected  int getDefaultPriority()
           
protected  FeatureCallToJavaMapping getFeatureCallToJavaMapping()
           
protected  int getImplicitStaticExtensionPriorityOffset()
           
protected  int getImplicitStaticFeaturePriority()
           
protected  int getItPriority()
           
 IScope getScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
          Returns a scope for the given context.
protected  int getSugarPriorityOffset()
           
protected  XExpression getSyntacticalReceiver(XAbstractFeatureCall call)
           
protected  int getThisPriority()
           
protected  ITypeProvider getTypeProvider()
           
protected  boolean isConstructorCallScope(org.eclipse.emf.ecore.EReference reference)
           
 boolean isFeatureCallScope(org.eclipse.emf.ecore.EReference reference)
           
protected  boolean isTypeScope(org.eclipse.emf.ecore.EReference reference)
           
protected  boolean isVisible(JvmFeature feature, JvmDeclaredType contextType)
           
protected  XConstructorProvider newConstructorProvider()
           
protected  DefaultConstructorDescriptionProvider newDefaultConstructorDescriptionProvider()
           
protected  DefaultJvmFeatureDescriptionProvider newDefaultFeatureDescriptionProvider()
           
protected  StaticImplicitMethodsFeatureForTypeProvider newImplicitStaticFeaturesProvider()
           
protected  XFeatureCallSugarDescriptionProvider newSugarDescriptionProvider()
           
 void setDefaultFeatureDescProvider(com.google.inject.Provider<DefaultJvmFeatureDescriptionProvider> defaultFeatureDescProvider)
           
 void setSugarFeatureDescProvider(com.google.inject.Provider<XFeatureCallSugarDescriptionProvider> sugarFeatureDescProvider)
           
 void setTypeProvider(ITypeProvider typeProvider)
           
protected  void sortDescriptionsFromLowestToHighest(java.util.List<IJvmFeatureScopeProvider.FeatureScopeDescription> list)
           
protected  JvmTypeReference unkownToObject(JvmTypeReference receiverType, org.eclipse.emf.ecore.EObject context)
           
 
Methods inherited from class org.eclipse.xtext.xbase.scoping.XtypeScopeProvider
delegateGetScope, getDelegate, getJvmTypeScope, setDelegate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MEMBER_CALL_PRIORITY

protected static final int DEFAULT_MEMBER_CALL_PRIORITY
See Also:
Constant Field Values

DEFAULT_IT_PRIORITY

protected static final int DEFAULT_IT_PRIORITY
See Also:
Constant Field Values

DEFAULT_THIS_PRIORITY

protected static final int DEFAULT_THIS_PRIORITY
See Also:
Constant Field Values

DEFAULT_IMPLICIT_STATIC_FEATURE_PRIORITY

protected static final int DEFAULT_IMPLICIT_STATIC_FEATURE_PRIORITY
See Also:
Constant Field Values

DEFAULT_SUGAR_PRIORITY_OFFSET

protected static final int DEFAULT_SUGAR_PRIORITY_OFFSET
See Also:
Constant Field Values

DEFAULT_STATIC_EXTENSION_PRIORITY_OFFSET

protected static final int DEFAULT_STATIC_EXTENSION_PRIORITY_OFFSET
See Also:
Constant Field Values

THIS

public static final QualifiedName THIS

SUPER

public static final QualifiedName SUPER

IT

public static final QualifiedName IT

jvmFeatureScopeProvider

@Inject
protected IJvmFeatureScopeProvider jvmFeatureScopeProvider
Constructor Detail

XbaseScopeProvider

public XbaseScopeProvider()
Method Detail

setTypeProvider

public void setTypeProvider(ITypeProvider typeProvider)

getTypeProvider

protected ITypeProvider getTypeProvider()

setSugarFeatureDescProvider

public void setSugarFeatureDescProvider(com.google.inject.Provider<XFeatureCallSugarDescriptionProvider> sugarFeatureDescProvider)

setDefaultFeatureDescProvider

public void setDefaultFeatureDescProvider(com.google.inject.Provider<DefaultJvmFeatureDescriptionProvider> defaultFeatureDescProvider)

getScope

public IScope getScope(org.eclipse.emf.ecore.EObject context,
                       org.eclipse.emf.ecore.EReference reference)
Description copied from interface: IScopeProvider
Returns a scope for the given context. The scope provides access to the compatible visible EObjects for a given reference.

Specified by:
getScope in interface IScopeProvider
Overrides:
getScope in class XtypeScopeProvider
Parameters:
context - the element from which an element shall be referenced. It doesn't need to be the element containing the reference, it is just used to find the most inner scope for given EReference.
reference - the reference for which to get the scope.
Returns:
IScope representing the inner most IScope for the passed context and reference. Note for implementors: The result may not be null. Return IScope.NULLSCOPE instead.

createTypeScope

protected IScope createTypeScope(org.eclipse.emf.ecore.EObject context,
                                 org.eclipse.emf.ecore.EReference reference)

createTypeScope

protected IScope createTypeScope(JvmIdentifiableElement context,
                                 org.eclipse.emf.ecore.EReference reference,
                                 IScope parentScope)

isTypeScope

protected boolean isTypeScope(org.eclipse.emf.ecore.EReference reference)

isVisible

protected boolean isVisible(JvmFeature feature,
                            JvmDeclaredType contextType)

createConstructorCallScope

protected IScope createConstructorCallScope(org.eclipse.emf.ecore.EObject context,
                                            org.eclipse.emf.ecore.EReference reference)

isConstructorCallScope

protected boolean isConstructorCallScope(org.eclipse.emf.ecore.EReference reference)

isFeatureCallScope

public boolean isFeatureCallScope(org.eclipse.emf.ecore.EReference reference)

createFeatureCallScope

protected IScope createFeatureCallScope(XAbstractFeatureCall call,
                                        org.eclipse.emf.ecore.EReference reference)
creates the feature scope for XAbstractFeatureCall, including the local variables in case it is a feature call without receiver (XFeatureCall).


createSimpleFeatureCallScope

public IScope createSimpleFeatureCallScope(org.eclipse.emf.ecore.EObject context,
                                           org.eclipse.emf.ecore.EReference reference,
                                           org.eclipse.emf.ecore.resource.Resource resource,
                                           boolean includeCurrentBlock,
                                           int idx)
This method serves as an entry point for the content assist scoping for simple feature calls.

Parameters:
context - the context e.g. a for loop expression, a block or a catch clause
reference - the reference who's value shall be scoped. Not necessarily a feature of the context.
includeCurrentBlock - false in the context of scoping but content assist will not have the actual value holder of the reference at hand so it passes its container to this method and expects the declared variables to be exposed in the scope.
idx - the index in an expression list of a block. Otherwise to be ignored.

createFeatureScopeForTypeRef

protected IScope createFeatureScopeForTypeRef(JvmTypeReference declaringType,
                                              org.eclipse.emf.ecore.EObject expression,
                                              XExpression implicitReceiver,
                                              IScope parent)
Parameters:
declaringType - the type that declares the feature
implicitReceiver - the instance that will receive the message.
expression - the expression that is closest to the to-be-created scope. Usually the feature call.

createLocalVariableScopeContext

protected LocalVariableScopeContext createLocalVariableScopeContext(org.eclipse.emf.ecore.EObject context,
                                                                    org.eclipse.emf.ecore.EReference reference,
                                                                    boolean includeCurrentBlock,
                                                                    int idx)

createFeatureCallScopeForReceiver

public IScope createFeatureCallScopeForReceiver(XExpression context,
                                                XExpression receiver,
                                                org.eclipse.emf.ecore.EReference reference)
This method serves as an entry point for the content assist scoping for features.

Parameters:
context - the context provides access to the resource set. If it is an assignment, it will be used to restrict scoping.
receiver - the receiver of the feature call.

getSyntacticalReceiver

protected XExpression getSyntacticalReceiver(XAbstractFeatureCall call)

createImplicitFeatureCallScope

protected IScope createImplicitFeatureCallScope(org.eclipse.emf.ecore.EObject call,
                                                org.eclipse.emf.ecore.resource.Resource resource,
                                                IScope parent,
                                                IScope localVariableScope)
override to add any other implicit feature calls.


addFeatureCallScopes

protected void addFeatureCallScopes(org.eclipse.emf.ecore.EObject featureCall,
                                    IScope localVariableScope,
                                    XbaseScopeProvider.IJvmFeatureScopeAcceptor featureScopeDescriptions)

addFeatureCallScopes

protected void addFeatureCallScopes(org.eclipse.emf.ecore.EObject expression,
                                    IScope localVariableScope,
                                    QualifiedName variableName,
                                    int priority,
                                    XbaseScopeProvider.IJvmFeatureScopeAcceptor featureScopeDescriptions)

unkownToObject

protected JvmTypeReference unkownToObject(JvmTypeReference receiverType,
                                          org.eclipse.emf.ecore.EObject context)

getContextType

protected JvmDeclaredType getContextType(org.eclipse.emf.ecore.EObject obj)

createLocalVarScope

protected IScope createLocalVarScope(IScope parentScope,
                                     LocalVariableScopeContext scopeContext)

createLocalVarScopeForJvmOperation

protected IScope createLocalVarScopeForJvmOperation(JvmOperation context,
                                                    IScope parentScope)

createLocalVarScopeForJvmConstructor

protected IScope createLocalVarScopeForJvmConstructor(JvmConstructor context,
                                                      IScope parentScope)

createLocalVarScopeForJvmDeclaredType

protected IScope createLocalVarScopeForJvmDeclaredType(JvmDeclaredType type,
                                                       IScope parentScope)

adaptsToJvmElement

protected boolean adaptsToJvmElement(org.eclipse.emf.ecore.EObject context)

createLocalVarScopeForSwitchExpression

protected IScope createLocalVarScopeForSwitchExpression(XSwitchExpression context,
                                                        IScope parentScope)

createLocalVarScopeForTypeGuardedCase

protected IScope createLocalVarScopeForTypeGuardedCase(XCasePart context,
                                                       IScope parentScope)
Allows to hook into the case guards to introduce new local variables with a specialized type. Implemented as no-op by default.

Parameters:
context - the case part.
parentScope - the parent scope.

createLocalVarScopeForCatchClause

protected IScope createLocalVarScopeForCatchClause(XCatchClause catchClause,
                                                   int indexOfContextExpressionInBlock,
                                                   IScope parentScope)
Allows to hook into the local variable definition for catch clauses.

Parameters:
catchClause - the catch clause.
indexOfContextExpressionInBlock - the index of the context expression in its surrounding block.
parentScope - the parent scope.

createLocalVarScopeForBlock

protected IScope createLocalVarScopeForBlock(XBlockExpression block,
                                             int indexOfContextExpressionInBlock,
                                             boolean referredFromClosure,
                                             IScope parentScope)

createLocalVarScopeForClosure

protected IScope createLocalVarScopeForClosure(XClosure closure,
                                               IScope parentScope)

sortDescriptionsFromLowestToHighest

protected void sortDescriptionsFromLowestToHighest(java.util.List<IJvmFeatureScopeProvider.FeatureScopeDescription> list)

addFeatureScopes

protected void addFeatureScopes(JvmTypeReference receiverType,
                                org.eclipse.emf.ecore.EObject expression,
                                JvmDeclaredType contextType,
                                XExpression implicitReceiver,
                                XExpression implicitArgument,
                                int priority,
                                XbaseScopeProvider.IJvmFeatureScopeAcceptor acceptor)

addStaticFeatureDescriptionProviders

protected void addStaticFeatureDescriptionProviders(org.eclipse.emf.ecore.resource.Resource resource,
                                                    JvmDeclaredType contextType,
                                                    IAcceptor<IJvmFeatureDescriptionProvider> acceptor)

getThisPriority

protected int getThisPriority()

getDefaultPriority

protected int getDefaultPriority()

getItPriority

protected int getItPriority()

getSugarPriorityOffset

protected int getSugarPriorityOffset()

getImplicitStaticExtensionPriorityOffset

protected int getImplicitStaticExtensionPriorityOffset()

getImplicitStaticFeaturePriority

protected int getImplicitStaticFeaturePriority()

addFeatureDescriptionProviders

protected void addFeatureDescriptionProviders(JvmDeclaredType contextType,
                                              IFeaturesForTypeProvider featureProvider,
                                              XExpression implicitReceiver,
                                              XExpression implicitArgument,
                                              int priority,
                                              boolean preferStatics,
                                              IAcceptor<IJvmFeatureDescriptionProvider> acceptor)

addFeatureDescriptionProviders

protected void addFeatureDescriptionProviders(org.eclipse.emf.ecore.resource.Resource resource,
                                              JvmDeclaredType contextType,
                                              XExpression implicitReceiver,
                                              XExpression implicitArgument,
                                              int priority,
                                              IAcceptor<IJvmFeatureDescriptionProvider> acceptor)

newImplicitStaticFeaturesProvider

protected StaticImplicitMethodsFeatureForTypeProvider newImplicitStaticFeaturesProvider()

addFeatureDescriptionProvidersForAssignment

protected void addFeatureDescriptionProvidersForAssignment(org.eclipse.emf.ecore.resource.Resource resource,
                                                           JvmDeclaredType contextType,
                                                           XExpression implicitReceiver,
                                                           XExpression implicitArgument,
                                                           int priority,
                                                           IAcceptor<IJvmFeatureDescriptionProvider> acceptor)
Parameters:
resource - the resource which may define implicitly available feature description providers.

addFeatureDescriptionProvidersForAssignment

protected void addFeatureDescriptionProvidersForAssignment(JvmDeclaredType contextType,
                                                           IFeaturesForTypeProvider featureProvider,
                                                           XExpression implicitReceiver,
                                                           XExpression implicitArgument,
                                                           int priority,
                                                           boolean preferStatics,
                                                           IAcceptor<IJvmFeatureDescriptionProvider> acceptor)

createLocalScopeForParameter

protected IScope createLocalScopeForParameter(JvmFormalParameter p,
                                              IScope parentScope)

createLocalVarDescription

protected IValidatedEObjectDescription createLocalVarDescription(JvmFormalParameter p)

createLocalVarDescription

protected IValidatedEObjectDescription createLocalVarDescription(XVariableDeclaration varDecl)

newDefaultFeatureDescriptionProvider

protected DefaultJvmFeatureDescriptionProvider newDefaultFeatureDescriptionProvider()

newDefaultConstructorDescriptionProvider

protected DefaultConstructorDescriptionProvider newDefaultConstructorDescriptionProvider()

newConstructorProvider

protected XConstructorProvider newConstructorProvider()

newSugarDescriptionProvider

protected XFeatureCallSugarDescriptionProvider newSugarDescriptionProvider()

getFeatureCallToJavaMapping

protected FeatureCallToJavaMapping getFeatureCallToJavaMapping()