Class NearestSectionFilter


public final class NearestSectionFilter extends Object
Add a filter for source sections that are nearest to the given source position, according to the guest language control flow.

The selection of the nearest source location happens based on the provided SourceSectionFilter and this nearest section filter to the Instrumenter create/attach methods. First location candidates are selected according to the SourceSectionFilter. Based on this selection a nearest location is found using this NearestSectionFilter. If new nearer locations are loaded then the listener/factory will be notified again. There is at most one nearest SourceSection at a time, therefore it is possible to detect updates by remembering and comparing the source section in the listener/factory.

Start building the nearest filter by calling newBuilder(int, int) and complete it by calling

A use-case is a debugger breakpoint, for instance, where the exact line or column is not always precise and the location needs to be updated when new code is loaded.

See Also:
  • Method Details

    • newBuilder

      public static NearestSectionFilter.Builder newBuilder(int line, int column)
      Creates a new NearestSectionFilter using a builder pattern. The filter will find source sections that are nearest to the given source line and column. To create the final filter finalize it using
      line - the line, greater than or equal to 1
      column - the column, or < 1 when column is unknown
      a new builder to create new NearestSectionFilter instances
    • toString

      public String toString()
      toString in class Object
      the filter attributes in a human readable form for debugging.