1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:38:33 -06:00

go/analysis/doc: fix stuff that was left out of the previous commit

I forgot to add the section on supplying AST nodes directly.

Change-Id: Ibf9930693cf32542832b21a95621224c8d68e0f2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/192682
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
Michael Matloob 2019-08-30 18:10:08 -04:00
parent 8fa7b020d0
commit 573d992605

View File

@ -120,4 +120,17 @@ This is primarily an issue with the current design of the Go AST and
it's possible that a new future version of the AST might make this a more
viable option.
### Supplying AST nodes directly
### Supplying AST nodes directly
Another possibility would be for SuggestedFixes to supply the replacement
ASTs directly. There is one primary limitation to this: that because
comments to ASTs specify their location using token.Pos values, it's very
difficult to place any comments in the right place.
In general, it's also more difficult to generate the AST structures for
some code than to generate the text for that code. So we prefer to allow
the flexibility to do the latter.
Because users can call ```format.Node``` to produce the text for any
AST node, users will always be able to produce a SuggestedFix from AST
nodes. In future, we may choose to add a convenience method that does this for users.