remove nodesWithEndToken type

This commit is contained in:
z7zmey
2018-06-03 09:35:44 +03:00
parent 2abe1dfb84
commit a488f43496
17 changed files with 1393 additions and 1251 deletions

View File

@@ -1517,13 +1517,18 @@ func (p *Printer) printStmtClassMethod(n node.Node) {
p.Print(nn.ReturnType)
}
io.WriteString(p.w, "\n")
p.printIndent()
io.WriteString(p.w, "{\n")
p.printNodes(nn.Stmts)
io.WriteString(p.w, "\n")
p.printIndent()
io.WriteString(p.w, "}")
switch s := nn.Stmt.(type) {
case *stmt.StmtList:
io.WriteString(p.w, "\n")
p.printIndent()
io.WriteString(p.w, "{\n")
p.printNodes(s.Stmts)
io.WriteString(p.w, "\n")
p.printIndent()
io.WriteString(p.w, "}")
default:
p.Print(s)
}
}
func (p *Printer) printStmtClass(n node.Node) {

View File

@@ -44,10 +44,12 @@ func TestPrintFile(t *testing.T) {
&stmt.ClassMethod{
Modifiers: []node.Node{&node.Identifier{Value: "public"}},
MethodName: &node.Identifier{Value: "greet"},
Stmts: []node.Node{
&stmt.Echo{
Exprs: []node.Node{
&scalar.String{Value: "'Hello world'"},
Stmt: &stmt.StmtList{
Stmts: []node.Node{
&stmt.Echo{
Exprs: []node.Node{
&scalar.String{Value: "'Hello world'"},
},
},
},
},
@@ -2453,8 +2455,10 @@ func TestPrintStmtClassMethod(t *testing.T) {
},
},
ReturnType: &name.Name{Parts: []node.Node{&name.NamePart{Value: "void"}}},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
Stmt: &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
},
},
})
@@ -3387,8 +3391,10 @@ func TestPrintInterface(t *testing.T) {
Modifiers: []node.Node{&node.Identifier{Value: "public"}},
MethodName: &node.Identifier{Value: "foo"},
Params: []node.Node{},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
Stmt: &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
},
},
},
},
@@ -3833,8 +3839,10 @@ func TestPrintTrait(t *testing.T) {
Modifiers: []node.Node{&node.Identifier{Value: "public"}},
MethodName: &node.Identifier{Value: "foo"},
Params: []node.Node{},
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
Stmt: &stmt.StmtList{
Stmts: []node.Node{
&stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
},
},
},
},