Skip to content

Commit 21abc7f

Browse files
committed
cue/ast: remove Node.Comments and Node.AddComment
And deprecate the methods which get promoted into every Node implementation, which is what many users end up actually using. These Node methods were deprecated back in late 2019 in https://cue-review.googlesource.com/c/cue/+/3221, more than six years ago, so at this point they can be removed. The corresponding methods in the comments type, which are promoted into every Node implementation via embedding, were not deprecated yet. As such, removing them outright doesn't seem fair to users. Deprecate them now, and leave a note to remove in the future. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I321ae429e91e004f51a0824e98088cf1cc28e11e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1224693 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Roger Peppe <[email protected]> Unity-Result: CUE porcuepine <[email protected]>
1 parent 3d8f535 commit 21abc7f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

cue/ast/ast.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ type Node interface {
5555
// the node or nil if there is no such position.
5656
pos() *token.Pos
5757

58-
// Deprecated: use [Comments]
59-
Comments() []*CommentGroup
60-
61-
// Deprecated: use [AddComment]
62-
AddComment(*CommentGroup)
6358
commentInfo() *comments
6459
}
6560

@@ -147,13 +142,20 @@ type comments struct {
147142

148143
func (c *comments) commentInfo() *comments { return c }
149144

145+
// TODO: remove these deprecated comment methods in late 2026.
146+
// Note that we unfortunately cannot use `//go:fix inline`;
147+
// for example, from the comments.Comments promoted method below,
148+
// we cannot call the Comments API as it works on Node, the embedding type.
149+
150+
// Deprecated: use [Comments].
150151
func (c *comments) Comments() []*CommentGroup {
151152
if c.groups == nil {
152153
return []*CommentGroup{}
153154
}
154155
return *c.groups
155156
}
156157

158+
// Deprecated: use [AddComment].
157159
func (c *comments) AddComment(cg *CommentGroup) {
158160
if cg == nil {
159161
return
@@ -171,6 +173,7 @@ func (c *comments) AddComment(cg *CommentGroup) {
171173
}
172174
}
173175

176+
// Deprecated: use [SetComments].
174177
func (c *comments) SetComments(cgs []*CommentGroup) {
175178
if c.groups == nil {
176179
if cgs == nil {

0 commit comments

Comments
 (0)