replace meta.OpenCurlyBracesToken from stmt.StmtList

This commit is contained in:
z7zmey 2018-10-29 14:59:57 +02:00
parent 4bb9aada9e
commit 14cfed2e03
10 changed files with 16 additions and 17 deletions

View File

@ -2976,7 +2976,7 @@ yydefault:
yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token))
// save comments
yyDollar[1].token.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yyDollar[1].token.Meta.SetTokenName(meta.NodeStart).AppendTo(yyVAL.node.GetMeta())
yyDollar[3].token.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
@ -5126,7 +5126,7 @@ yydefault:
yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token))
// save comments
yyDollar[1].token.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yyDollar[1].token.Meta.SetTokenName(meta.NodeStart).AppendTo(yyVAL.node.GetMeta())
yyDollar[3].token.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)

View File

@ -878,7 +878,7 @@ unticked_statement:
$$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
// save comments
$1.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo($$.GetMeta())
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
$3.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
@ -2923,7 +2923,7 @@ method_body:
$$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
// save comments
$1.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo($$.GetMeta())
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
$3.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)

View File

@ -3246,7 +3246,7 @@ yydefault:
yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token))
// save comments
yyDollar[1].token.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yyDollar[1].token.Meta.SetTokenName(meta.NodeStart).AppendTo(yyVAL.node.GetMeta())
yyDollar[3].token.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
@ -5136,7 +5136,7 @@ yydefault:
yyVAL.node.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition(yyDollar[1].token, yyDollar[3].token))
// save comments
yyDollar[1].token.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yyDollar[1].token.Meta.SetTokenName(meta.NodeStart).AppendTo(yyVAL.node.GetMeta())
yyDollar[3].token.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo(yyVAL.node.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)

View File

@ -944,7 +944,7 @@ statement:
$$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
// save comments
$1.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo($$.GetMeta())
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
$3.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)
@ -2727,7 +2727,7 @@ method_body:
$$.SetPosition(yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
// save comments
$1.Meta.SetTokenName(meta.OpenCurlyBracesToken).AppendTo($$.GetMeta())
$1.Meta.SetTokenName(meta.NodeStart).AppendTo($$.GetMeta())
$3.Meta.SetTokenName(meta.CloseCurlyBracesToken).AppendTo($$.GetMeta())
yylex.(*Parser).returnTokenToPool(yyDollar, &yyVAL)

View File

@ -2484,7 +2484,6 @@ func (p *Printer) printStmtStmtList(n node.Node) {
nn := n.(*stmt.StmtList)
p.printMeta(nn, meta.NodeStart)
p.printMeta(nn, meta.OpenCurlyBracesToken)
io.WriteString(p.w, "{")
p.printNodes(nn.Stmts)
p.printMeta(nn, meta.CloseCurlyBracesToken)

View File

@ -5718,7 +5718,7 @@ func TestPrinterPrintStmtClassMethod(t *testing.T) {
&meta.Data{
Type: meta.WhiteSpaceType,
Value: " ",
TokenName: meta.OpenCurlyBracesToken,
TokenName: meta.NodeStart,
},
&meta.Data{
Type: meta.WhiteSpaceType,
@ -7843,7 +7843,7 @@ func TestPrinterPrintStmtList(t *testing.T) {
&meta.Data{
Type: meta.WhiteSpaceType,
Value: " ",
TokenName: meta.OpenCurlyBracesToken,
TokenName: meta.NodeStart,
},
&meta.Data{
Type: meta.WhiteSpaceType,
@ -7892,7 +7892,7 @@ func TestPrinterPrintStmtListNested(t *testing.T) {
&meta.Data{
Type: meta.WhiteSpaceType,
Value: " ",
TokenName: meta.OpenCurlyBracesToken,
TokenName: meta.NodeStart,
},
&meta.Data{
Type: meta.WhiteSpaceType,

View File

@ -132,7 +132,7 @@ func ExampleDumper() {
// | [*stmt.StmtList]
// | "Position": Pos{Line: 6-9 Pos: 96-134}
// | "Meta":
// | "\n\t\t\t\t" before "OpenCurlyBracesToken"
// | "\n\t\t\t\t" before "NodeStart"
// | "\n\t\t\t\t" before "CloseCurlyBracesToken"
// | "Stmts":
// | [*stmt.Expression]

View File

@ -215,8 +215,8 @@ func ExampleGoDumper() {
// TokenName: meta.FunctionToken,
// },
// },
// ReturnsRef: false,
// PhpDocComment: "",
// ReturnsRef: false,
// MethodName: &node.Identifier{
// Position: &position.Position{
// StartLine: 5,
@ -400,7 +400,7 @@ func ExampleGoDumper() {
// EndPos: 95,
// },
// Value: "\n\t\t\t\t",
// TokenName: meta.OpenCurlyBracesToken,
// TokenName: meta.NodeStart,
// },
// &meta.Data{
// Type: meta.WhiteSpaceType,

View File

@ -37,5 +37,5 @@ func ExampleJsonDumper() {
nodes.Walk(dumper)
// Output:
// {"type":"*node.Root","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"Stmts":[{"type":"*stmt.Namespace","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"meta":[{"type":"*meta.TokenType","value":"<?php","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\n\n\t\t","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t","tokenName":"CloseCurlyBracesToken"}],"NamespaceName":{"type":"*name.Name","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"Parts":[{"type":"*name.NamePart","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Foo"}]},"Stmts":[{"type":"*stmt.Class","position":{"startPos":29,"endPos":162,"startLine":4,"endLine":11},"namespacedName":"Foo\\Bar","meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"ClassToken"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"CloseCurlyBracesToken"}],"PhpDocComment":"","ClassName":{"type":"*node.Identifier","position":{"startPos":35,"endPos":37,"startLine":4,"endLine":4},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Bar"},"Stmts":[{"type":"*stmt.ClassMethod","position":{"startPos":45,"endPos":157,"startLine":5,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"FunctionToken"}],"PhpDocComment":"","ReturnsRef":false,"MethodName":{"type":"*node.Identifier","position":{"startPos":61,"endPos":72,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"FunctionName"},"Modifiers":[{"type":"*node.Identifier","position":{"startPos":45,"endPos":50,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"NodeStart"}],"Value":"public"}],"Params":[{"type":"*node.Parameter","position":{"startPos":74,"endPos":89,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"EqualToken"}],"ByRef":false,"Variadic":false,"VariableType":{"type":"*name.Name","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"namespacedName":"Foo\\Type","Parts":[{"type":"*name.NamePart","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"Value":"Type"}]},"Variable":{"type":"*expr.Variable","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"Value":"var"}},"DefaultValue":{"type":"*expr.ConstFetch","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"Constant":{"type":"*name.Name","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"namespacedName":"null","Parts":[{"type":"*name.NamePart","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"null"}]}}}],"Stmt":{"type":"*stmt.StmtList","position":{"startPos":96,"endPos":157,"startLine":6,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"CloseCurlyBracesToken"}],"Stmts":[{"type":"*stmt.Expression","position":{"startPos":147,"endPos":151,"startLine":9,"endLine":9},"meta":[{"type":"*meta.TokenType","value":";","tokenName":"SemiColonToken"}],"Expr":{"type":"*expr.Variable","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// some comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// second comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"Value":"var"}}}]}}]}]}]}
// {"type":"*node.Root","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"Stmts":[{"type":"*stmt.Namespace","position":{"startPos":10,"endPos":166,"startLine":3,"endLine":12},"meta":[{"type":"*meta.TokenType","value":"<?php","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\n\n\t\t","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t","tokenName":"CloseCurlyBracesToken"}],"NamespaceName":{"type":"*name.Name","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"Parts":[{"type":"*name.NamePart","position":{"startPos":20,"endPos":22,"startLine":3,"endLine":3},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Foo"}]},"Stmts":[{"type":"*stmt.Class","position":{"startPos":29,"endPos":162,"startLine":4,"endLine":11},"namespacedName":"Foo\\Bar","meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"ClassToken"},{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"OpenCurlyBracesToken"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t","tokenName":"CloseCurlyBracesToken"}],"PhpDocComment":"","ClassName":{"type":"*node.Identifier","position":{"startPos":35,"endPos":37,"startLine":4,"endLine":4},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"Bar"},"Stmts":[{"type":"*stmt.ClassMethod","position":{"startPos":45,"endPos":157,"startLine":5,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"FunctionToken"}],"PhpDocComment":"","ReturnsRef":false,"MethodName":{"type":"*node.Identifier","position":{"startPos":61,"endPos":72,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"FunctionName"},"Modifiers":[{"type":"*node.Identifier","position":{"startPos":45,"endPos":50,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"NodeStart"}],"Value":"public"}],"Params":[{"type":"*node.Parameter","position":{"startPos":74,"endPos":89,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"EqualToken"}],"ByRef":false,"Variadic":false,"VariableType":{"type":"*name.Name","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"namespacedName":"Foo\\Type","Parts":[{"type":"*name.NamePart","position":{"startPos":74,"endPos":77,"startLine":5,"endLine":5},"Value":"Type"}]},"Variable":{"type":"*expr.Variable","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":79,"endPos":82,"startLine":5,"endLine":5},"Value":"var"}},"DefaultValue":{"type":"*expr.ConstFetch","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"Constant":{"type":"*name.Name","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"namespacedName":"null","Parts":[{"type":"*name.NamePart","position":{"startPos":86,"endPos":89,"startLine":5,"endLine":5},"meta":[{"type":"*meta.WhiteSpaceType","value":" ","tokenName":"NodeStart"}],"Value":"null"}]}}}],"Stmt":{"type":"*stmt.StmtList","position":{"startPos":96,"endPos":157,"startLine":6,"endLine":10},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t","tokenName":"CloseCurlyBracesToken"}],"Stmts":[{"type":"*stmt.Expression","position":{"startPos":147,"endPos":151,"startLine":9,"endLine":9},"meta":[{"type":"*meta.TokenType","value":";","tokenName":"SemiColonToken"}],"Expr":{"type":"*expr.Variable","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"meta":[{"type":"*meta.WhiteSpaceType","value":"\n\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// some comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.CommentType","value":"// second comment\n","tokenName":"NodeStart"},{"type":"*meta.WhiteSpaceType","value":"\t\t\t\t\t","tokenName":"NodeStart"},{"type":"*meta.TokenType","value":"$","tokenName":"NodeStart"}],"VarName":{"type":"*node.Identifier","position":{"startPos":147,"endPos":150,"startLine":9,"endLine":9},"Value":"var"}}}]}}]}]}]}
}

View File

@ -335,7 +335,7 @@ func ExamplePrettyJsonDumper() {
// {
// "type": "*meta.WhiteSpaceType",
// "value": "\n\t\t\t\t",
// "tokenName": "OpenCurlyBracesToken"
// "tokenName": "NodeStart"
// },
// {
// "type": "*meta.WhiteSpaceType",