[refactoring] update ast structure of "Declare" and "ConstList" nodes
This commit is contained in:
@@ -189,7 +189,6 @@ type NodeVisitor interface {
|
||||
NameRelative(n *NameRelative)
|
||||
NameNamePart(n *NameNamePart)
|
||||
|
||||
ParserAs(n *ParserAs)
|
||||
ParserNsSeparator(n *ParserNsSeparator)
|
||||
ParserBrackets(n *ParserBrackets)
|
||||
ParserSeparatedList(n *ParserSeparatedList)
|
||||
}
|
||||
|
||||
@@ -278,9 +278,10 @@ func (n *StmtClassMethod) Accept(v NodeVisitor) {
|
||||
// StmtConstList node
|
||||
type StmtConstList struct {
|
||||
Node
|
||||
ConstTkn *token.Token
|
||||
Consts []Vertex
|
||||
SemiColonTkn *token.Token
|
||||
ConstTkn *token.Token
|
||||
Consts []Vertex
|
||||
SeparatorTkns []*token.Token
|
||||
SemiColonTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *StmtConstList) Accept(v NodeVisitor) {
|
||||
@@ -315,9 +316,16 @@ func (n *StmtContinue) Accept(v NodeVisitor) {
|
||||
// StmtDeclare node
|
||||
type StmtDeclare struct {
|
||||
Node
|
||||
Alt bool
|
||||
Consts []Vertex
|
||||
Stmt Vertex
|
||||
Alt bool
|
||||
DeclareTkn *token.Token
|
||||
OpenParenthesisTkn *token.Token
|
||||
Consts []Vertex
|
||||
SeparatorTkns []*token.Token
|
||||
CloseParenthesisTkn *token.Token
|
||||
ColonTkn *token.Token
|
||||
Stmt Vertex
|
||||
EndDeclareTkn *token.Token
|
||||
SemiColonTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *StmtDeclare) Accept(v NodeVisitor) {
|
||||
@@ -1887,24 +1895,6 @@ func (n *NameNamePart) Accept(v NodeVisitor) {
|
||||
v.NameNamePart(n)
|
||||
}
|
||||
|
||||
type ParserAs struct {
|
||||
Node
|
||||
Child Vertex
|
||||
}
|
||||
|
||||
func (n *ParserAs) Accept(v NodeVisitor) {
|
||||
v.ParserAs(n)
|
||||
}
|
||||
|
||||
type ParserNsSeparator struct {
|
||||
Node
|
||||
Child Vertex
|
||||
}
|
||||
|
||||
func (n *ParserNsSeparator) Accept(v NodeVisitor) {
|
||||
v.ParserNsSeparator(n)
|
||||
}
|
||||
|
||||
type ParserBrackets struct {
|
||||
Node
|
||||
OpenBracketTkn *token.Token
|
||||
@@ -1915,3 +1905,13 @@ type ParserBrackets struct {
|
||||
func (n *ParserBrackets) Accept(v NodeVisitor) {
|
||||
v.ParserBrackets(n)
|
||||
}
|
||||
|
||||
type ParserSeparatedList struct {
|
||||
Node
|
||||
Items []Vertex
|
||||
SeparatorTkns []*token.Token
|
||||
}
|
||||
|
||||
func (n *ParserSeparatedList) Accept(v NodeVisitor) {
|
||||
v.ParserSeparatedList(n)
|
||||
}
|
||||
|
||||
@@ -2607,30 +2607,6 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
||||
if !t.visitor.EnterNode(nn) {
|
||||
return
|
||||
}
|
||||
case *ast.ParserAs:
|
||||
if nn == nil {
|
||||
return
|
||||
}
|
||||
if !t.visitor.EnterNode(nn) {
|
||||
return
|
||||
}
|
||||
if nn.Child != nil {
|
||||
t.visitor.Enter("Child", true)
|
||||
t.Traverse(nn.Child)
|
||||
t.visitor.Leave("Child", true)
|
||||
}
|
||||
case *ast.ParserNsSeparator:
|
||||
if nn == nil {
|
||||
return
|
||||
}
|
||||
if !t.visitor.EnterNode(nn) {
|
||||
return
|
||||
}
|
||||
if nn.Child != nil {
|
||||
t.visitor.Enter("Child", true)
|
||||
t.Traverse(nn.Child)
|
||||
t.visitor.Leave("Child", true)
|
||||
}
|
||||
case *ast.ParserBrackets:
|
||||
if nn == nil {
|
||||
return
|
||||
|
||||
@@ -1293,20 +1293,12 @@ func (v *Dump) NameNamePart(n *ast.NameNamePart) {
|
||||
v.print(fmt.Sprintf("Value: []byte(%q),\n", n.Value))
|
||||
}
|
||||
|
||||
func (v *Dump) ParserAs(n *ast.ParserAs) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.ParserAs{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) ParserNsSeparator(n *ast.ParserNsSeparator) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.ParserNsSeparator{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) ParserBrackets(n *ast.ParserBrackets) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.ParserBrackets{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) ParserSeparatedList(n *ast.ParserSeparatedList) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ func (v *FilterTokens) StmtHaltCompiler(n *ast.StmtHaltCompiler) {
|
||||
|
||||
func (v *FilterTokens) StmtConstList(n *ast.StmtConstList) {
|
||||
n.ConstTkn = nil
|
||||
n.SeparatorTkns = nil
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
||||
@@ -224,3 +225,13 @@ func (v *FilterTokens) StmtForeach(n *ast.StmtForeach) {
|
||||
n.EndForeachTkn = nil
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) StmtDeclare(n *ast.StmtDeclare) {
|
||||
n.DeclareTkn = nil
|
||||
n.OpenParenthesisTkn = nil
|
||||
n.SeparatorTkns = nil
|
||||
n.CloseParenthesisTkn = nil
|
||||
n.ColonTkn = nil
|
||||
n.EndDeclareTkn = nil
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
||||
@@ -674,14 +674,10 @@ func (v *Null) NameNamePart(_ *ast.NameNamePart) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) ParserAs(_ *ast.ParserAs) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) ParserNsSeparator(_ *ast.ParserNsSeparator) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) ParserBrackets(_ *ast.ParserBrackets) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) ParserSeparatedList(_ *ast.ParserSeparatedList) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user