go/ast: document that (*ast.File).Comments is sorted by position

This is the way that go/parser produces it and in every AST manipulation
that we do, we preserve such property. Also printer expects it is such
order.

Change-Id: I6a6a696424a679a2cf1f9bb7eb41bdd47523efa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/704255
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
This commit is contained in:
Mateusz Poliwczak 2025-09-15 21:14:25 +02:00 committed by Alan Donovan
parent 594deca981
commit 02a888e820

View file

@ -1064,7 +1064,7 @@ type File struct {
Scope *Scope // package scope (this file only). Deprecated: see Object
Imports []*ImportSpec // imports in this file
Unresolved []*Ident // unresolved identifiers in this file. Deprecated: see Object
Comments []*CommentGroup // list of all comments in the source file
Comments []*CommentGroup // comments in the file, in lexical order
GoVersion string // minimum Go version required by //go:build or // +build directives
}