Class LightScopes


  • public class LightScopes
    extends Object
    Set of useful classes resembling Scopes Xtext class, rewritten to improve the performance.
    • Constructor Summary

      Constructors 
      Constructor Description
      LightScopes()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Iterable<org.eclipse.xtext.resource.IEObjectDescription> concat​(Iterable<org.eclipse.xtext.resource.IEObjectDescription>... sourсeScopes)
      Gets the scope iterable which is able to concatenate given iterables and iterate them in the original order.
      static Iterable<org.eclipse.xtext.resource.IEObjectDescription> concat​(List<Iterable<org.eclipse.xtext.resource.IEObjectDescription>> sourсeScopes)
      Gets the scope iterable which is able to concatenate given iterables and iterate them in the original order.
      static <T> Iterable<T> filter​(Iterable<T> sourceIterable, com.google.common.base.Predicate<? super T> predicate)
      Gets the scope iterable which is able to filter given source using the specified filtering predicate.
      static <T> Iterator<T> filteringIterator​(Iterator<T> sourceIterator, com.google.common.base.Predicate<? super T> predicate)
      Creates filtering iterator.
      static <T> Iterable<org.eclipse.xtext.resource.IEObjectDescription> scopedElementsFor​(Iterable<T> elements, com.google.common.base.Function<T,​org.eclipse.xtext.naming.QualifiedName> nameComputation)
      Optimized version of Scopes.scopedElementsFor from Xtext standard implementations.
      static <F,​T>
      Iterable<T>
      transform​(Iterable<F> sourceIterable, com.google.common.base.Function<? super F,​? extends T> function)
      Gets an iterable that transforms given items, each item transformation produses exactly one result element.
      static <F,​T>
      Iterable<T>
      transformOneToMany​(Iterable<F> sourceIterable, com.google.common.base.Function<? super F,​Iterable<T>> function)
      Gets an iterable that transforms given items, each item transformation could produce many target objects.
    • Constructor Detail

      • LightScopes

        public LightScopes()
    • Method Detail

      • concat

        @SafeVarargs
        public static Iterable<org.eclipse.xtext.resource.IEObjectDescription> concat​(Iterable<org.eclipse.xtext.resource.IEObjectDescription>... sourсeScopes)
        Gets the scope iterable which is able to concatenate given iterables and iterate them in the original order.
        Parameters:
        sour\u0441eScopes - Source scope iterables.
        Returns:
        The concatenated iterable.
      • concat

        public static Iterable<org.eclipse.xtext.resource.IEObjectDescription> concat​(List<Iterable<org.eclipse.xtext.resource.IEObjectDescription>> sourсeScopes)
        Gets the scope iterable which is able to concatenate given iterables and iterate them in the original order.
        Parameters:
        sour\u0441eScopes - Source scope iterables.
        Returns:
        The concatenated iterable.
      • filter

        public static <T> Iterable<T> filter​(Iterable<T> sourceIterable,
                                             com.google.common.base.Predicate<? super T> predicate)
        Gets the scope iterable which is able to filter given source using the specified filtering predicate.
        Parameters:
        sourceIterable - Source scope iterable.
        predicate - Filtering predicate.
        Returns:
        The concatenated iterable.
      • filteringIterator

        public static <T> Iterator<T> filteringIterator​(Iterator<T> sourceIterator,
                                                        com.google.common.base.Predicate<? super T> predicate)
        Creates filtering iterator.
        Parameters:
        sourceIterable - The s++ource iterable.
        predicate - The filtering predicate/
        Returns:
        The iterator which filters through the given iterable.
      • scopedElementsFor

        public static <T> Iterable<org.eclipse.xtext.resource.IEObjectDescription> scopedElementsFor​(Iterable<T> elements,
                                                                                                     com.google.common.base.Function<T,​org.eclipse.xtext.naming.QualifiedName> nameComputation)
        Optimized version of Scopes.scopedElementsFor from Xtext standard implementations.
        Parameters:
        elements - The source elements to create scoped iterable for.
        nameComputation - The qualified name providing function.
        Returns:
        The iterable scope.
      • transform

        public static <F,​T> Iterable<T> transform​(Iterable<F> sourceIterable,
                                                        com.google.common.base.Function<? super F,​? extends T> function)
        Gets an iterable that transforms given items, each item transformation produses exactly one result element.
        Parameters:
        sourceIterable - The source iterable.
        function - The transforming function.
        Returns:
        The iterable with transformed elements.
      • transformOneToMany

        public static <F,​T> Iterable<T> transformOneToMany​(Iterable<F> sourceIterable,
                                                                 com.google.common.base.Function<? super F,​Iterable<T>> function)
        Gets an iterable that transforms given items, each item transformation could produce many target objects.
        Parameters:
        sourceIterable - The source iterable.
        function - The transforming function.
        Returns:
        The iterable with transformed elements.