Package 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
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 ifgetScope(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 invokesgetPredicate(EObject, EReference)
for the eContainer of the context EObject. For instance of a Property resides in an Entity thegetScope(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 bygetPredicate(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 foundnull
is returned
-
-
Field Summary
Fields Modifier and Type Field Description org.apache.log4j.Logger
logger
static java.lang.String
NAMED_DELEGATE
static java.lang.String
NAMED_ERROR_HANDLER
-
Constructor Summary
Constructors Constructor Description AbstractDeclarativeScopeProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected IScope
delegateGetScope(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
IScopeProvider
getDelegate()
Provides access to the delegate.org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler<IScope>
getErrorHandler()
protected com.google.common.base.Predicate<java.lang.reflect.Method>
getPredicate(org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EClass type)
protected com.google.common.base.Predicate<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(org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler<IScope> errorHandler)
-
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.scoping.impl.IDelegatingScopeProvider
setWrapper
-
-
-
-
Field Detail
-
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
-
-
Method Detail
-
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 interfaceIDelegatingScopeProvider
- 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 interfaceIScopeProvider
- 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 givenEReference
.reference
- the reference for which to get the scope.- Returns:
IScope
representing the innermostIScope
for the passed context and reference. Note for implementors: The result may not benull
. ReturnIScope.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(org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler<IScope> errorHandler)
-
getErrorHandler
public org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler<IScope> getErrorHandler()
-
-