File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -967,6 +967,19 @@ func (*FuncDecl) declNode() {}
967
967
// appearance, including the comments that are pointed to from other nodes
968
968
// via Doc and Comment fields.
969
969
//
970
+ // For correct printing of source code containing comments (using packages
971
+ // go/format and go/printer), special care must be taken to update comments
972
+ // when a File's syntax tree is modified: For printing, comments are inter-
973
+ // spersed between tokens based on their position. If syntax tree nodes are
974
+ // removed or moved, relevant comments in their vicinity must also be removed
975
+ // (from the File.Comments list) or moved accordingly (by updating their
976
+ // positions). A CommentMap may be used to facilitate some of these operations.
977
+ //
978
+ // Whether and how a comment is associated with a node depends on the inter-
979
+ // pretation of the syntax tree by the manipulating program: Except for Doc
980
+ // and Comment comments directly associated with nodes, the remaining comments
981
+ // are "free-floating" (see also issues #18593, #20744).
982
+ //
970
983
type File struct {
971
984
Doc * CommentGroup // associated documentation; or nil
972
985
Package token.Pos // position of "package" keyword
You can’t perform that action at this time.
0 commit comments