Package org.openrewrite
Class CoordinatesPrinter
- java.lang.Object
-
- org.openrewrite.CoordinatesPrinter
-
public class CoordinatesPrinter extends java.lang.ObjectUtility to print a compilation unit with tree coordinates embedded in the output. This can be useful to discover the location within the source code that the coordinate represents.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringANSI_BACKGROUND_GREENstatic java.lang.StringANSI_FOREGROUND_GREYstatic java.lang.StringANSI_FOREGROUND_WHITEstatic java.lang.StringANSI_RESET
-
Constructor Summary
Constructors Constructor Description CoordinatesPrinter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringprintCoordinates(org.openrewrite.java.tree.J.CompilationUnit cu, @Nullable java.lang.Class<? extends org.openrewrite.java.tree.J> cursorFilter)This will print out the compilation unit and embed the tree coordinates (at each Space position).static java.lang.StringprintCoordinatesWithColor(org.openrewrite.java.tree.J.CompilationUnit cu, java.lang.Class<? extends org.openrewrite.java.tree.J> cursorFilter)This will print out the compilation unit and embed the tree coordinates (at each Space position).
-
-
-
Field Detail
-
ANSI_RESET
public static final java.lang.String ANSI_RESET
- See Also:
- Constant Field Values
-
ANSI_FOREGROUND_WHITE
public static final java.lang.String ANSI_FOREGROUND_WHITE
- See Also:
- Constant Field Values
-
ANSI_FOREGROUND_GREY
public static final java.lang.String ANSI_FOREGROUND_GREY
- See Also:
- Constant Field Values
-
ANSI_BACKGROUND_GREEN
public static final java.lang.String ANSI_BACKGROUND_GREEN
- See Also:
- Constant Field Values
-
-
Method Detail
-
printCoordinates
public static java.lang.String printCoordinates(org.openrewrite.java.tree.J.CompilationUnit cu, @Nullable @Nullable java.lang.Class<? extends org.openrewrite.java.tree.J> cursorFilter)This will print out the compilation unit and embed the tree coordinates (at each Space position). If a filter is supplied, the printer will only print coordinates for the tree elements of that given type.See
printCoordinatesWithColor(J.CompilationUnit, Class)for a variant of this method that will output the string with ASCII color codes.- Parameters:
cu- The compilation unit to printcursorFilter- An optional cursor filter.- Returns:
- The printed tree.
-
printCoordinatesWithColor
public static java.lang.String printCoordinatesWithColor(org.openrewrite.java.tree.J.CompilationUnit cu, java.lang.Class<? extends org.openrewrite.java.tree.J> cursorFilter)This will print out the compilation unit and embed the tree coordinates (at each Space position). If a filter is supplied, the printer will only print coordinates for the tree elements of that given type. This variant also uses ANSI Color codes to better highlight the differences between the coordinates and the actual source code.- Parameters:
cu- The compilation unit to printcursorFilter- An optional cursor filter.- Returns:
- The printed tree.
-
-