org.eclipse.xtext.scoping.impl
Class MapBasedScope

java.lang.Object
  extended by org.eclipse.xtext.scoping.impl.AbstractScope
      extended by org.eclipse.xtext.scoping.impl.MapBasedScope
All Implemented Interfaces:
IScope

public class MapBasedScope
extends AbstractScope

A scope implemented using a Map used for efficient lookup of ordinary named EObjectDescriptions. This implementation assumes, that the keys of the Map correspond to the keys of the contained EObjectDescription. Additionally it assumes, that those keys are equal to description.getName().toLowerCase(). When looking up elements using ISelector.SelectByName this implementation looks up the the elements from the map, hence are much more efficient for many IEObjectDescriptions.

Author:
Sven Efftinge - Initial contribution and API

Nested Class Summary
 
Nested classes/interfaces inherited from class org.eclipse.xtext.scoping.impl.AbstractScope
AbstractScope.ParentIterable
 
Field Summary
 
Fields inherited from interface org.eclipse.xtext.scoping.IScope
NULLSCOPE
 
Constructor Summary
protected MapBasedScope(IScope parent, java.util.Map<QualifiedName,IEObjectDescription> elements, boolean ignoreCase)
           
 
Method Summary
static IScope createScope(IScope parent, java.lang.Iterable<IEObjectDescription> descriptions)
           
static IScope createScope(IScope parent, java.lang.Iterable<IEObjectDescription> descriptions, boolean ignoreCase)
           
protected  java.lang.Iterable<IEObjectDescription> getAllLocalElements()
           
protected  java.lang.Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name)
           
protected  boolean isShadowed(IEObjectDescription fromParent)
           
 
Methods inherited from class org.eclipse.xtext.scoping.impl.AbstractScope
getAllElements, getElements, getElements, getLocalElementsByEObject, getParent, getParentElements, getSingleElement, getSingleElement, getSingleLocalElementByName, isIgnoreCase, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapBasedScope

protected MapBasedScope(IScope parent,
                        java.util.Map<QualifiedName,IEObjectDescription> elements,
                        boolean ignoreCase)
Method Detail

createScope

public static IScope createScope(IScope parent,
                                 java.lang.Iterable<IEObjectDescription> descriptions,
                                 boolean ignoreCase)

createScope

public static IScope createScope(IScope parent,
                                 java.lang.Iterable<IEObjectDescription> descriptions)

getAllLocalElements

protected java.lang.Iterable<IEObjectDescription> getAllLocalElements()
Specified by:
getAllLocalElements in class AbstractScope

getLocalElementsByName

protected java.lang.Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name)
Overrides:
getLocalElementsByName in class AbstractScope

isShadowed

protected boolean isShadowed(IEObjectDescription fromParent)
Overrides:
isShadowed in class AbstractScope