[refactoring] do not inherit free-floating tokens in name nodes

This commit is contained in:
Vadym Slizov 2020-08-03 22:39:02 +02:00
parent feebb017c4
commit 48e0996a92
6 changed files with 41 additions and 68 deletions

BIN
internal/php5/php5.go generated

Binary file not shown.

View File

@ -389,7 +389,6 @@ top_statement:
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens) yylex.(*Parser).setToken($$, token.SemiColon, $3.Tokens)
@ -406,7 +405,6 @@ top_statement:
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens)
yylex.(*Parser).MoveFreeFloating($2[0], name)
yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens) yylex.(*Parser).setFreeFloating(name, token.End, $3.Tokens)
yylex.(*Parser).setFreeFloating($$, token.Stmts, $5.Tokens) yylex.(*Parser).setFreeFloating($$, token.Stmts, $5.Tokens)
@ -4429,7 +4427,6 @@ combined_scalar_offset:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -4443,7 +4440,6 @@ combined_scalar_offset:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -4459,7 +4455,7 @@ combined_scalar_offset:
$$.GetNode().Position = position.NewNodeTokenPosition(str, $4) $$.GetNode().Position = position.NewNodeTokenPosition(str, $4)
// save comments // save comments
yylex.(*Parser).setFreeFloating($$, token.Start, $1.Tokens) yylex.(*Parser).setFreeFloating(str, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -4473,7 +4469,6 @@ combined_scalar_offset:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -4622,9 +4617,6 @@ function_call:
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
$$.GetNode().Position = position.NewNodesPosition(name, $2) $$.GetNode().Position = position.NewNodesPosition(name, $2)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_NAMESPACE T_NS_SEPARATOR namespace_name function_call_parameter_list | T_NAMESPACE T_NS_SEPARATOR namespace_name function_call_parameter_list
@ -4742,9 +4734,6 @@ class_name:
// save position // save position
$$.GetNode().Position = position.NewNodeListPosition($1) $$.GetNode().Position = position.NewNodeListPosition($1)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_NAMESPACE T_NS_SEPARATOR namespace_name | T_NAMESPACE T_NS_SEPARATOR namespace_name
@ -4782,9 +4771,6 @@ fully_qualified_class_name:
// save position // save position
$$.GetNode().Position = position.NewNodeListPosition($1) $$.GetNode().Position = position.NewNodeListPosition($1)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_NAMESPACE T_NS_SEPARATOR namespace_name | T_NAMESPACE T_NS_SEPARATOR namespace_name
@ -5186,9 +5172,6 @@ static_scalar_value:
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
$$.GetNode().Position = position.NewNodePosition(name) $$.GetNode().Position = position.NewNodePosition(name)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_NAMESPACE T_NS_SEPARATOR namespace_name | T_NAMESPACE T_NS_SEPARATOR namespace_name
@ -5282,7 +5265,6 @@ static_operation:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -5718,9 +5700,6 @@ general_constant:
name.GetNode().Position = position.NewNodeListPosition($1) name.GetNode().Position = position.NewNodeListPosition($1)
$$.GetNode().Position = position.NewNodePosition(name) $$.GetNode().Position = position.NewNodePosition(name)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_NAMESPACE T_NS_SEPARATOR namespace_name | T_NAMESPACE T_NS_SEPARATOR namespace_name
@ -6226,7 +6205,6 @@ array_function_dereference:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -6240,7 +6218,6 @@ array_function_dereference:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -6306,7 +6283,6 @@ reference_variable:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -6320,7 +6296,6 @@ reference_variable:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -6853,7 +6828,7 @@ encaps_var:
$$.GetNode().Position = position.NewTokensPosition($1, $6) $$.GetNode().Position = position.NewTokensPosition($1, $6)
// save comments // save comments
yylex.(*Parser).setToken($$, token.Start, $1.Tokens) yylex.(*Parser).setToken(variable, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $3.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $3.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $5.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $5.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $6.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $6.Tokens)

BIN
internal/php7/php7.go generated

Binary file not shown.

View File

@ -392,9 +392,6 @@ name:
// save position // save position
$$.GetNode().Position = position.NewNodeListPosition($1) $$.GetNode().Position = position.NewNodeListPosition($1)
// save comments
yylex.(*Parser).MoveFreeFloating($1[0], $$)
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL) yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
} }
| T_NAMESPACE T_NS_SEPARATOR namespace_name | T_NAMESPACE T_NS_SEPARATOR namespace_name
@ -4818,7 +4815,6 @@ callable_variable:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -4832,7 +4828,6 @@ callable_variable:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -4846,7 +4841,6 @@ callable_variable:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -4988,7 +4982,6 @@ new_variable:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -5002,7 +4995,6 @@ new_variable:
$$.GetNode().Position = position.NewNodeTokenPosition($1, $4) $$.GetNode().Position = position.NewNodeTokenPosition($1, $4)
// save comments // save comments
yylex.(*Parser).MoveFreeFloating($1, $$)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $2.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $4.Tokens)
@ -5403,7 +5395,7 @@ encaps_var:
$$.GetNode().Position = position.NewTokensPosition($1, $6) $$.GetNode().Position = position.NewTokensPosition($1, $6)
// save comments // save comments
yylex.(*Parser).setToken($$, token.Start, $1.Tokens) yylex.(*Parser).setToken(variable, token.Start, $1.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $3.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Var, $3.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $5.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.Expr, $5.Tokens)
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $6.Tokens) yylex.(*Parser).setFreeFloatingTokens($$, token.End, $6.Tokens)

View File

@ -594,35 +594,48 @@ func (p *Printer) printNameRelative(n ast.Vertex) {
func (p *Printer) printScalarLNumber(n ast.Vertex) { func (p *Printer) printScalarLNumber(n ast.Vertex) {
nn := n.(*ast.ScalarLnumber) nn := n.(*ast.ScalarLnumber)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Value)) io.WriteString(p.w, string(nn.Value))
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printScalarDNumber(n ast.Vertex) { func (p *Printer) printScalarDNumber(n ast.Vertex) {
nn := n.(*ast.ScalarDnumber) nn := n.(*ast.ScalarDnumber)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Value)) io.WriteString(p.w, string(nn.Value))
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printScalarString(n ast.Vertex) { func (p *Printer) printScalarString(n ast.Vertex) {
nn := n.(*ast.ScalarString) nn := n.(*ast.ScalarString)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Value)) io.WriteString(p.w, string(nn.Value))
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printScalarEncapsedStringPart(n ast.Vertex) { func (p *Printer) printScalarEncapsedStringPart(n ast.Vertex) {
nn := n.(*ast.ScalarEncapsedStringPart) nn := n.(*ast.ScalarEncapsedStringPart)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Value)) io.WriteString(p.w, string(nn.Value))
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
func (p *Printer) printScalarEncapsed(n ast.Vertex) { func (p *Printer) printScalarEncapsed(n ast.Vertex) {
nn := n.(*ast.ScalarEncapsed) nn := n.(*ast.ScalarEncapsed)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, "\"") io.WriteString(p.w, "\"")
for _, part := range nn.Parts { for _, part := range nn.Parts {
@ -652,7 +665,8 @@ func (p *Printer) printScalarEncapsed(n ast.Vertex) {
func (p *Printer) printScalarHeredoc(n ast.Vertex) { func (p *Printer) printScalarHeredoc(n ast.Vertex) {
nn := n.(*ast.ScalarHeredoc) nn := n.(*ast.ScalarHeredoc)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Label)) io.WriteString(p.w, string(nn.Label))
@ -684,8 +698,11 @@ func (p *Printer) printScalarHeredoc(n ast.Vertex) {
func (p *Printer) printScalarMagicConstant(n ast.Vertex) { func (p *Printer) printScalarMagicConstant(n ast.Vertex) {
nn := n.(*ast.ScalarMagicConstant) nn := n.(*ast.ScalarMagicConstant)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
io.WriteString(p.w, string(nn.Value)) io.WriteString(p.w, string(nn.Value))
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
} }
@ -1613,9 +1630,7 @@ func (p *Printer) printExprInstanceOf(n ast.Vertex) {
io.WriteString(p.w, "instanceof") io.WriteString(p.w, "instanceof")
if nn.Class.GetNode().Tokens.IsEmpty() { p.bufStart = " "
io.WriteString(p.w, " ")
}
p.Print(nn.Class) p.Print(nn.Class)
p.printFreeFloating(nn, token.End) p.printFreeFloating(nn, token.End)
@ -1673,9 +1688,7 @@ func (p *Printer) printExprNew(n ast.Vertex) {
p.printFreeFloating(nn, token.Start) p.printFreeFloating(nn, token.Start)
io.WriteString(p.w, "new") io.WriteString(p.w, "new")
if nn.Class.GetNode().Tokens.IsEmpty() { p.bufStart = " "
io.WriteString(p.w, " ")
}
p.Print(nn.Class) p.Print(nn.Class)
if nn.ArgumentList != nil { if nn.ArgumentList != nil {
@ -1900,7 +1913,8 @@ func (p *Printer) printExprUnaryPlus(n ast.Vertex) {
func (p *Printer) printExprVariable(n ast.Vertex) { func (p *Printer) printExprVariable(n ast.Vertex) {
nn := n.(*ast.ExprVariable) nn := n.(*ast.ExprVariable)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
p.printFreeFloating(nn, token.Dollar) p.printFreeFloating(nn, token.Dollar)
if _, ok := nn.VarName.(*ast.Identifier); !ok { if _, ok := nn.VarName.(*ast.Identifier); !ok {
@ -2282,7 +2296,8 @@ func (p *Printer) printStmtClassMethod(n ast.Vertex) {
func (p *Printer) printStmtClass(n ast.Vertex) { func (p *Printer) printStmtClass(n ast.Vertex) {
nn := n.(*ast.StmtClass) nn := n.(*ast.StmtClass)
p.printFreeFloating(nn, token.Start) p.printFreeFloatingOrDefault(nn, token.Start, p.bufStart)
p.bufStart = ""
if nn.Modifiers != nil { if nn.Modifiers != nil {
for k, m := range nn.Modifiers { for k, m := range nn.Modifiers {
@ -2301,9 +2316,7 @@ func (p *Printer) printStmtClass(n ast.Vertex) {
p.printFreeFloating(nn, token.Class) p.printFreeFloating(nn, token.Class)
if nn.ClassName != nil { if nn.ClassName != nil {
if nn.ClassName.GetNode().Tokens.IsEmpty() { p.bufStart = " "
io.WriteString(p.w, " ")
}
p.Print(nn.ClassName) p.Print(nn.ClassName)
} }
@ -2322,9 +2335,7 @@ func (p *Printer) printStmtClass(n ast.Vertex) {
io.WriteString(p.w, " ") io.WriteString(p.w, " ")
} }
io.WriteString(p.w, "extends") io.WriteString(p.w, "extends")
if nn.Extends.ClassName.GetNode().Tokens.IsEmpty() { p.bufStart = " "
io.WriteString(p.w, " ")
}
p.Print(nn.Extends.ClassName) p.Print(nn.Extends.ClassName)
} }
@ -2890,12 +2901,11 @@ func (p *Printer) printStmtPropertyList(n ast.Vertex) {
p.Print(m) p.Print(m)
} }
if nn.Type != nil && nn.Type.GetNode().Tokens.IsEmpty() { if nn.Type != nil {
io.WriteString(p.w, " ") p.bufStart = " "
p.Print(nn.Type)
} }
p.Print(nn.Type)
if nn.Properties[0].GetNode().Tokens.IsEmpty() { if nn.Properties[0].GetNode().Tokens.IsEmpty() {
io.WriteString(p.w, " ") io.WriteString(p.w, " ")
} }
@ -2931,9 +2941,7 @@ func (p *Printer) printStmtReturn(n ast.Vertex) {
p.printFreeFloating(nn, token.Start) p.printFreeFloating(nn, token.Start)
io.WriteString(p.w, "return") io.WriteString(p.w, "return")
if nn.Expr != nil && nn.Expr.GetNode().Tokens.IsEmpty() { p.bufStart = " "
io.WriteString(p.w, " ")
}
p.Print(nn.Expr) p.Print(nn.Expr)
p.printFreeFloating(nn, token.Expr) p.printFreeFloating(nn, token.Expr)
@ -3102,9 +3110,7 @@ func (p *Printer) printStmtTraitUsePrecedence(n ast.Vertex) {
} }
io.WriteString(p.w, "insteadof") io.WriteString(p.w, "insteadof")
if nn.Insteadof[0].GetNode().Tokens.IsEmpty() { p.bufStart = " "
io.WriteString(p.w, " ")
}
p.joinPrint(",", nn.Insteadof) p.joinPrint(",", nn.Insteadof)
p.printFreeFloating(nn, token.NameList) p.printFreeFloating(nn, token.NameList)

View File

@ -979,7 +979,7 @@ func TestParseAndPrintClass(t *testing.T) {
} }
new class ( $c ) extends Foo implements Bar , Baz { new class ( $c, $a ) extends Foo implements Bar , Baz {
} ;` } ;`