Class AbstractDeclarativeScopeProvider

  extended by org.eclipse.xtext.scoping.impl.AbstractScopeProvider
      extended by org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider
All Implemented Interfaces:
Direct Known Subclasses:

public abstract class AbstractDeclarativeScopeProvider
extends AbstractScopeProvider

A scope provider that invokes methods reflectively. At first it looks for methods of the following signature: IScope scope_[EClassName]_[EReferenceName](MyType context, EReference ref)

That is if getScope(EObject, EReference) is called where EReference is e.g. Property.type and the ctx is an instance of Property, than the corresponding signature could be:

IScope scope_Property_type(Property prop, EReference ref)

If there is no method with the given name and a first parameter type which is compatible to the actual context object, the implementation invokes getPredicate(EObject, EReference) for the eContainer of the context EObject. For instance of a Property resides in an Entity the getScope(EObject, EReference) would be called for the containing Entity. This is done as long as there is an eContainer.
If after walking up the containment hierarchy no suitable scoping declaration has been found, the implementation falls back to invoke methods with the following signature (computed by getPredicate(EObject, EClass)):

IScope scope_[EClassName](MyType context, EReference ref)

For instance if a scope provider is asked to return all Entities which are visible from a certain Property, it looks for a method like this:

IScope scope_Entity(Property property, EReference ref)

Again the first parameter can also be any super type of the actual type and the implementation walks up the containment hierarchy again.

If still no method could be found null is returned

Sven Efftinge - Initial contribution and API, Sebastian Zarnekow

Field Summary
 org.apache.log4j.Logger logger
static java.lang.String NAMED_DELEGATE
static java.lang.String NAMED_ERROR_HANDLER
Constructor Summary
Method Summary
protected  IScope delegateGetScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
 IScopeProvider getDelegate()
 PolymorphicDispatcher.ErrorHandler<IScope> getErrorHandler()
protected<java.lang.reflect.Method> getPredicate(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EClass type)
protected<java.lang.reflect.Method> getPredicate(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
 IScope getScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
          Returns a scope for the given context.
protected  IScope polymorphicFindScopeForClassName(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
protected  IScope polymorphicFindScopeForReferenceName(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
 void setDelegate(IScopeProvider delegate)
 void setErrorHandler(PolymorphicDispatcher.ErrorHandler<IScope> errorHandler)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Detail


public static final java.lang.String NAMED_DELEGATE
See Also:
Constant Field Values


public static final java.lang.String NAMED_ERROR_HANDLER
See Also:
Constant Field Values


public final org.apache.log4j.Logger logger
Constructor Detail


public AbstractDeclarativeScopeProvider()
Method Detail


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


public void setDelegate(IScopeProvider delegate)


public IScopeProvider getDelegate()


protected<java.lang.reflect.Method> getPredicate(org.eclipse.emf.ecore.EObject context,
                                                                                  org.eclipse.emf.ecore.EClass type)


protected<java.lang.reflect.Method> getPredicate(org.eclipse.emf.ecore.EObject context,
                                                                                  org.eclipse.emf.ecore.EReference reference)


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.

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.
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.


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


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


public void setErrorHandler(PolymorphicDispatcher.ErrorHandler<IScope> errorHandler)


public PolymorphicDispatcher.ErrorHandler<IScope> getErrorHandler()