[refactoring] update ast structure of "array" and "list" nodes

This commit is contained in:
Vadym Slizov
2020-11-30 23:42:56 +02:00
parent 43f6fab862
commit 47b974a3a4
11 changed files with 1547 additions and 1475 deletions

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -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
}