Class SourceCode
java.lang.Object
tech.picnic.errorprone.bugpatterns.util.SourceCode
A collection of Error Prone utility methods for dealing with the source code representation of
AST nodes.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.errorprone.fixes.SuggestedFixdeleteWithTrailingWhitespace(Tree tree, com.google.errorprone.VisitorState state) Creates aSuggestedFixfor the deletion of the givenTree, including any whitespace that follows it.static StringtreeToString(Tree tree, com.google.errorprone.VisitorState state) Returns a string representation of the givenTree, preferring the original source code (if available) over its prettified representation.
-
Method Details
-
treeToString
Returns a string representation of the givenTree, preferring the original source code (if available) over its prettified representation.- Parameters:
tree- The AST node of interest.state- AVisitorStatedescribing the context in which the givenTreeis found.- Returns:
- A non-
nullstring.
-
deleteWithTrailingWhitespace
public static com.google.errorprone.fixes.SuggestedFix deleteWithTrailingWhitespace(Tree tree, com.google.errorprone.VisitorState state) Creates aSuggestedFixfor the deletion of the givenTree, including any whitespace that follows it.Removing trailing whitespace may prevent the introduction of an empty line at the start of a code block; such empty lines are not removed when formatting the code using Google Java Format.
- Parameters:
tree- The AST node of interest.state- AVisitorStatedescribing the context in which the givenTreeis found.- Returns:
- A non-
nullSuggestedFixsimilar to one produced bySuggestedFix.delete(Tree).
-