[refactoring] update ast structure of "PostDec", "PostInc", "PreDec", "PreInc" and "New" nodes
This commit is contained in:
@@ -1230,8 +1230,11 @@ func (n *ExprMethodCall) Accept(v NodeVisitor) {
|
||||
// ExprNew node
|
||||
type ExprNew struct {
|
||||
Node
|
||||
Class Vertex
|
||||
ArgumentList *ArgumentList
|
||||
NewTkn *token.Token
|
||||
Class Vertex
|
||||
OpenParenthesisTkn *token.Token
|
||||
Arguments []Vertex
|
||||
CloseParenthesisTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *ExprNew) Accept(v NodeVisitor) {
|
||||
@@ -1241,7 +1244,8 @@ func (n *ExprNew) Accept(v NodeVisitor) {
|
||||
// ExprPostDec node
|
||||
type ExprPostDec struct {
|
||||
Node
|
||||
Var Vertex
|
||||
Var Vertex
|
||||
DecTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *ExprPostDec) Accept(v NodeVisitor) {
|
||||
@@ -1251,7 +1255,8 @@ func (n *ExprPostDec) Accept(v NodeVisitor) {
|
||||
// ExprPostInc node
|
||||
type ExprPostInc struct {
|
||||
Node
|
||||
Var Vertex
|
||||
Var Vertex
|
||||
IncTkn *token.Token
|
||||
}
|
||||
|
||||
func (n *ExprPostInc) Accept(v NodeVisitor) {
|
||||
@@ -1261,7 +1266,8 @@ func (n *ExprPostInc) Accept(v NodeVisitor) {
|
||||
// ExprPreDec node
|
||||
type ExprPreDec struct {
|
||||
Node
|
||||
Var Vertex
|
||||
DecTkn *token.Token
|
||||
Var Vertex
|
||||
}
|
||||
|
||||
func (n *ExprPreDec) Accept(v NodeVisitor) {
|
||||
@@ -1271,7 +1277,8 @@ func (n *ExprPreDec) Accept(v NodeVisitor) {
|
||||
// ExprPreInc node
|
||||
type ExprPreInc struct {
|
||||
Node
|
||||
Var Vertex
|
||||
IncTkn *token.Token
|
||||
Var Vertex
|
||||
}
|
||||
|
||||
func (n *ExprPreInc) Accept(v NodeVisitor) {
|
||||
|
||||
@@ -1415,10 +1415,12 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
||||
t.Traverse(nn.Class)
|
||||
t.visitor.Leave("Class", 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.ExprPostDec:
|
||||
if nn == nil {
|
||||
|
||||
@@ -1143,9 +1143,9 @@ func (p *PrettyPrinter) printExprNew(n ast.Vertex) {
|
||||
io.WriteString(p.w, "new ")
|
||||
p.Print(nn.Class)
|
||||
|
||||
if nn.ArgumentList != nil {
|
||||
if nn.Arguments != nil {
|
||||
io.WriteString(p.w, "(")
|
||||
p.joinPrint(", ", nn.ArgumentList.Arguments)
|
||||
p.joinPrint(", ", nn.Arguments)
|
||||
io.WriteString(p.w, ")")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1710,10 +1710,10 @@ func (p *Printer) printExprNew(n ast.Vertex) {
|
||||
p.bufStart = " "
|
||||
p.Print(nn.Class)
|
||||
|
||||
if nn.ArgumentList != nil {
|
||||
p.printFreeFloatingOrDefault(nn.ArgumentList, token.Start, "(")
|
||||
p.joinPrint(",", nn.ArgumentList.Arguments)
|
||||
p.printFreeFloatingOrDefault(nn.ArgumentList, token.End, ")")
|
||||
if nn.Arguments != nil {
|
||||
p.printToken(nn.OpenParenthesisTkn, "(")
|
||||
p.joinPrint(",", nn.Arguments)
|
||||
p.printToken(nn.CloseParenthesisTkn, ")")
|
||||
}
|
||||
|
||||
p.printFreeFloating(nn, token.End)
|
||||
|
||||
Reference in New Issue
Block a user