[refactoring] update ast structure of "array" and "list" nodes
This commit is contained in:
@@ -113,8 +113,6 @@ type NodeVisitor interface {
|
||||
ExprRequire(n *ExprRequire)
|
||||
ExprRequireOnce(n *ExprRequireOnce)
|
||||
ExprShellExec(n *ExprShellExec)
|
||||
ExprShortArray(n *ExprShortArray)
|
||||
ExprShortList(n *ExprShortList)
|
||||
ExprStaticCall(n *ExprStaticCall)
|
||||
ExprStaticPropertyFetch(n *ExprStaticPropertyFetch)
|
||||
ExprTernary(n *ExprTernary)
|
||||
|
||||
@@ -939,7 +939,11 @@ func (n *StmtWhile) Accept(v NodeVisitor) {
|
||||
// ExprArray node
|
||||
type ExprArray struct {
|
||||
Node
|
||||
Items []Vertex
|
||||
ArrayTkn *token.Token
|
||||
OpenBracketTkn *token.Token
|
||||
Items []Vertex
|
||||
SeparatorTkns []*token.Token
|
||||
CloseBracketTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *ExprArray) Accept(v NodeVisitor) {
|
||||
@@ -1166,7 +1170,11 @@ func (n *ExprIsset) Accept(v NodeVisitor) {
|
||||
// ExprList node
|
||||
type ExprList struct {
|
||||
Node
|
||||
Items []Vertex
|
||||
ListTkn *token.Token
|
||||
OpenBracketTkn *token.Token
|
||||
Items []Vertex
|
||||
SeparatorTkns []*token.Token
|
||||
CloseBracketTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *ExprList) Accept(v NodeVisitor) {
|
||||
@@ -1297,26 +1305,6 @@ func (n *ExprShellExec) Accept(v NodeVisitor) {
|
||||
v.ExprShellExec(n)
|
||||
}
|
||||
|
||||
// ExprShortArray node
|
||||
type ExprShortArray struct {
|
||||
Node
|
||||
Items []Vertex
|
||||
}
|
||||
|
||||
func (n *ExprShortArray) Accept(v NodeVisitor) {
|
||||
v.ExprShortArray(n)
|
||||
}
|
||||
|
||||
// ExprShortList node
|
||||
type ExprShortList struct {
|
||||
Node
|
||||
Items []Vertex
|
||||
}
|
||||
|
||||
func (n *ExprShortList) Accept(v NodeVisitor) {
|
||||
v.ExprShortList(n)
|
||||
}
|
||||
|
||||
// ExprStaticCall node
|
||||
type ExprStaticCall struct {
|
||||
Node
|
||||
|
||||
@@ -1543,34 +1543,6 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
||||
}
|
||||
t.visitor.Leave("Parts", false)
|
||||
}
|
||||
case *ast.ExprShortArray:
|
||||
if nn == nil {
|
||||
return
|
||||
}
|
||||
if !t.visitor.EnterNode(nn) {
|
||||
return
|
||||
}
|
||||
if nn.Items != nil {
|
||||
t.visitor.Enter("Items", false)
|
||||
for _, c := range nn.Items {
|
||||
t.Traverse(c)
|
||||
}
|
||||
t.visitor.Leave("Items", false)
|
||||
}
|
||||
case *ast.ExprShortList:
|
||||
if nn == nil {
|
||||
return
|
||||
}
|
||||
if !t.visitor.EnterNode(nn) {
|
||||
return
|
||||
}
|
||||
if nn.Items != nil {
|
||||
t.visitor.Enter("Items", false)
|
||||
for _, c := range nn.Items {
|
||||
t.Traverse(c)
|
||||
}
|
||||
t.visitor.Leave("Items", false)
|
||||
}
|
||||
case *ast.ExprStaticCall:
|
||||
if nn == nil {
|
||||
return
|
||||
|
||||
@@ -812,18 +812,6 @@ func (v *Dump) ExprShellExec(n *ast.ExprShellExec) {
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) ExprShortArray(n *ast.ExprShortArray) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.ExprShortArray{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) ExprShortList(n *ast.ExprShortList) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.ExprShortList{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) ExprStaticCall(n *ast.ExprStaticCall) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.ExprStaticCall{\n")
|
||||
|
||||
@@ -394,14 +394,6 @@ func (v *Null) ExprShellExec(_ *ast.ExprShellExec) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) ExprShortArray(_ *ast.ExprShortArray) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) ExprShortList(_ *ast.ExprShortList) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) ExprStaticCall(_ *ast.ExprStaticCall) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -274,10 +274,6 @@ func (p *PrettyPrinter) printNode(n ast.Vertex) {
|
||||
p.printExprRequireOnce(n)
|
||||
case *ast.ExprShellExec:
|
||||
p.printExprShellExec(n)
|
||||
case *ast.ExprShortArray:
|
||||
p.printExprShortArray(n)
|
||||
case *ast.ExprShortList:
|
||||
p.printExprShortList(n)
|
||||
case *ast.ExprStaticCall:
|
||||
p.printExprStaticCall(n)
|
||||
case *ast.ExprStaticPropertyFetch:
|
||||
@@ -1240,22 +1236,6 @@ func (p *PrettyPrinter) printExprShellExec(n ast.Vertex) {
|
||||
io.WriteString(p.w, "`")
|
||||
}
|
||||
|
||||
func (p *PrettyPrinter) printExprShortArray(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprShortArray)
|
||||
|
||||
io.WriteString(p.w, "[")
|
||||
p.joinPrint(", ", nn.Items)
|
||||
io.WriteString(p.w, "]")
|
||||
}
|
||||
|
||||
func (p *PrettyPrinter) printExprShortList(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprShortList)
|
||||
|
||||
io.WriteString(p.w, "[")
|
||||
p.joinPrint(", ", nn.Items)
|
||||
io.WriteString(p.w, "]")
|
||||
}
|
||||
|
||||
func (p *PrettyPrinter) printExprStaticCall(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprStaticCall)
|
||||
|
||||
|
||||
@@ -363,10 +363,6 @@ func (p *Printer) printNode(n ast.Vertex) {
|
||||
p.printExprRequireOnce(n)
|
||||
case *ast.ExprShellExec:
|
||||
p.printExprShellExec(n)
|
||||
case *ast.ExprShortArray:
|
||||
p.printExprShortArray(n)
|
||||
case *ast.ExprShortList:
|
||||
p.printExprShortList(n)
|
||||
case *ast.ExprStaticCall:
|
||||
p.printExprStaticCall(n)
|
||||
case *ast.ExprStaticPropertyFetch:
|
||||
@@ -1837,30 +1833,6 @@ func (p *Printer) printExprShellExec(n ast.Vertex) {
|
||||
p.printFreeFloating(nn, token.End)
|
||||
}
|
||||
|
||||
func (p *Printer) printExprShortArray(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprShortArray)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
p.write([]byte("["))
|
||||
p.joinPrint(",", nn.Items)
|
||||
p.printFreeFloating(nn, token.ArrayPairList)
|
||||
p.write([]byte("]"))
|
||||
|
||||
p.printFreeFloating(nn, token.End)
|
||||
}
|
||||
|
||||
func (p *Printer) printExprShortList(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprShortList)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
p.write([]byte("["))
|
||||
p.joinPrint(",", nn.Items)
|
||||
p.printFreeFloating(nn, token.ArrayPairList)
|
||||
p.write([]byte("]"))
|
||||
|
||||
p.printFreeFloating(nn, token.End)
|
||||
}
|
||||
|
||||
func (p *Printer) printExprStaticCall(n ast.Vertex) {
|
||||
nn := n.(*ast.ExprStaticCall)
|
||||
p.printFreeFloating(nn, token.Start)
|
||||
|
||||
Reference in New Issue
Block a user