Package org.eclipse.xtext.scoping.impl
Class AbstractScope
- java.lang.Object
-
- org.eclipse.xtext.scoping.impl.AbstractScope
-
- All Implemented Interfaces:
IScope
- Direct Known Subclasses:
ImportScope
,MapBasedScope
,MultimapBasedScope
,SelectableBasedScope
,SimpleScope
public abstract class AbstractScope extends java.lang.Object implements IScope
Base class for custom scope implementations. It supports nesting of scopes into each other, appropriate shadowing semantics and case sensitive and insensitive lookup.
Implementors have to provide
getAllLocalElements()
. However, it is recommended to customizegetLocalElementsByEObject(EObject, URI)
andgetLocalElementsByName(QualifiedName)
as well.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
AbstractScope.ParentIterable
Lazy iterable with a reasonableAbstractScope.ParentIterable.toString()
implementation that supports shadowing of parents elements by means of filtering.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractScope(IScope parent, boolean ignoreCase)
Creates a new scope with a given parent.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<IEObjectDescription>
getAllElements()
Obtain all elements from the scope.protected abstract java.lang.Iterable<IEObjectDescription>
getAllLocalElements()
java.lang.Iterable<IEObjectDescription>
getElements(org.eclipse.emf.ecore.EObject object)
Find all descriptions that match the given instance.java.lang.Iterable<IEObjectDescription>
getElements(QualifiedName name)
Find all descriptions that match the given name.protected java.lang.Iterable<IEObjectDescription>
getLocalElementsByEObject(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.common.util.URI uri)
protected java.lang.Iterable<IEObjectDescription>
getLocalElementsByName(QualifiedName name)
IScope
getParent()
protected java.lang.Iterable<IEObjectDescription>
getParentElements(com.google.inject.Provider<java.lang.Iterable<IEObjectDescription>> provider)
IEObjectDescription
getSingleElement(org.eclipse.emf.ecore.EObject object)
Find the first description that matches the given instance.IEObjectDescription
getSingleElement(QualifiedName name)
Find the first description that matches the given name.protected IEObjectDescription
getSingleLocalElementByName(QualifiedName name)
boolean
isIgnoreCase()
protected boolean
isShadowed(IEObjectDescription input)
Returnstrue
if the given descriptioninput
from the parent scope is shadowed by local elements.java.lang.String
toString()
-
-
-
Method Detail
-
getParent
public IScope getParent()
-
isIgnoreCase
public boolean isIgnoreCase()
-
getSingleElement
public IEObjectDescription getSingleElement(QualifiedName name)
Description copied from interface:IScope
Find the first description that matches the given name.- Specified by:
getSingleElement
in interfaceIScope
- Parameters:
name
- the name of the to-be-found element. May not benull
.- Returns:
- the first element that matches the
name
. May benull
.
-
getSingleLocalElementByName
protected IEObjectDescription getSingleLocalElementByName(QualifiedName name)
-
getAllElements
public java.lang.Iterable<IEObjectDescription> getAllElements()
Description copied from interface:IScope
Obtain all elements from the scope. Implementors a free to throw anUnsupportedOperationException
if the scope cannot be enumerated.- Specified by:
getAllElements
in interfaceIScope
- Returns:
- all elements of the scope. Never
null
.
-
getElements
public java.lang.Iterable<IEObjectDescription> getElements(QualifiedName name)
Description copied from interface:IScope
Find all descriptions that match the given name.- Specified by:
getElements
in interfaceIScope
- Parameters:
name
- the name of the to-be-found elements. May not benull
.- Returns:
- all elements that match the
name
. Nevernull
.
-
getSingleElement
public IEObjectDescription getSingleElement(org.eclipse.emf.ecore.EObject object)
Description copied from interface:IScope
Find the first description that matches the given instance.- Specified by:
getSingleElement
in interfaceIScope
- Parameters:
object
- the instance whose description should be obtained. May not benull
.- Returns:
- the first element that matches the
instance
. May benull
.
-
getElements
public java.lang.Iterable<IEObjectDescription> getElements(org.eclipse.emf.ecore.EObject object)
Description copied from interface:IScope
Find all descriptions that match the given instance.- Specified by:
getElements
in interfaceIScope
- Parameters:
object
- the instance whose descriptions should be obtained. May not benull
.- Returns:
- all elements that match the
instance
. Nevernull
.
-
getAllLocalElements
protected abstract java.lang.Iterable<IEObjectDescription> getAllLocalElements()
-
getLocalElementsByName
protected java.lang.Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name)
-
getLocalElementsByEObject
protected java.lang.Iterable<IEObjectDescription> getLocalElementsByEObject(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.common.util.URI uri)
-
getParentElements
protected java.lang.Iterable<IEObjectDescription> getParentElements(com.google.inject.Provider<java.lang.Iterable<IEObjectDescription>> provider)
-
isShadowed
protected boolean isShadowed(IEObjectDescription input)
Returnstrue
if the given descriptioninput
from the parent scope is shadowed by local elements.- Returns:
true
if the given descriptioninput
from the parent scope is shadowed by local elements.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-