Class Query

java.lang.Object
spoon.reflect.visitor.Query

public abstract class Query extends Object
This class provides some useful methods to retrieve program elements and reference through a CtScanner-based deep search. It uses the Filter facility to select the right elements or references.
  • Method Details

    • getElements

      public static <E extends CtElement> List<E> getElements(Factory factory, Filter<E> filter)
      Within a given factory, returns all the program elements that match the filter.
      Type Parameters:
      E - the type of the sought program elements
      Parameters:
      factory - the factory that contains the elements where to recursive search on
      filter - the filter which defines the matching criteria
    • getElements

      public static <E extends CtElement> List<E> getElements(CtElement rootElement, Filter<E> filter)
      Returns all the program elements that match the filter starting from the given rootElement. Use CtQueryable.map(CtFunction) if you need more control on the scanning context of the Filter.
      Type Parameters:
      E - the type of the sought program elements
      Parameters:
      rootElement - the element to start the recursive search on
      filter - the filter which defines the matching criteria
    • getReferences

      public static <T extends CtReference> List<T> getReferences(CtElement rootElement, Filter<T> filter)
      Returns all the program element references that match the filter.
      Type Parameters:
      T - the type of the sought program element references
      Parameters:
      rootElement - the element to start the recursive search on
      filter - the filter which defines the matching criteria
    • getReferences

      public static <R extends CtReference> List<R> getReferences(Factory factory, Filter<R> filter)
      Within a given factory, returns all the program element references that match the filter.
      Type Parameters:
      R - the type of the sought program element references
      Parameters:
      factory - the factory that contains the references where to recursive search on
      filter - the filter which defines the matching criteria