Class LambdaScanner

All Implemented Interfaces:
TreeVisitor<Void,Void>

public class LambdaScanner extends CommonScanner
LambdaScanner stores information about the names and offsets of lambda expressions inside a method, and can also be used to scan the source tree and determine the index of a given instanceof check, where the i^th index corresponds to the i^th instanceof check, using 0-based indexing.
  • Method Details

    • indexOfLambdaExpressionTree

      public static int indexOfLambdaExpressionTree(TreePath origpath, Tree tree)
      Computes the index of the given lambda expression tree amongst all lambda expression trees inside its method, using 0-based indexing.
      Parameters:
      origpath - the path ending in the given lambda expression tree
      tree - the lambda expression tree to search for
      Returns:
      the index of the given lambda expression tree
    • visitLambdaExpression

      public Void visitLambdaExpression(LambdaExpressionTree node, Void p)
      Specified by:
      visitLambdaExpression in interface TreeVisitor<Void,Void>
      Overrides:
      visitLambdaExpression in class TreeScanner<Void,Void>
    • addLambdaExpressionToMethod

      public static void addLambdaExpressionToMethod(String methodName, Integer offset)
      Adds a lambda expression bytecode offset to the current list of offsets for methodName. This method must be called with monotonically increasing offsets for any one method.
      Parameters:
      methodName - the name of the method
      offset - the offset to add
    • getMethodLambdaExpressionIndex

      public static Integer getMethodLambdaExpressionIndex(String methodName, Integer offset)
      Returns the index of the given offset within the list of offsets for the given method, using 0-based indexing, or returns a negative number if the offset is not one of the offsets in the context.
      Parameters:
      methodName - the name of the method
      offset - the offset of the lambda expression
      Returns:
      the index of the given offset, or a negative number if the offset does not exist inside the context