Skip to content

Commit b73ab0b

Browse files
committed
cue/ast: remove support for TemplateLabel
This really hasn't been parsed in ages, so if this hasn't resulted in problems yet, it is unlikely this will. Change-Id: I45c79ad2605479fec4dbdb1df901d458f8662dea Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9561 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Paul Jolly <[email protected]>
1 parent fd05bf4 commit b73ab0b

File tree

8 files changed

+1
-63
lines changed

8 files changed

+1
-63
lines changed

cue/ast/ast.go

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,6 @@ type Ident struct {
414414
expr
415415
}
416416

417-
// A TemplateLabel represents a field template declaration in a struct.
418-
//
419-
// Deprecated: use square bracket notation through ListLit.
420-
type TemplateLabel struct {
421-
Langle token.Pos
422-
Ident *Ident
423-
Rangle token.Pos
424-
425-
comments
426-
label
427-
}
428-
429417
// A BasicLit node represents a literal of basic type.
430418
type BasicLit struct {
431419
ValuePos token.Pos // literal position
@@ -770,8 +758,6 @@ func (x *BadExpr) Pos() token.Pos { return x.From }
770758
func (x *BadExpr) pos() *token.Pos { return &x.From }
771759
func (x *Ident) Pos() token.Pos { return x.NamePos }
772760
func (x *Ident) pos() *token.Pos { return &x.NamePos }
773-
func (x *TemplateLabel) Pos() token.Pos { return x.Langle }
774-
func (x *TemplateLabel) pos() *token.Pos { return &x.Langle }
775761
func (x *BasicLit) Pos() token.Pos { return x.ValuePos }
776762
func (x *BasicLit) pos() *token.Pos { return &x.ValuePos }
777763
func (x *Interpolation) Pos() token.Pos { return x.Elts[0].Pos() }
@@ -817,8 +803,7 @@ func (x *BadExpr) End() token.Pos { return x.To }
817803
func (x *Ident) End() token.Pos {
818804
return x.NamePos.Add(len(x.Name))
819805
}
820-
func (x *TemplateLabel) End() token.Pos { return x.Rangle }
821-
func (x *BasicLit) End() token.Pos { return x.ValuePos.Add(len(x.Value)) }
806+
func (x *BasicLit) End() token.Pos { return x.ValuePos.Add(len(x.Value)) }
822807

823808
func (x *Interpolation) End() token.Pos { return x.Elts[len(x.Elts)-1].Pos() }
824809
func (x *StructLit) End() token.Pos {

cue/ast/astutil/apply.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,6 @@ func applyCursor(v applyVisitor, c Cursor) {
350350
case *ast.BottomLit, *ast.BadExpr, *ast.Ident, *ast.BasicLit:
351351
// nothing to do
352352

353-
case *ast.TemplateLabel:
354-
apply(v, c, &n.Ident)
355-
356353
case *ast.Interpolation:
357354
applyExprList(v, c, &n, n.Elts)
358355

cue/ast/astutil/resolve.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,6 @@ func (s *scope) Before(n ast.Node) (w visitor) {
334334
}
335335
})
336336
walk(s, expr)
337-
338-
case *ast.TemplateLabel:
339-
s = newScope(s.file, s, x, nil)
340-
name, err := ast.ParseIdent(label.Ident)
341-
if err == nil {
342-
s.insert(name, x.Label, x) // Field used for entire lambda.
343-
}
344337
}
345338

346339
if n := x.Value; n != nil {

cue/ast/astutil/walk.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ func walk(v visitor, node ast.Node) {
9595
case *ast.BottomLit, *ast.BadExpr, *ast.Ident, *ast.BasicLit:
9696
// nothing to do
9797

98-
case *ast.TemplateLabel:
99-
walk(v, n.Ident)
100-
10198
case *ast.Interpolation:
10299
for _, e := range n.Elts {
103100
walk(v, e)

cue/ast/walk.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ func walk(v visitor, node Node) {
100100
case *BottomLit, *BadExpr, *Ident, *BasicLit:
101101
// nothing to do
102102

103-
case *TemplateLabel:
104-
walk(v, n.Ident)
105-
106103
case *Interpolation:
107104
for _, e := range n.Elts {
108105
walk(v, e)

cue/format/node.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,6 @@ func (f *formatter) label(l ast.Label, optional bool) {
485485
}
486486
f.print(n.ValuePos, str)
487487

488-
case *ast.TemplateLabel:
489-
f.print(n.Langle, token.LSS, indent)
490-
f.label(n.Ident, false)
491-
f.print(unindent, n.Rangle, token.GTR)
492-
493488
case *ast.ListLit:
494489
f.expr(n)
495490

internal/astinternal/debugstr.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,6 @@ func DebugStr(x interface{}) (out string) {
158158
case *ast.Ident:
159159
return v.Name
160160

161-
case *ast.TemplateLabel:
162-
out := "<"
163-
out += DebugStr(v.Ident)
164-
out += ">"
165-
return out
166-
167161
case *ast.SelectorExpr:
168162
return DebugStr(v.X) + "." + DebugStr(v.Sel)
169163

tools/fix/fix.go

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,6 @@ func File(f *ast.File, o ...Option) *ast.File {
150150
}
151151
}
152152

153-
// Rewrite TemplateLabel to ListLit.
154-
// Note: there is a chance that the name will clash with the
155-
// scope in which it is defined. We drop the alias if it is not
156-
// used to mitigate this issue.
157-
f = astutil.Apply(f, func(c astutil.Cursor) bool {
158-
n := c.Node()
159-
switch x := n.(type) {
160-
case *ast.TemplateLabel:
161-
var expr ast.Expr = ast.NewIdent("string")
162-
if _, ok := referred[x]; ok {
163-
expr = &ast.Alias{
164-
Ident: x.Ident,
165-
Expr: ast.NewIdent("_"),
166-
}
167-
}
168-
c.Replace(ast.NewList(expr))
169-
}
170-
return true
171-
}, nil).(*ast.File)
172-
173153
// Rewrite quoted identifier fields that are referenced.
174154
f = astutil.Apply(f, func(c astutil.Cursor) bool {
175155
n := c.Node()

0 commit comments

Comments
 (0)