Skip to content

Commit 6d70fb2

Browse files
committed
go/ast/astutil: add Apply, for rewriting Go ASTs
This change implements an AST walker, Apply, with the capability to perform various actions (including rewrites) during the AST walk, in pre- and post-iteration order. Ideally we would like to have this functionality in the std lib (go/ast), but as this change contains significant new API, it is better to first gain some experience with it in x/tools. Credits: This is joint work of Josh Bleecher Snyder, Roger Peppe, and myself (author of this CL). The code is based on proposal golang/go#17108 which I had started, together with an initial implementation. It was then reworked significantly by Josh in golang.org/cl/55790, further refined by suggestions from Roger (allocation reduction), and finally cleaned up a bit by me (AST simplifications). Fixes golang/go#17108. Change-Id: I56d56b7f2bc5be2acfeb927f76aea7f264bb7b94 Reviewed-on: https://go-review.googlesource.com/77811 Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 4de4a8d commit 6d70fb2

File tree

2 files changed

+725
-0
lines changed

2 files changed

+725
-0
lines changed

0 commit comments

Comments
 (0)