Class 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 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
    • Field Detail

      • 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
    • Constructor Detail

      • AbstractDeclarativeScopeProvider

        public AbstractDeclarativeScopeProvider()
    • Method Detail

      • delegateGetScope

        protected IScope delegateGetScope​(org.eclipse.emf.ecore.EObject context,
                                          org.eclipse.emf.ecore.EReference reference)
      • 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 innermost 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​(org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler<IScope> errorHandler)
      • getErrorHandler

        public org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler<IScope> getErrorHandler()