go/ast/inspector: clarify behavior regarding comment traversal
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>
diff --git a/go/ast/inspector/inspector.go b/go/ast/inspector/inspector.go
index 3fbfebf..1fc1de0 100644
--- a/go/ast/inspector/inspector.go
+++ b/go/ast/inspector/inspector.go
@@ -64,8 +64,9 @@
// 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
@@ -97,6 +98,7 @@
// 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.