org.eclipse.xtext.scoping.impl
Class ImportedNamespaceAwareLocalScopeProvider

java.lang.Object
  extended by org.eclipse.xtext.scoping.impl.AbstractScopeProvider
      extended by org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider
          extended by org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider
All Implemented Interfaces:
IScopeProvider
Direct Known Subclasses:
XbaseImportedNamespaceScopeProvider

public class ImportedNamespaceAwareLocalScopeProvider
extends AbstractGlobalScopeDelegatingScopeProvider

A local scope provider that understands namespace imports. It scans model elements for an EAttribute importedNamespace. The value of this attribute is interpreted as qualified name to be imported. Wildcards are supported (see getWildCard() for details). Imports are valid for all elements in the same container and their children. See http://www.eclipse.org/Xtext/documentation/latest/xtext.html#scoping for details.

Author:
Sven Efftinge - Initial contribution and API, Jan Koehnlein, Sebastian Zarnekow

Constructor Summary
ImportedNamespaceAwareLocalScopeProvider()
           
ImportedNamespaceAwareLocalScopeProvider(IGlobalScopeProvider globalScopeProvider, IQualifiedNameProvider qualifiedNameProvider, IQualifiedNameConverter qualifiedNameConverter, ICaseInsensitivityHelper caseInsensitivityHelper)
           
 
Method Summary
protected  ImportNormalizer createImportedNamespaceResolver(java.lang.String namespace, boolean ignoreCase)
          Create a new ImportNormalizer for the given namespace.
protected  ImportScope createImportScope(IScope parent, java.util.List<ImportNormalizer> namespaceResolvers, ISelectable importFrom, org.eclipse.emf.ecore.EClass type, boolean ignoreCase)
           
protected  ISelectable getAllDescriptions(org.eclipse.emf.ecore.resource.Resource resource)
           
protected  java.util.List<ImportNormalizer> getImplicitImports(boolean ignoreCase)
           
protected  java.util.List<ImportNormalizer> getImportedNamespaceResolvers(org.eclipse.emf.ecore.EObject context, boolean ignoreCase)
           
protected  java.lang.Object getKey(org.eclipse.emf.common.notify.Notifier context, org.eclipse.emf.ecore.EReference reference)
           
protected  IScope getLocalElementsScope(IScope parent, org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
           
protected  QualifiedName getQualifiedNameOfLocalElement(org.eclipse.emf.ecore.EObject context)
           
 IQualifiedNameProvider getQualifiedNameProvider()
           
protected  IScope getResourceScope(IScope parent, org.eclipse.emf.ecore.EObject context, org.eclipse.emf.ecore.EReference reference)
           
protected  IScope getResourceScope(org.eclipse.emf.ecore.resource.Resource res, 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.
 java.lang.String getWildCard()
           
protected  ISelectable internalGetAllDescriptions(org.eclipse.emf.ecore.resource.Resource resource)
           
protected  java.util.List<ImportNormalizer> internalGetImportedNamespaceResolvers(org.eclipse.emf.ecore.EObject context, boolean ignoreCase)
           
protected  boolean isRelativeImport()
           
 
Methods inherited from class org.eclipse.xtext.scoping.impl.AbstractGlobalScopeDelegatingScopeProvider
getGlobalScope, getGlobalScope, isIgnoreCase, setWrapper, wrap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImportedNamespaceAwareLocalScopeProvider

@Inject
public ImportedNamespaceAwareLocalScopeProvider()

ImportedNamespaceAwareLocalScopeProvider

public ImportedNamespaceAwareLocalScopeProvider(IGlobalScopeProvider globalScopeProvider,
                                                IQualifiedNameProvider qualifiedNameProvider,
                                                IQualifiedNameConverter qualifiedNameConverter,
                                                ICaseInsensitivityHelper caseInsensitivityHelper)
Method Detail

getQualifiedNameProvider

public IQualifiedNameProvider getQualifiedNameProvider()

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.

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.

getResourceScope

protected IScope getResourceScope(org.eclipse.emf.ecore.resource.Resource res,
                                  org.eclipse.emf.ecore.EReference reference)

getImplicitImports

protected java.util.List<ImportNormalizer> getImplicitImports(boolean ignoreCase)

getResourceScope

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

getKey

protected java.lang.Object getKey(org.eclipse.emf.common.notify.Notifier context,
                                  org.eclipse.emf.ecore.EReference reference)

getImportedNamespaceResolvers

protected java.util.List<ImportNormalizer> getImportedNamespaceResolvers(org.eclipse.emf.ecore.EObject context,
                                                                         boolean ignoreCase)

internalGetImportedNamespaceResolvers

protected java.util.List<ImportNormalizer> internalGetImportedNamespaceResolvers(org.eclipse.emf.ecore.EObject context,
                                                                                 boolean ignoreCase)

createImportedNamespaceResolver

protected ImportNormalizer createImportedNamespaceResolver(java.lang.String namespace,
                                                           boolean ignoreCase)
Create a new ImportNormalizer for the given namespace.

Parameters:
namespace - the namespace.
ignoreCase - true if the resolver should be case insensitive.
Returns:
a new ImportNormalizer or null if the namespace cannot be converted to a valid qualified name.

getLocalElementsScope

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

createImportScope

protected ImportScope createImportScope(IScope parent,
                                        java.util.List<ImportNormalizer> namespaceResolvers,
                                        ISelectable importFrom,
                                        org.eclipse.emf.ecore.EClass type,
                                        boolean ignoreCase)

getQualifiedNameOfLocalElement

protected QualifiedName getQualifiedNameOfLocalElement(org.eclipse.emf.ecore.EObject context)

isRelativeImport

protected boolean isRelativeImport()

getAllDescriptions

protected ISelectable getAllDescriptions(org.eclipse.emf.ecore.resource.Resource resource)

internalGetAllDescriptions

protected ISelectable internalGetAllDescriptions(org.eclipse.emf.ecore.resource.Resource resource)

getWildCard

public java.lang.String getWildCard()