[refactoring] update ast structure of "For" node
This commit is contained in:
@@ -252,12 +252,6 @@ func (v *Dump) Argument(n *ast.Argument) {
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Dump) StmtAltFor(n *ast.StmtAltFor) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.StmtAltFor{\n")
|
||||
v.printNode(n.GetNode())
|
||||
}
|
||||
|
||||
func (v *Dump) StmtAltForeach(n *ast.StmtAltForeach) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.StmtAltForeach{\n")
|
||||
@@ -414,6 +408,11 @@ func (v *Dump) StmtFor(n *ast.StmtFor) {
|
||||
v.printIndentIfNotSingle(v.indent - 1)
|
||||
v.print("&ast.StmtFor{\n")
|
||||
v.printNode(n.GetNode())
|
||||
|
||||
if n.Alt {
|
||||
v.printIndent(v.indent)
|
||||
v.print("Alt: true,\n")
|
||||
}
|
||||
}
|
||||
|
||||
func (v *Dump) StmtForeach(n *ast.StmtForeach) {
|
||||
|
||||
@@ -209,44 +209,6 @@ func (v *FilterParserNodes) ExprVariable(n *ast.ExprVariable) {
|
||||
}
|
||||
}
|
||||
|
||||
func (v *FilterParserNodes) StmtFor(n *ast.StmtFor) {
|
||||
for k, v := range n.Init {
|
||||
for {
|
||||
if nn, ok := v.(*ast.ParserBrackets); ok {
|
||||
v = nn.Child
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
n.Init[k] = v
|
||||
}
|
||||
|
||||
for k, v := range n.Cond {
|
||||
for {
|
||||
if nn, ok := v.(*ast.ParserBrackets); ok {
|
||||
v = nn.Child
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
n.Cond[k] = v
|
||||
}
|
||||
|
||||
for k, v := range n.Loop {
|
||||
for {
|
||||
if nn, ok := v.(*ast.ParserBrackets); ok {
|
||||
v = nn.Child
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
n.Loop[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
func (v *FilterParserNodes) ExprAssign(n *ast.ExprAssign) {
|
||||
for {
|
||||
if nn, ok := n.Expr.(*ast.ParserBrackets); ok {
|
||||
|
||||
@@ -130,3 +130,14 @@ func (v *FilterTokens) StmtDo(n *ast.StmtDo) {
|
||||
n.CloseParenthesisTkn = nil
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) StmtFor(n *ast.StmtFor) {
|
||||
n.ForTkn = nil
|
||||
n.OpenParenthesisTkn = nil
|
||||
n.InitSemiColonTkn = nil
|
||||
n.CondSemiColonTkn = nil
|
||||
n.CloseParenthesisTkn = nil
|
||||
n.ColonTkn = nil
|
||||
n.EndForTkn = nil
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
||||
@@ -54,10 +54,6 @@ func (v *Null) Argument(_ *ast.Argument) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtAltFor(_ *ast.StmtAltFor) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (v *Null) StmtAltForeach(_ *ast.StmtAltForeach) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user