org.eclipse.xtext.scoping.impl
Class FilteringScope

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

public class FilteringScope
extends java.lang.Object
implements IScope

A FilteringScope filters out all IEObjectDescription for which the given predicate returns false.

Author:
Sven Efftinge - Initial contribution and API

Field Summary
 
Fields inherited from interface org.eclipse.xtext.scoping.IScope
NULLSCOPE
 
Constructor Summary
FilteringScope(IScope delegate, com.google.common.base.Predicate<IEObjectDescription> filter)
           
 
Method Summary
 java.lang.Iterable<IEObjectDescription> getAllElements()
          Obtain all elements from the scope.
 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  IEObjectDescription getFirst(java.lang.Iterable<IEObjectDescription> elements)
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FilteringScope

public FilteringScope(IScope delegate,
                      com.google.common.base.Predicate<IEObjectDescription> filter)
Method Detail

getAllElements

public java.lang.Iterable<IEObjectDescription> getAllElements()
Description copied from interface: IScope
Obtain all elements from the scope. Implementors a free to throw an UnsupportedOperationException if the scope cannot be enumerated.

Specified by:
getAllElements in interface IScope
Returns:
all elements of the scope. Never null.

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 interface IScope
Parameters:
object - the instance whose descriptions should be obtained. May not be null.
Returns:
all elements that match the instance. 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 interface IScope
Parameters:
name - the name of the to-be-found elements. May not be null.
Returns:
all elements that match the name. Never null.

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 interface IScope
Parameters:
object - the instance whose description should be obtained. May not be null.
Returns:
the first element that matches the instance. May be null.

getSingleElement

public IEObjectDescription getSingleElement(QualifiedName name)
Description copied from interface: IScope
Find the first description that matches the given name.

Specified by:
getSingleElement in interface IScope
Parameters:
name - the name of the to-be-found element. May not be null.
Returns:
the first element that matches the name. May be null.

getFirst

protected IEObjectDescription getFirst(java.lang.Iterable<IEObjectDescription> elements)