Skip to content

Commit

Permalink
go/ast/inspector: clarify behavior regarding comment traversal
Browse files Browse the repository at this point in the history
The inspector does not walk all ast.Comments nodes but only those
attached to declarations (i.e. doc comments). Clarify this in the
the documentation of the traversal functions.

Change-Id: I5cc9c5914fc8a7f0687ae632ba884d1317a4a7cb
Reviewed-on: https://go-review.googlesource.com/c/tools/+/505495
Auto-Submit: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
  • Loading branch information
lfolger authored and gopherbot committed Jun 26, 2023
1 parent fa10359 commit 8f9bce4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion go/ast/inspector/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ type event struct {
// depth-first order. It calls f(n) for each node n before it visits
// n's children.
//
// The complete traversal sequence is determined by ast.Inspect.
// The types argument, if non-empty, enables type-based filtering of
// events. The function f if is called only for nodes whose type
// events. The function f is called only for nodes whose type
// matches an element of the types slice.
func (in *Inspector) Preorder(types []ast.Node, f func(ast.Node)) {
// Because it avoids postorder calls to f, and the pruning
Expand Down Expand Up @@ -97,6 +98,7 @@ func (in *Inspector) Preorder(types []ast.Node, f func(ast.Node)) {
// of the non-nil children of the node, followed by a call of
// f(n, false).
//
// The complete traversal sequence is determined by ast.Inspect.
// The types argument, if non-empty, enables type-based filtering of
// events. The function f if is called only for nodes whose type
// matches an element of the types slice.
Expand Down

0 comments on commit 8f9bce4

Please sign in to comment.