[refactoring] update ast structure of "ShellExec", "StaticCall", "StaticPropertyFetch" and "Ternary" nodes

This commit is contained in:
Vadym Slizov
2020-12-03 22:41:08 +02:00
parent 592c9b9aff
commit 13436b88a7
8 changed files with 803 additions and 747 deletions

View File

@@ -1344,7 +1344,9 @@ func (n *ExprRequireOnce) Accept(v NodeVisitor) {
// ExprShellExec node
type ExprShellExec struct {
Node
Parts []Vertex
OpenBacktickTkn *token.Token
Parts []Vertex
CloseBacktickTkn *token.Token
}
func (n *ExprShellExec) Accept(v NodeVisitor) {
@@ -1354,9 +1356,12 @@ func (n *ExprShellExec) Accept(v NodeVisitor) {
// ExprStaticCall node
type ExprStaticCall struct {
Node
Class Vertex
Call Vertex
ArgumentList *ArgumentList
Class Vertex
DoubleColonTkn *token.Token
Call Vertex
OpenParenthesisTkn *token.Token
Arguments []Vertex
CloseParenthesisTkn *token.Token
}
func (n *ExprStaticCall) Accept(v NodeVisitor) {
@@ -1366,8 +1371,9 @@ func (n *ExprStaticCall) Accept(v NodeVisitor) {
// ExprStaticPropertyFetch node
type ExprStaticPropertyFetch struct {
Node
Class Vertex
Property Vertex
Class Vertex
DoubleColonTkn *token.Token
Property Vertex
}
func (n *ExprStaticPropertyFetch) Accept(v NodeVisitor) {
@@ -1377,9 +1383,11 @@ func (n *ExprStaticPropertyFetch) Accept(v NodeVisitor) {
// ExprTernary node
type ExprTernary struct {
Node
Condition Vertex
IfTrue Vertex
IfFalse Vertex
Condition Vertex
QuestionTkn *token.Token
IfTrue Vertex
ColonTkn *token.Token
IfFalse Vertex
}
func (n *ExprTernary) Accept(v NodeVisitor) {

View File

@@ -1566,10 +1566,12 @@ func (t *DFS) Traverse(n ast.Vertex) {
t.Traverse(nn.Call)
t.visitor.Leave("Call", true)
}
if nn.ArgumentList != nil {
t.visitor.Enter("ArgumentList", true)
t.Traverse(nn.ArgumentList)
t.visitor.Leave("ArgumentList", true)
if nn.Arguments != nil {
t.visitor.Enter("Arguments", false)
for _, c := range nn.Arguments {
t.Traverse(c)
}
t.visitor.Leave("Arguments", false)
}
case *ast.ExprStaticPropertyFetch:
if nn == nil {

View File

@@ -1239,7 +1239,7 @@ func (p *PrettyPrinter) printExprStaticCall(n ast.Vertex) {
io.WriteString(p.w, "::")
p.Print(nn.Call)
io.WriteString(p.w, "(")
p.joinPrint(", ", nn.ArgumentList.Arguments)
p.joinPrint(", ", nn.Arguments)
io.WriteString(p.w, ")")
}

View File

@@ -1842,9 +1842,9 @@ func (p *Printer) printExprStaticCall(n ast.Vertex) {
p.write([]byte("::"))
p.Print(nn.Call)
p.printFreeFloatingOrDefault(nn.ArgumentList, token.Start, "(")
p.joinPrint(",", nn.ArgumentList.Arguments)
p.printFreeFloatingOrDefault(nn.ArgumentList, token.End, ")")
p.printToken(nn.OpenParenthesisTkn, "(")
p.joinPrint(",", nn.Arguments)
p.printToken(nn.CloseParenthesisTkn, ")")
p.printFreeFloating(nn, token.End)
}