aboutsummaryrefslogtreecommitdiff
path: root/src/text/template/parse/node.go
diff options
context:
space:
mode:
authorDaniel Theophanes <kardianos@gmail.com>2018-06-21 10:41:26 -0700
committerDaniel Theophanes <kardianos@gmail.com>2018-06-22 08:05:11 +0000
commitbedfa4e1c37bd08063865da628f242d27ca06ec4 (patch)
tree24be31b8f4cecfcfc67c5e245c1210c521643465 /src/text/template/parse/node.go
parent4991bc6257a9e9d922f7b6e29e393d764c4e4295 (diff)
downloadgo-bedfa4e1c37bd08063865da628f242d27ca06ec4.tar.xz
text/template/parse: undo breaking API changes
golang.org/cl/84480 altered the API for the parse package for clarity and consistency. However, the changes also broke the API for consumers of the package. This CL reverts the API to the previous spelling, adding only a single new exported symbol. Fixes #25968 Change-Id: Ieb81054b61eeac7df3bc3864ef446df43c26b80f Reviewed-on: https://go-review.googlesource.com/120355 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Rob Pike <r@golang.org> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/text/template/parse/node.go')
-rw-r--r--src/text/template/parse/node.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/text/template/parse/node.go b/src/text/template/parse/node.go
index 0bb96fc2e9..dca83dacce 100644
--- a/src/text/template/parse/node.go
+++ b/src/text/template/parse/node.go
@@ -144,15 +144,15 @@ func (t *TextNode) Copy() Node {
type PipeNode struct {
NodeType
Pos
- tr *Tree
- Line int // The line number in the input. Deprecated: Kept for compatibility.
- Decl bool // The variables are being declared, not assigned
- Vars []*AssignNode // Variables in lexical order.
- Cmds []*CommandNode // The commands in lexical order.
+ tr *Tree
+ Line int // The line number in the input. Deprecated: Kept for compatibility.
+ IsAssign bool // The variables are being assigned, not declared.
+ Decl []*VariableNode // Variables in lexical order.
+ Cmds []*CommandNode // The commands in lexical order.
}
-func (t *Tree) newPipeline(pos Pos, line int, vars []*AssignNode) *PipeNode {
- return &PipeNode{tr: t, NodeType: NodePipe, Pos: pos, Line: line, Vars: vars}
+func (t *Tree) newPipeline(pos Pos, line int, vars []*VariableNode) *PipeNode {
+ return &PipeNode{tr: t, NodeType: NodePipe, Pos: pos, Line: line, Decl: vars}
}
func (p *PipeNode) append(command *CommandNode) {
@@ -161,8 +161,8 @@ func (p *PipeNode) append(command *CommandNode) {
func (p *PipeNode) String() string {
s := ""
- if len(p.Vars) > 0 {
- for i, v := range p.Vars {
+ if len(p.Decl) > 0 {
+ for i, v := range p.Decl {
if i > 0 {
s += ", "
}
@@ -187,12 +187,12 @@ func (p *PipeNode) CopyPipe() *PipeNode {
if p == nil {
return p
}
- var vars []*AssignNode
- for _, d := range p.Vars {
- vars = append(vars, d.Copy().(*AssignNode))
+ var vars []*VariableNode
+ for _, d := range p.Decl {
+ vars = append(vars, d.Copy().(*VariableNode))
}
n := p.tr.newPipeline(p.Pos, p.Line, vars)
- n.Decl = p.Decl
+ n.IsAssign = p.IsAssign
for _, c := range p.Cmds {
n.append(c.Copy().(*CommandNode))
}
@@ -321,18 +321,18 @@ func (i *IdentifierNode) Copy() Node {
// AssignNode holds a list of variable names, possibly with chained field
// accesses. The dollar sign is part of the (first) name.
-type AssignNode struct {
+type VariableNode struct {
NodeType
Pos
tr *Tree
Ident []string // Variable name and fields in lexical order.
}
-func (t *Tree) newVariable(pos Pos, ident string) *AssignNode {
- return &AssignNode{tr: t, NodeType: NodeVariable, Pos: pos, Ident: strings.Split(ident, ".")}
+func (t *Tree) newVariable(pos Pos, ident string) *VariableNode {
+ return &VariableNode{tr: t, NodeType: NodeVariable, Pos: pos, Ident: strings.Split(ident, ".")}
}
-func (v *AssignNode) String() string {
+func (v *VariableNode) String() string {
s := ""
for i, id := range v.Ident {
if i > 0 {
@@ -343,12 +343,12 @@ func (v *AssignNode) String() string {
return s
}
-func (v *AssignNode) tree() *Tree {
+func (v *VariableNode) tree() *Tree {
return v.tr
}
-func (v *AssignNode) Copy() Node {
- return &AssignNode{tr: v.tr, NodeType: NodeVariable, Pos: v.Pos, Ident: append([]string{}, v.Ident...)}
+func (v *VariableNode) Copy() Node {
+ return &VariableNode{tr: v.tr, NodeType: NodeVariable, Pos: v.Pos, Ident: append([]string{}, v.Ident...)}
}
// DotNode holds the special identifier '.'.