Package org.openrewrite.java
Class CoordinatesPrinter
java.lang.Object
org.openrewrite.java.CoordinatesPrinter
Utility 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringprintCoordinates(J.CompilationUnit cu, @Nullable Class<? extends J> cursorFilter) This will print out the compilation unit and embed the tree coordinates (at each Space position).static StringprintCoordinatesWithColor(J.CompilationUnit cu, Class<? extends J> cursorFilter) This will print out the compilation unit and embed the tree coordinates (at each Space position).
-
Field Details
-
ANSI_RESET
- See Also:
-
ANSI_FOREGROUND_WHITE
- See Also:
-
ANSI_FOREGROUND_GREY
- See Also:
-
ANSI_BACKGROUND_GREEN
- See Also:
-
-
Constructor Details
-
CoordinatesPrinter
public CoordinatesPrinter()
-
-
Method Details
-
printCoordinates
public static String printCoordinates(J.CompilationUnit cu, @Nullable @Nullable Class<? extends 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 String printCoordinatesWithColor(J.CompilationUnit cu, Class<? extends 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.
-