Class CtScannerFunction

java.lang.Object
spoon.reflect.visitor.filter.CtScannerFunction
All Implemented Interfaces:
CtConsumableFunction<CtElement>, CtQueryAware

public class CtScannerFunction extends Object implements CtConsumableFunction<CtElement>, CtQueryAware
Returns all children of an element. More than this, it is a parameterizable class to be subclassed which provides all the power of CtScanner in the context of queries.
In particular, one can a register a CtScannerListener, it is called-back when entering/exiting each scanned AST node and it drives the scanning process (see ScanningMode).
  • Constructor Details

    • CtScannerFunction

      public CtScannerFunction()
  • Method Details

    • includingSelf

      public CtScannerFunction includingSelf(boolean includingSelf)
      Parameters:
      includingSelf - if true then input element is sent to output too. By default it is false.
    • setListener

      public CtScannerFunction setListener(CtScannerListener listener)
      Parameters:
      listener - the implementation of CtScannerListener, which will listen for enter/exit of nodes during scanning of AST
      Returns:
      this to support fluent API
    • apply

      public void apply(CtElement input, CtConsumer<Object> outputConsumer)
      Description copied from interface: CtConsumableFunction
      Evaluates the function on the given input.
      Specified by:
      apply in interface CtConsumableFunction<CtElement>
      Parameters:
      input - the input of the function
      outputConsumer - the consumer which accepts the results of this function.
    • setQuery

      public void setQuery(CtQuery query)
      Description copied from interface: CtQueryAware
      This method is called when the filter/function is added as a step to a CtQuery by the query engine (CtQueryImpl).
      Specified by:
      setQuery in interface CtQueryAware
      Parameters:
      query - an instance registering this function/filter.