org.eclipse.xtext.scoping.impl
Class AbstractDeclarativeScopeProvider
java.lang.Object
org.eclipse.xtext.scoping.impl.AbstractScopeProvider
org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider
- All Implemented Interfaces:
- IDelegatingScopeProvider, IScopeProvider
- Direct Known Subclasses:
- CodetemplatesScopeProvider
public abstract class AbstractDeclarativeScopeProvider
- extends AbstractScopeProvider
- implements IDelegatingScopeProvider
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
- Author:
- Sven Efftinge - Initial contribution and API, Sebastian Zarnekow
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NAMED_DELEGATE
public static final java.lang.String NAMED_DELEGATE
- See Also:
- Constant Field Values
NAMED_ERROR_HANDLER
public static final java.lang.String NAMED_ERROR_HANDLER
- See Also:
- Constant Field Values
logger
public final org.apache.log4j.Logger logger
AbstractDeclarativeScopeProvider
public AbstractDeclarativeScopeProvider()
delegateGetScope
protected IScope delegateGetScope(org.eclipse.emf.ecore.EObject context,
org.eclipse.emf.ecore.EReference reference)
setDelegate
public void setDelegate(IScopeProvider delegate)
getDelegate
public IScopeProvider getDelegate()
- Description copied from interface:
IDelegatingScopeProvider
- Provides access to the delegate.
- Specified by:
getDelegate
in interface IDelegatingScopeProvider
- Returns:
- the delegate. May not be
null
.
getPredicate
protected com.google.common.base.Predicate<java.lang.reflect.Method> getPredicate(org.eclipse.emf.ecore.EObject context,
org.eclipse.emf.ecore.EClass type)
getPredicate
protected com.google.common.base.Predicate<java.lang.reflect.Method> getPredicate(org.eclipse.emf.ecore.EObject context,
org.eclipse.emf.ecore.EReference reference)
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
- 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.
polymorphicFindScopeForClassName
protected IScope polymorphicFindScopeForClassName(org.eclipse.emf.ecore.EObject context,
org.eclipse.emf.ecore.EReference reference)
polymorphicFindScopeForReferenceName
protected IScope polymorphicFindScopeForReferenceName(org.eclipse.emf.ecore.EObject context,
org.eclipse.emf.ecore.EReference reference)
setErrorHandler
public void setErrorHandler(PolymorphicDispatcher.ErrorHandler<IScope> errorHandler)
getErrorHandler
public PolymorphicDispatcher.ErrorHandler<IScope> getErrorHandler()