Interface JavaSourceVisitor<R>

    • Method Detail

      • enclosingBlock

        default J.Block<?> enclosingBlock()
      • enclosingMethod

        @Nullable
        default J.MethodDecl enclosingMethod()
      • enclosingClass

        default J.ClassDecl enclosingClass()
      • isInSameNameScope

        default boolean isInSameNameScope​(org.openrewrite.Cursor base,
                                          org.openrewrite.Cursor child)
        Check if a child AST element is in the same lexical scope as that of the AST element associated with the base cursor. (i.e.: Are the variables and declarations visible in the base scope also visible to the child AST element?) The base lexical scope is first established by walking up the path of the base cursor to find its first enclosing element. The child path is traversed by walking up the child path elements until either the base scope has been found, a "terminating" element is encountered, or there are no more elements in the path.

        A terminating element is one of the following:

      • A static class declaration
      • An enumeration declaration
      • An interface declaration
      • An annotation declaration
Parameters:
base - A pointer within the AST that is used to establish the "base lexical scope".
child - A pointer within the AST that will be traversed (up the tree) looking for an intersection with the base lexical scope.
Returns:
true if the child is in within the lexical scope of the base