[refactoring] update ast structure of "Unset" node

This commit is contained in:
Vadym Slizov
2020-09-14 17:19:17 +03:00
parent 8b4d65ac4d
commit 62fc16da97
7 changed files with 1149 additions and 1160 deletions

View File

@@ -783,7 +783,12 @@ func (n *StmtTry) Accept(v NodeVisitor) {
// StmtUnset node
type StmtUnset struct {
Node
Vars []Vertex
UnsetTkn *token.Token
OpenParenthesisTkn *token.Token
Vars []Vertex
SeparatorTkns []*token.Token
CloseParenthesisTkn *token.Token
SemiColonTkn *token.Token
}
func (n *StmtUnset) Accept(v NodeVisitor) {

View File

@@ -204,3 +204,12 @@ func (v *FilterTokens) StmtEcho(n *ast.StmtEcho) {
func (v *FilterTokens) StmtInlineHtml(n *ast.StmtInlineHtml) {
n.InlineHtmlTkn = nil
}
func (v *FilterTokens) StmtUnset(n *ast.StmtUnset) {
n.UnsetTkn = nil
n.OpenParenthesisTkn = nil
n.SeparatorTkns = nil
n.CloseParenthesisTkn = nil
n.SemiColonTkn = nil
n.SemiColonTkn = nil
}

View File

@@ -2905,24 +2905,12 @@ func (p *Printer) printStmtTry(n ast.Vertex) {
p.printFreeFloating(nn, token.End)
}
func (p *Printer) printStmtUnset(n ast.Vertex) {
nn := n.(*ast.StmtUnset)
p.printFreeFloating(nn, token.Start)
p.write([]byte("unset"))
p.printFreeFloating(nn, token.Unset)
p.write([]byte("("))
p.joinPrint(",", nn.Vars)
p.printFreeFloating(nn, token.VarList)
p.write([]byte(")"))
p.printFreeFloating(nn, token.CloseParenthesisToken)
p.printFreeFloating(nn, token.SemiColon)
if n.GetNode().Tokens.IsEmpty() {
p.write([]byte(";"))
}
p.printFreeFloating(nn, token.End)
func (p *Printer) printStmtUnset(n *ast.StmtUnset) {
p.printToken(n.UnsetTkn, "unset")
p.printToken(n.OpenParenthesisTkn, "(")
p.printSeparatedList(n.Vars, n.SeparatorTkns, ",")
p.printToken(n.CloseParenthesisTkn, ")")
p.printToken(n.SemiColonTkn, ";")
}
func (p *Printer) printStmtUse(n *ast.StmtUse) {