Skip to content

Commit

Permalink
Improve TreeToString docs
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=261976141
  • Loading branch information
cushon authored and netdpb committed Aug 13, 2019
1 parent fef940a commit 9e69135
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@
name = "TreeToString",
summary =
"Tree#toString shouldn't be used for Trees deriving from the code being compiled, as it"
+ " discards whitespace and comments. If this code is within an Error Prone check,"
+ " using VisitorState#getSourceForNode will give you the original source text. Note"
+ " that for synthetic trees (e.g.: implicit constructors), that source may be null.",
+ " discards whitespace and comments.",
severity = WARNING,
providesFix = NO_FIX)
public class TreeToString extends AbstractToString {
Expand Down
10 changes: 10 additions & 0 deletions docs/bugpattern/TreeToString.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
`Tree#toString` shouldn't be used for Trees deriving from the code being
compiled, as it discards whitespace and comments.

* If this code is within an Error Prone check, using
`VisitorState#getSourceForNode` will give you the original source text. Note
that for synthetic trees (e.g.: implicit constructors), that source may be
`null`.

* Prefer `Elements#getConstantExpression` to `TreeMaker.Literal` for escaping
constants in generated code.

0 comments on commit 9e69135

Please sign in to comment.