[refactoring] update ast structure for "Use" and "GroupUse" nodes
This commit is contained in:
parent
97747c5ac0
commit
767187ff85
@ -11677,15 +11677,6 @@ func TestStmtUse(t *testing.T) {
|
|||||||
EndPos: 11,
|
EndPos: 11,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 10,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -11723,7 +11714,6 @@ func TestStmtUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -11757,15 +11747,6 @@ func TestStmtUse_FullyQualified(t *testing.T) {
|
|||||||
EndPos: 12,
|
EndPos: 12,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 11,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -11803,7 +11784,6 @@ func TestStmtUse_FullyQualified(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -11837,15 +11817,6 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
|
|||||||
EndPos: 19,
|
EndPos: 19,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 18,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -11894,7 +11865,6 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -11928,15 +11898,6 @@ func TestStmtUse_List(t *testing.T) {
|
|||||||
EndPos: 16,
|
EndPos: 16,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 15,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12007,7 +11968,6 @@ func TestStmtUse_List(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -12041,15 +12001,6 @@ func TestStmtUse_ListAlias(t *testing.T) {
|
|||||||
EndPos: 23,
|
EndPos: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 22,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12131,7 +12082,6 @@ func TestStmtUse_ListAlias(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -12165,15 +12115,6 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
|
|||||||
EndPos: 26,
|
EndPos: 26,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 25,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -12185,15 +12126,6 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 16,
|
|
||||||
EndPos: 25,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12264,8 +12196,6 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -12299,15 +12229,6 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
|
|||||||
EndPos: 40,
|
EndPos: 40,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 39,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -12319,15 +12240,6 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 16,
|
|
||||||
EndPos: 39,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12420,8 +12332,6 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -12455,16 +12365,6 @@ func TestStmtUse_ListConstType(t *testing.T) {
|
|||||||
EndPos: 23,
|
EndPos: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 22,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -12476,15 +12376,6 @@ func TestStmtUse_ListConstType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 13,
|
|
||||||
EndPos: 22,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12555,8 +12446,6 @@ func TestStmtUse_ListConstType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
@ -12590,15 +12479,6 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
|
|||||||
EndPos: 37,
|
EndPos: 37,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 36,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -12610,15 +12490,6 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 13,
|
|
||||||
EndPos: 36,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12711,8 +12582,6 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
lexer := scanner.NewLexer([]byte(src), "5.6", nil)
|
||||||
|
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -395,52 +395,48 @@ top_statement:
|
|||||||
}
|
}
|
||||||
| T_USE use_declarations ';'
|
| T_USE use_declarations ';'
|
||||||
{
|
{
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $2}
|
$$ = &ast.StmtUse{
|
||||||
$$ = &ast.StmtUse{ast.Node{}, useList}
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokensPosition($1, $3),
|
||||||
// save position
|
},
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($2)
|
UseTkn: $1,
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
UseDeclarations: $2,
|
||||||
|
SemiColonTkn: $3,
|
||||||
// save comments
|
}
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_USE T_FUNCTION use_function_declarations ';'
|
| T_USE T_FUNCTION use_function_declarations ';'
|
||||||
{
|
{
|
||||||
identifier := &ast.Identifier{ast.Node{}, $2.Value}
|
$$ = &ast.StmtUse{
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $3}
|
Node: ast.Node{
|
||||||
useType := &ast.StmtUseType{ast.Node{}, identifier, useList}
|
Position: position.NewTokensPosition($1, $4),
|
||||||
$$ = &ast.StmtUse{ast.Node{}, useType}
|
},
|
||||||
|
UseTkn: $1,
|
||||||
// save position
|
Type: &ast.Identifier{
|
||||||
identifier.GetNode().Position = position.NewTokenPosition($2)
|
Node: ast.Node{
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($3)
|
Position: position.NewTokenPosition($2),
|
||||||
useType.GetNode().Position = position.NewTokenNodePosition($2, useList)
|
},
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
Value: $2.Value,
|
||||||
|
},
|
||||||
// save comments
|
UseDeclarations: $3,
|
||||||
yylex.(*Parser).setFreeFloating(identifier, token.Start, $2.SkippedTokens)
|
SemiColonTkn: $4,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_USE T_CONST use_const_declarations ';'
|
| T_USE T_CONST use_const_declarations ';'
|
||||||
{
|
{
|
||||||
identifier := &ast.Identifier{ast.Node{}, $2.Value}
|
$$ = &ast.StmtUse{
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $3}
|
Node: ast.Node{
|
||||||
useType := &ast.StmtUseType{ast.Node{}, identifier, useList}
|
Position: position.NewTokensPosition($1, $4),
|
||||||
$$ = &ast.StmtUse{ast.Node{}, useType}
|
},
|
||||||
|
UseTkn: $1,
|
||||||
// save position
|
Type: &ast.Identifier{
|
||||||
identifier.GetNode().Position = position.NewTokenPosition($2)
|
Node: ast.Node{
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($3)
|
Position: position.NewTokenPosition($2),
|
||||||
useType.GetNode().Position = position.NewTokenNodePosition($2, useList)
|
},
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
Value: $2.Value,
|
||||||
|
},
|
||||||
// save comments
|
UseDeclarations: $3,
|
||||||
yylex.(*Parser).setFreeFloating(identifier, token.Start, $2.SkippedTokens)
|
SemiColonTkn: $4,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
}
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| constant_declaration ';'
|
| constant_declaration ';'
|
||||||
{
|
{
|
||||||
@ -458,10 +454,9 @@ top_statement:
|
|||||||
use_declarations:
|
use_declarations:
|
||||||
use_declarations ',' use_declaration
|
use_declarations ',' use_declaration
|
||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$1[len($1)-1].(*ast.StmtUseDeclaration).CommaTkn = $2
|
||||||
|
|
||||||
// save comments
|
$$ = append($1, $3)
|
||||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| use_declaration
|
| use_declaration
|
||||||
{
|
{
|
||||||
@ -472,73 +467,84 @@ use_declarations:
|
|||||||
use_declaration:
|
use_declaration:
|
||||||
namespace_name
|
namespace_name
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
// save position
|
},
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Use: &ast.NameName{
|
||||||
$$.GetNode().Position = position.NewNodeListPosition($1)
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
|
},
|
||||||
|
Parts: $1,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| namespace_name T_AS T_STRING
|
| namespace_name T_AS T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
Node: ast.Node{
|
||||||
asAlias := &ast.ParserAs{ast.Node{}, alias}
|
Position: position.NewNodeListTokenPosition($1, $3),
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, asAlias}
|
},
|
||||||
|
Use: &ast.NameName{
|
||||||
// save position
|
Node: ast.Node{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Position: position.NewNodeListPosition($1),
|
||||||
alias.GetNode().Position = position.NewTokenPosition($3)
|
},
|
||||||
asAlias.GetNode().Position = position.NewTokensPosition($2, $3)
|
Parts: $1,
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
},
|
||||||
|
AsTkn: $2,
|
||||||
// save comments
|
Alias: &ast.Identifier{
|
||||||
yylex.(*Parser).setFreeFloating(asAlias, token.Start, $2.SkippedTokens)
|
Node: ast.Node{
|
||||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.SkippedTokens)
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
Value: $3.Value,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name
|
| T_NS_SEPARATOR namespace_name
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
useDeclaration := &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
Node: ast.Node{
|
||||||
$$ = &ast.ParserNsSeparator{ast.Node{}, useDeclaration}
|
Position: position.NewTokenNodeListPosition($1, $2),
|
||||||
|
},
|
||||||
// save position
|
NsSeparatorTkn: $1,
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Use: &ast.NameName{
|
||||||
useDeclaration.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Node: ast.Node{
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Position: position.NewNodeListPosition($2),
|
||||||
|
},
|
||||||
// save comments
|
Parts: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name T_AS T_STRING
|
| T_NS_SEPARATOR namespace_name T_AS T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
alias := &ast.Identifier{ast.Node{}, $4.Value}
|
Node: ast.Node{
|
||||||
asAlias := &ast.ParserAs{ast.Node{}, alias}
|
Position: position.NewTokensPosition($1, $4),
|
||||||
useDeclaration := &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
},
|
||||||
$$ = &ast.ParserNsSeparator{ast.Node{}, useDeclaration}
|
NsSeparatorTkn: $1,
|
||||||
|
Use: &ast.NameName{
|
||||||
// save position
|
Node: ast.Node{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Position: position.NewNodeListPosition($2),
|
||||||
alias.GetNode().Position = position.NewTokenPosition($4)
|
},
|
||||||
asAlias.GetNode().Position = position.NewTokensPosition($3, $4)
|
Parts: $2,
|
||||||
useDeclaration.GetNode().Position = position.NewTokensPosition($1, $4)
|
},
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
AsTkn: $3,
|
||||||
|
Alias: &ast.Identifier{
|
||||||
// save comments
|
Node: ast.Node{
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
Position: position.NewTokenPosition($4),
|
||||||
yylex.(*Parser).setFreeFloating(asAlias, token.Start, $3.SkippedTokens)
|
},
|
||||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.SkippedTokens)
|
Value: $4.Value,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
use_function_declarations:
|
use_function_declarations:
|
||||||
use_function_declarations ',' use_function_declaration
|
use_function_declarations ',' use_function_declaration
|
||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$1[len($1)-1].(*ast.StmtUseDeclaration).CommaTkn = $2
|
||||||
|
|
||||||
// save comments
|
$$ = append($1, $3)
|
||||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| use_function_declaration
|
| use_function_declaration
|
||||||
{
|
{
|
||||||
@ -549,73 +555,84 @@ use_function_declarations:
|
|||||||
use_function_declaration:
|
use_function_declaration:
|
||||||
namespace_name
|
namespace_name
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
// save position
|
},
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Use: &ast.NameName{
|
||||||
$$.GetNode().Position = position.NewNodeListPosition($1)
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
|
},
|
||||||
|
Parts: $1,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| namespace_name T_AS T_STRING
|
| namespace_name T_AS T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
Node: ast.Node{
|
||||||
asAlias := &ast.ParserAs{ast.Node{}, alias}
|
Position: position.NewNodeListTokenPosition($1, $3),
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, asAlias}
|
},
|
||||||
|
Use: &ast.NameName{
|
||||||
// save position
|
Node: ast.Node{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Position: position.NewNodeListPosition($1),
|
||||||
alias.GetNode().Position = position.NewTokenPosition($3)
|
},
|
||||||
asAlias.GetNode().Position = position.NewTokensPosition($2, $3)
|
Parts: $1,
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
},
|
||||||
|
AsTkn: $2,
|
||||||
// save comments
|
Alias: &ast.Identifier{
|
||||||
yylex.(*Parser).setFreeFloating(asAlias, token.Start, $2.SkippedTokens)
|
Node: ast.Node{
|
||||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.SkippedTokens)
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
Value: $3.Value,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name
|
| T_NS_SEPARATOR namespace_name
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
useDeclaration := &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
Node: ast.Node{
|
||||||
$$ = &ast.ParserNsSeparator{ast.Node{}, useDeclaration}
|
Position: position.NewTokenNodeListPosition($1, $2),
|
||||||
|
},
|
||||||
// save position
|
NsSeparatorTkn: $1,
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Use: &ast.NameName{
|
||||||
useDeclaration.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Node: ast.Node{
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Position: position.NewNodeListPosition($2),
|
||||||
|
},
|
||||||
// save comments
|
Parts: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name T_AS T_STRING
|
| T_NS_SEPARATOR namespace_name T_AS T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
alias := &ast.Identifier{ast.Node{}, $4.Value}
|
Node: ast.Node{
|
||||||
asAlias := &ast.ParserAs{ast.Node{}, alias}
|
Position: position.NewTokensPosition($1, $4),
|
||||||
useDeclaration := &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
},
|
||||||
$$ = &ast.ParserNsSeparator{ast.Node{}, useDeclaration}
|
NsSeparatorTkn: $1,
|
||||||
|
Use: &ast.NameName{
|
||||||
// save position
|
Node: ast.Node{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Position: position.NewNodeListPosition($2),
|
||||||
alias.GetNode().Position = position.NewTokenPosition($4)
|
},
|
||||||
asAlias.GetNode().Position = position.NewTokensPosition($3, $4)
|
Parts: $2,
|
||||||
useDeclaration.GetNode().Position = position.NewTokensPosition($1, $4)
|
},
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
AsTkn: $3,
|
||||||
|
Alias: &ast.Identifier{
|
||||||
// save comments
|
Node: ast.Node{
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
Position: position.NewTokenPosition($4),
|
||||||
yylex.(*Parser).setFreeFloating(asAlias, token.Start, $3.SkippedTokens)
|
},
|
||||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.SkippedTokens)
|
Value: $4.Value,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
use_const_declarations:
|
use_const_declarations:
|
||||||
use_const_declarations ',' use_const_declaration
|
use_const_declarations ',' use_const_declaration
|
||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$1[len($1)-1].(*ast.StmtUseDeclaration).CommaTkn = $2
|
||||||
|
|
||||||
// save comments
|
$$ = append($1, $3)
|
||||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| use_const_declaration
|
| use_const_declaration
|
||||||
{
|
{
|
||||||
@ -626,63 +643,75 @@ use_const_declarations:
|
|||||||
use_const_declaration:
|
use_const_declaration:
|
||||||
namespace_name
|
namespace_name
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
// save position
|
},
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Use: &ast.NameName{
|
||||||
$$.GetNode().Position = position.NewNodeListPosition($1)
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
|
},
|
||||||
|
Parts: $1,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| namespace_name T_AS T_STRING
|
| namespace_name T_AS T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
Node: ast.Node{
|
||||||
asAlias := &ast.ParserAs{ast.Node{}, alias}
|
Position: position.NewNodeListTokenPosition($1, $3),
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, asAlias}
|
},
|
||||||
|
Use: &ast.NameName{
|
||||||
// save position
|
Node: ast.Node{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Position: position.NewNodeListPosition($1),
|
||||||
alias.GetNode().Position = position.NewTokenPosition($3)
|
},
|
||||||
asAlias.GetNode().Position = position.NewTokensPosition($2, $3)
|
Parts: $1,
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
},
|
||||||
|
AsTkn: $2,
|
||||||
// save comments
|
Alias: &ast.Identifier{
|
||||||
yylex.(*Parser).setFreeFloating(asAlias, token.Start, $2.SkippedTokens)
|
Node: ast.Node{
|
||||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.SkippedTokens)
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
Value: $3.Value,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name
|
| T_NS_SEPARATOR namespace_name
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
useDeclaration := &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
Node: ast.Node{
|
||||||
$$ = &ast.ParserNsSeparator{ast.Node{}, useDeclaration}
|
Position: position.NewTokenNodeListPosition($1, $2),
|
||||||
|
},
|
||||||
// save position
|
NsSeparatorTkn: $1,
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Use: &ast.NameName{
|
||||||
useDeclaration.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Node: ast.Node{
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Position: position.NewNodeListPosition($2),
|
||||||
|
},
|
||||||
// save comments
|
Parts: $2,
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name T_AS T_STRING
|
| T_NS_SEPARATOR namespace_name T_AS T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
alias := &ast.Identifier{ast.Node{}, $4.Value}
|
Node: ast.Node{
|
||||||
asAlias := &ast.ParserAs{ast.Node{}, alias}
|
Position: position.NewTokensPosition($1, $4),
|
||||||
useDeclaration := &ast.StmtUseDeclaration{ast.Node{}, name, alias}
|
},
|
||||||
$$ = &ast.ParserNsSeparator{ast.Node{}, useDeclaration}
|
NsSeparatorTkn: $1,
|
||||||
|
Use: &ast.NameName{
|
||||||
// save position
|
Node: ast.Node{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Position: position.NewNodeListPosition($2),
|
||||||
alias.GetNode().Position = position.NewTokenPosition($4)
|
},
|
||||||
asAlias.GetNode().Position = position.NewTokensPosition($3, $4)
|
Parts: $2,
|
||||||
useDeclaration.GetNode().Position = position.NewTokensPosition($1, $4)
|
},
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
AsTkn: $3,
|
||||||
|
Alias: &ast.Identifier{
|
||||||
// save comments
|
Node: ast.Node{
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
Position: position.NewTokenPosition($4),
|
||||||
yylex.(*Parser).setFreeFloating(asAlias, token.Start, $3.SkippedTokens)
|
},
|
||||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $4.SkippedTokens)
|
Value: $4.Value,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -8536,15 +8536,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3289,
|
EndPos: 3289,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 154,
|
|
||||||
EndLine: 154,
|
|
||||||
StartPos: 3285,
|
|
||||||
EndPos: 3288,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -8581,7 +8572,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -8591,15 +8581,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3299,
|
EndPos: 3299,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 155,
|
|
||||||
EndLine: 155,
|
|
||||||
StartPos: 3294,
|
|
||||||
EndPos: 3298,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -8636,7 +8617,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -8646,15 +8626,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3316,
|
EndPos: 3316,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 156,
|
|
||||||
EndLine: 156,
|
|
||||||
StartPos: 3304,
|
|
||||||
EndPos: 3315,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -8702,7 +8673,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -8712,15 +8682,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3330,
|
EndPos: 3330,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 157,
|
|
||||||
EndLine: 157,
|
|
||||||
StartPos: 3321,
|
|
||||||
EndPos: 3329,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -8790,7 +8751,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -8800,15 +8760,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3351,
|
EndPos: 3351,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 158,
|
|
||||||
EndLine: 158,
|
|
||||||
StartPos: 3335,
|
|
||||||
EndPos: 3350,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -8889,7 +8840,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -8899,15 +8849,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3375,
|
EndPos: 3375,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 159,
|
|
||||||
EndLine: 159,
|
|
||||||
StartPos: 3356,
|
|
||||||
EndPos: 3374,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -8919,15 +8860,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 159,
|
|
||||||
EndLine: 159,
|
|
||||||
StartPos: 3365,
|
|
||||||
EndPos: 3374,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -8997,8 +8929,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9008,15 +8938,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3413,
|
EndPos: 3413,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 160,
|
|
||||||
EndLine: 160,
|
|
||||||
StartPos: 3380,
|
|
||||||
EndPos: 3412,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9028,15 +8949,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 160,
|
|
||||||
EndLine: 160,
|
|
||||||
StartPos: 3389,
|
|
||||||
EndPos: 3412,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9128,8 +9040,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9139,15 +9049,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3434,
|
EndPos: 3434,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 161,
|
|
||||||
EndLine: 161,
|
|
||||||
StartPos: 3418,
|
|
||||||
EndPos: 3433,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9159,15 +9060,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 161,
|
|
||||||
EndLine: 161,
|
|
||||||
StartPos: 3424,
|
|
||||||
EndPos: 3433,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9237,8 +9129,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9248,15 +9138,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
EndPos: 3469,
|
EndPos: 3469,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 162,
|
|
||||||
EndLine: 162,
|
|
||||||
StartPos: 3439,
|
|
||||||
EndPos: 3468,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9268,15 +9149,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 162,
|
|
||||||
EndLine: 162,
|
|
||||||
StartPos: 3445,
|
|
||||||
EndPos: 3468,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9368,8 +9240,6 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtExpression{
|
&ast.StmtExpression{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
|
@ -12671,15 +12671,6 @@ func TestStmtUse(t *testing.T) {
|
|||||||
EndPos: 11,
|
EndPos: 11,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 10,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12717,7 +12708,6 @@ func TestStmtUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -12751,15 +12741,6 @@ func TestStmtUse_FullyQualified(t *testing.T) {
|
|||||||
EndPos: 12,
|
EndPos: 12,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 11,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12797,7 +12778,6 @@ func TestStmtUse_FullyQualified(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -12831,15 +12811,6 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
|
|||||||
EndPos: 19,
|
EndPos: 19,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 18,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -12888,7 +12859,6 @@ func TestStmtUse_FullyQualifiedAlias(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -12922,15 +12892,6 @@ func TestStmtUse_List(t *testing.T) {
|
|||||||
EndPos: 16,
|
EndPos: 16,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 15,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -13001,7 +12962,6 @@ func TestStmtUse_List(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -13035,15 +12995,6 @@ func TestStmtUse_ListAlias(t *testing.T) {
|
|||||||
EndPos: 23,
|
EndPos: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 22,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -13125,7 +13076,6 @@ func TestStmtUse_ListAlias(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -13159,15 +13109,6 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
|
|||||||
EndPos: 26,
|
EndPos: 26,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 25,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -13179,15 +13120,6 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 16,
|
|
||||||
EndPos: 25,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -13258,8 +13190,6 @@ func TestStmtUse_ListFunctionType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -13293,15 +13223,6 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
|
|||||||
EndPos: 40,
|
EndPos: 40,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 39,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -13313,15 +13234,6 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 16,
|
|
||||||
EndPos: 39,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -13414,8 +13326,6 @@ func TestStmtUse_ListFunctionTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -13449,16 +13359,6 @@ func TestStmtUse_ListConstType(t *testing.T) {
|
|||||||
EndPos: 23,
|
EndPos: 23,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 22,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -13470,15 +13370,6 @@ func TestStmtUse_ListConstType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 13,
|
|
||||||
EndPos: 22,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -13549,8 +13440,6 @@ func TestStmtUse_ListConstType(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -13584,15 +13473,6 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
|
|||||||
EndPos: 37,
|
EndPos: 37,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 36,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -13604,15 +13484,6 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 13,
|
|
||||||
EndPos: 36,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -13705,8 +13576,6 @@ func TestStmtUse_ListConstTypeAliases(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -13731,7 +13600,7 @@ func TestStmtUse_GroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtGroupUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
@ -13740,15 +13609,6 @@ func TestStmtUse_GroupUse(t *testing.T) {
|
|||||||
EndPos: 22,
|
EndPos: 22,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 21,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -13772,15 +13632,6 @@ func TestStmtUse_GroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 12,
|
|
||||||
EndPos: 20,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -13851,8 +13702,6 @@ func TestStmtUse_GroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -13877,7 +13726,7 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtGroupUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
@ -13886,15 +13735,6 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
|
|||||||
EndPos: 30,
|
EndPos: 30,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 29,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -13918,15 +13758,6 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 12,
|
|
||||||
EndPos: 28,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -14008,8 +13839,6 @@ func TestStmtUse_GroupUseAlias(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -14034,7 +13863,7 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtGroupUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
@ -14043,15 +13872,6 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
|
|||||||
EndPos: 31,
|
EndPos: 31,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -14063,15 +13883,6 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 16,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -14095,15 +13906,6 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 21,
|
|
||||||
EndPos: 29,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -14174,9 +13976,6 @@ func TestStmtUse_FunctionGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -14201,7 +14000,7 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtGroupUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
@ -14210,15 +14009,6 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
|
|||||||
EndPos: 28,
|
EndPos: 28,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 27,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -14230,15 +14020,6 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 13,
|
|
||||||
EndPos: 27,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -14262,15 +14043,6 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 18,
|
|
||||||
EndPos: 26,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -14341,9 +14113,6 @@ func TestStmtUse_ConstGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
@ -14368,7 +14137,7 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtGroupUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
@ -14377,15 +14146,6 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
|
|||||||
EndPos: 37,
|
EndPos: 37,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 7,
|
|
||||||
EndPos: 36,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -14409,17 +14169,8 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 12,
|
|
||||||
EndPos: 35,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseType{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
@ -14439,15 +14190,6 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 18,
|
|
||||||
EndPos: 21,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Use: &ast.NameName{
|
Use: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -14472,8 +14214,7 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtUseDeclaration{
|
||||||
&ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 1,
|
StartLine: 1,
|
||||||
@ -14493,15 +14234,6 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 32,
|
|
||||||
EndPos: 35,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Use: &ast.NameName{
|
Use: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -14529,9 +14261,6 @@ func TestStmtUse_MixedGroupUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
lexer := scanner.NewLexer([]byte(src), "7.4", nil)
|
||||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -485,55 +485,47 @@ top_statement:
|
|||||||
}
|
}
|
||||||
| T_USE mixed_group_use_declaration ';'
|
| T_USE mixed_group_use_declaration ';'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtUse{ast.Node{}, $2}
|
use := $2.(*ast.StmtGroupUse)
|
||||||
|
|
||||||
// save position
|
use.Node.Position = position.NewTokensPosition($1, $3)
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
use.UseTkn = $1
|
||||||
|
use.SemiColonTkn = $3
|
||||||
|
|
||||||
// save comments
|
$$ = $2
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_USE use_type group_use_declaration ';'
|
| T_USE use_type group_use_declaration ';'
|
||||||
{
|
{
|
||||||
useType := &ast.StmtUseType{ast.Node{}, $2, $3}
|
use := $3.(*ast.StmtGroupUse)
|
||||||
$$ = &ast.StmtUse{ast.Node{}, useType}
|
|
||||||
|
|
||||||
// save position
|
use.Node.Position = position.NewTokensPosition($1, $4)
|
||||||
useType.GetNode().Position = position.NewNodesPosition($2, $3)
|
use.UseTkn = $1
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
use.Type = $2
|
||||||
|
use.SemiColonTkn = $4
|
||||||
|
|
||||||
// save comments
|
$$ = $3
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_USE use_declarations ';'
|
| T_USE use_declarations ';'
|
||||||
{
|
{
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $2}
|
$$ = &ast.StmtUse{
|
||||||
$$ = &ast.StmtUse{ast.Node{}, useList}
|
Node: ast.Node{
|
||||||
|
Position: position.NewTokensPosition($1, $3),
|
||||||
// save position
|
},
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($2)
|
UseTkn: $1,
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $3)
|
UseDeclarations: $2,
|
||||||
|
SemiColonTkn: $3,
|
||||||
// save comments
|
}
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $3.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_USE use_type use_declarations ';'
|
| T_USE use_type use_declarations ';'
|
||||||
{
|
{
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $3}
|
$$ = &ast.StmtUse{
|
||||||
useType := &ast.StmtUseType{ast.Node{}, $2, useList}
|
Node: ast.Node{
|
||||||
$$ = &ast.StmtUse{ast.Node{}, useType}
|
Position: position.NewTokensPosition($1, $4),
|
||||||
|
},
|
||||||
// save position
|
UseTkn: $1,
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($3)
|
Type: $2,
|
||||||
useType.GetNode().Position = position.NewNodesPosition($2, useList)
|
UseDeclarations: $3,
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $4)
|
SemiColonTkn: $4,
|
||||||
|
}
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens($$, token.End, $4.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_CONST const_list ';'
|
| T_CONST const_list ';'
|
||||||
{
|
{
|
||||||
@ -575,104 +567,90 @@ use_type:
|
|||||||
group_use_declaration:
|
group_use_declaration:
|
||||||
namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
if len($4) > 0 {
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $4}
|
$4[len($4)-1].(*ast.StmtUseDeclaration).CommaTkn = $5
|
||||||
useListBrackets := &ast.ParserBrackets{ast.Node{}, useList}
|
}
|
||||||
useListNsSeparator := &ast.ParserNsSeparator{ast.Node{}, useListBrackets}
|
|
||||||
$$ = &ast.StmtGroupUseList{ast.Node{}, name, useListNsSeparator}
|
$$ = &ast.StmtGroupUse{
|
||||||
|
Node: ast.Node{
|
||||||
// save position
|
Position: position.NewNodeListTokenPosition($1, $6),
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
},
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($4)
|
Prefix: &ast.NameName{
|
||||||
useListBrackets.GetNode().Position = position.NewTokensPosition($3, $6)
|
Node: ast.Node{
|
||||||
useListNsSeparator.GetNode().Position = position.NewTokensPosition($2, $6)
|
Position: position.NewNodeListPosition($1),
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $6)
|
},
|
||||||
|
Parts: $1,
|
||||||
// save comments
|
},
|
||||||
if $5 != nil {
|
NsSeparatorTkn: $2,
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.End, $5.SkippedTokens)
|
OpenCurlyBracketTkn: $3,
|
||||||
|
UseDeclarations: $4,
|
||||||
|
CloseCurlyBracketTkn: $6,
|
||||||
}
|
}
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.Start, $3.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.End, $6.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating(useListNsSeparator, token.Start, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' unprefixed_use_declarations possible_comma '}'
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$5[len($5)-1].(*ast.StmtUseDeclaration).CommaTkn = $6
|
||||||
prefixNsSeparator := &ast.ParserNsSeparator{ast.Node{}, name}
|
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $5}
|
|
||||||
useListBrackets := &ast.ParserBrackets{ast.Node{}, useList}
|
|
||||||
useListNsSeparator := &ast.ParserNsSeparator{ast.Node{}, useListBrackets}
|
|
||||||
$$ = &ast.StmtGroupUseList{ast.Node{}, prefixNsSeparator, useListNsSeparator}
|
|
||||||
|
|
||||||
// save position
|
$$ = &ast.StmtGroupUse{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Node: ast.Node{
|
||||||
prefixNsSeparator.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Position: position.NewTokensPosition($1, $7),
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($5)
|
},
|
||||||
useListBrackets.GetNode().Position = position.NewTokensPosition($4, $7)
|
LeadingNsSeparatorTkn: $1,
|
||||||
useListNsSeparator.GetNode().Position = position.NewTokensPosition($3, $7)
|
Prefix: &ast.NameName{
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $7)
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($2),
|
||||||
// save comments
|
},
|
||||||
yylex.(*Parser).setFreeFloating(prefixNsSeparator, token.Start, $1.SkippedTokens)
|
Parts: $2,
|
||||||
if $6 != nil {
|
},
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.End, $6.SkippedTokens)
|
NsSeparatorTkn: $3,
|
||||||
|
OpenCurlyBracketTkn: $4,
|
||||||
|
UseDeclarations: $5,
|
||||||
|
CloseCurlyBracketTkn: $7,
|
||||||
}
|
}
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.Start, $4.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.End, $7.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating(useListNsSeparator, token.Start, $3.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
mixed_group_use_declaration:
|
mixed_group_use_declaration:
|
||||||
namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$4[len($4)-1].(*ast.StmtUseDeclaration).CommaTkn = $5
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $4}
|
|
||||||
useListBrackets := &ast.ParserBrackets{ast.Node{}, useList}
|
|
||||||
useListNsSeparator := &ast.ParserNsSeparator{ast.Node{}, useListBrackets}
|
|
||||||
$$ = &ast.StmtGroupUseList{ast.Node{}, name, useListNsSeparator}
|
|
||||||
|
|
||||||
// save position
|
$$ = &ast.StmtGroupUse{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Node: ast.Node{
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($4)
|
Position: position.NewNodeListTokenPosition($1, $6),
|
||||||
useListBrackets.GetNode().Position = position.NewTokensPosition($3, $6)
|
},
|
||||||
useListNsSeparator.GetNode().Position = position.NewTokensPosition($2, $6)
|
Prefix: &ast.NameName{
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $6)
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
// save comments
|
},
|
||||||
if $5 != nil {
|
Parts: $1,
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.End, $5.SkippedTokens)
|
},
|
||||||
|
NsSeparatorTkn: $2,
|
||||||
|
OpenCurlyBracketTkn: $3,
|
||||||
|
UseDeclarations: $4,
|
||||||
|
CloseCurlyBracketTkn: $6,
|
||||||
}
|
}
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.Start, $3.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.End, $6.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating(useListNsSeparator, token.Start, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
| T_NS_SEPARATOR namespace_name T_NS_SEPARATOR '{' inline_use_declarations possible_comma '}'
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $2}
|
$5[len($5)-1].(*ast.StmtUseDeclaration).CommaTkn = $6
|
||||||
prefixNsSeparator := &ast.ParserNsSeparator{ast.Node{}, name}
|
|
||||||
useList := &ast.StmtUseList{ast.Node{}, $5}
|
|
||||||
useListBrackets := &ast.ParserBrackets{ast.Node{}, useList}
|
|
||||||
useListNsSeparator := &ast.ParserNsSeparator{ast.Node{}, useListBrackets}
|
|
||||||
$$ = &ast.StmtGroupUseList{ast.Node{}, prefixNsSeparator, useListNsSeparator}
|
|
||||||
|
|
||||||
// save position
|
$$ = &ast.StmtGroupUse{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($2)
|
Node: ast.Node{
|
||||||
prefixNsSeparator.GetNode().Position = position.NewTokenNodePosition($1, name)
|
Position: position.NewTokensPosition($1, $7),
|
||||||
useList.GetNode().Position = position.NewNodeListPosition($5)
|
},
|
||||||
useListBrackets.GetNode().Position = position.NewTokensPosition($4, $7)
|
LeadingNsSeparatorTkn: $1,
|
||||||
useListNsSeparator.GetNode().Position = position.NewTokensPosition($3, $7)
|
Prefix: &ast.NameName{
|
||||||
$$.GetNode().Position = position.NewTokensPosition($1, $7)
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($2),
|
||||||
// save comments
|
},
|
||||||
yylex.(*Parser).setFreeFloating(prefixNsSeparator, token.Start, $1.SkippedTokens)
|
Parts: $2,
|
||||||
if $6 != nil {
|
},
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useList, token.End, $6.SkippedTokens)
|
NsSeparatorTkn: $3,
|
||||||
|
OpenCurlyBracketTkn: $4,
|
||||||
|
UseDeclarations: $5,
|
||||||
|
CloseCurlyBracketTkn: $7,
|
||||||
}
|
}
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.Start, $4.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloatingTokens(useListBrackets, token.End, $7.SkippedTokens)
|
|
||||||
yylex.(*Parser).setFreeFloating(useListNsSeparator, token.Start, $3.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -690,10 +668,9 @@ possible_comma:
|
|||||||
inline_use_declarations:
|
inline_use_declarations:
|
||||||
inline_use_declarations ',' inline_use_declaration
|
inline_use_declarations ',' inline_use_declaration
|
||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$1[len($1)-1].(*ast.StmtUseDeclaration).CommaTkn = $2
|
||||||
|
|
||||||
// save comments
|
$$ = append($1, $3)
|
||||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| inline_use_declaration
|
| inline_use_declaration
|
||||||
{
|
{
|
||||||
@ -704,10 +681,9 @@ inline_use_declarations:
|
|||||||
unprefixed_use_declarations:
|
unprefixed_use_declarations:
|
||||||
unprefixed_use_declarations ',' unprefixed_use_declaration
|
unprefixed_use_declarations ',' unprefixed_use_declaration
|
||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$1[len($1)-1].(*ast.StmtUseDeclaration).CommaTkn = $2
|
||||||
|
|
||||||
// save comments
|
$$ = append($1, $3)
|
||||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| unprefixed_use_declaration
|
| unprefixed_use_declaration
|
||||||
{
|
{
|
||||||
@ -718,10 +694,9 @@ unprefixed_use_declarations:
|
|||||||
use_declarations:
|
use_declarations:
|
||||||
use_declarations ',' use_declaration
|
use_declarations ',' use_declaration
|
||||||
{
|
{
|
||||||
$$ = append($1, $3)
|
$1[len($1)-1].(*ast.StmtUseDeclaration).CommaTkn = $2
|
||||||
|
|
||||||
// save comments
|
$$ = append($1, $3)
|
||||||
yylex.(*Parser).setFreeFloating(lastNode($1), token.End, $2.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
| use_declaration
|
| use_declaration
|
||||||
{
|
{
|
||||||
@ -736,39 +711,49 @@ inline_use_declaration:
|
|||||||
}
|
}
|
||||||
| use_type unprefixed_use_declaration
|
| use_type unprefixed_use_declaration
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtUseType{ast.Node{}, $1, $2}
|
decl := $2.(*ast.StmtUseDeclaration)
|
||||||
|
decl.Type = $1
|
||||||
|
decl.Node.Position = position.NewNodesPosition($1, $2)
|
||||||
|
|
||||||
// save position
|
$$ = $2
|
||||||
$$.GetNode().Position = position.NewNodesPosition($1, $2)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
unprefixed_use_declaration:
|
unprefixed_use_declaration:
|
||||||
namespace_name
|
namespace_name
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, nil}
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
// save position
|
},
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Use: &ast.NameName{
|
||||||
$$.GetNode().Position = position.NewNodePosition(name)
|
Node: ast.Node{
|
||||||
|
Position: position.NewNodeListPosition($1),
|
||||||
|
},
|
||||||
|
Parts: $1,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
| namespace_name T_AS T_STRING
|
| namespace_name T_AS T_STRING
|
||||||
{
|
{
|
||||||
name := &ast.NameName{ast.Node{}, $1}
|
$$ = &ast.StmtUseDeclaration{
|
||||||
alias := &ast.Identifier{ast.Node{}, $3.Value}
|
Node: ast.Node{
|
||||||
asAlias := &ast.ParserAs{ast.Node{}, alias}
|
Position: position.NewNodeListTokenPosition($1, $3),
|
||||||
$$ = &ast.StmtUseDeclaration{ast.Node{}, name, asAlias}
|
},
|
||||||
|
Use: &ast.NameName{
|
||||||
// save position
|
Node: ast.Node{
|
||||||
name.GetNode().Position = position.NewNodeListPosition($1)
|
Position: position.NewNodeListPosition($1),
|
||||||
alias.GetNode().Position = position.NewTokenPosition($3)
|
},
|
||||||
asAlias.GetNode().Position = position.NewTokensPosition($2, $3)
|
Parts: $1,
|
||||||
$$.GetNode().Position = position.NewNodeListTokenPosition($1, $3)
|
},
|
||||||
|
AsTkn: $2,
|
||||||
// save comments
|
Alias: &ast.Identifier{
|
||||||
yylex.(*Parser).setFreeFloating(asAlias, token.Start, $2.SkippedTokens)
|
Node: ast.Node{
|
||||||
yylex.(*Parser).setFreeFloating(alias, token.Start, $3.SkippedTokens)
|
Position: position.NewTokenPosition($3),
|
||||||
|
},
|
||||||
|
Value: $3.Value,
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -779,14 +764,11 @@ use_declaration:
|
|||||||
}
|
}
|
||||||
| T_NS_SEPARATOR unprefixed_use_declaration
|
| T_NS_SEPARATOR unprefixed_use_declaration
|
||||||
{
|
{
|
||||||
$$ = &ast.ParserNsSeparator{ast.Node{}, $2}
|
decl := $2.(*ast.StmtUseDeclaration)
|
||||||
|
decl.NsSeparatorTkn = $1
|
||||||
|
decl.Node.Position = position.NewTokenNodePosition($1, $2)
|
||||||
|
|
||||||
// save position
|
$$ = $2
|
||||||
$2.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
|
||||||
$$.GetNode().Position = position.NewTokenNodePosition($1, $2)
|
|
||||||
|
|
||||||
// save comments
|
|
||||||
yylex.(*Parser).setFreeFloating($$, token.Start, $1.SkippedTokens)
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -9024,15 +9024,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3370,
|
EndPos: 3370,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 161,
|
|
||||||
EndLine: 161,
|
|
||||||
StartPos: 3366,
|
|
||||||
EndPos: 3369,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9069,7 +9060,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9079,15 +9069,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3380,
|
EndPos: 3380,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 162,
|
|
||||||
EndLine: 162,
|
|
||||||
StartPos: 3375,
|
|
||||||
EndPos: 3379,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9124,7 +9105,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9134,15 +9114,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3397,
|
EndPos: 3397,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 163,
|
|
||||||
EndLine: 163,
|
|
||||||
StartPos: 3385,
|
|
||||||
EndPos: 3396,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9190,7 +9161,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9200,15 +9170,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3411,
|
EndPos: 3411,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 164,
|
|
||||||
EndLine: 164,
|
|
||||||
StartPos: 3402,
|
|
||||||
EndPos: 3410,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9278,7 +9239,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9288,15 +9248,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3432,
|
EndPos: 3432,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 165,
|
|
||||||
EndLine: 165,
|
|
||||||
StartPos: 3416,
|
|
||||||
EndPos: 3431,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9377,7 +9328,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9387,15 +9337,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3456,
|
EndPos: 3456,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 166,
|
|
||||||
EndLine: 166,
|
|
||||||
StartPos: 3437,
|
|
||||||
EndPos: 3455,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9407,15 +9348,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 166,
|
|
||||||
EndLine: 166,
|
|
||||||
StartPos: 3446,
|
|
||||||
EndPos: 3455,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9485,8 +9417,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9496,15 +9426,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3494,
|
EndPos: 3494,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 167,
|
|
||||||
EndLine: 167,
|
|
||||||
StartPos: 3461,
|
|
||||||
EndPos: 3493,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9516,15 +9437,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 167,
|
|
||||||
EndLine: 167,
|
|
||||||
StartPos: 3470,
|
|
||||||
EndPos: 3493,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9616,8 +9528,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9627,15 +9537,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3515,
|
EndPos: 3515,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 168,
|
|
||||||
EndLine: 168,
|
|
||||||
StartPos: 3499,
|
|
||||||
EndPos: 3514,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9647,15 +9548,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 168,
|
|
||||||
EndLine: 168,
|
|
||||||
StartPos: 3505,
|
|
||||||
EndPos: 3514,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9725,8 +9617,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9736,15 +9626,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3550,
|
EndPos: 3550,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 169,
|
|
||||||
EndLine: 169,
|
|
||||||
StartPos: 3520,
|
|
||||||
EndPos: 3549,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9756,15 +9637,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 169,
|
|
||||||
EndLine: 169,
|
|
||||||
StartPos: 3526,
|
|
||||||
EndPos: 3549,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9856,9 +9728,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtGroupUse{
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 171,
|
StartLine: 171,
|
||||||
@ -9867,15 +9737,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3572,
|
EndPos: 3572,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 171,
|
|
||||||
EndLine: 171,
|
|
||||||
StartPos: 3556,
|
|
||||||
EndPos: 3571,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -9899,15 +9760,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 171,
|
|
||||||
EndLine: 171,
|
|
||||||
StartPos: 3562,
|
|
||||||
EndPos: 3570,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -9977,9 +9829,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtGroupUse{
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 172,
|
StartLine: 172,
|
||||||
@ -9988,15 +9838,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3600,
|
EndPos: 3600,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 172,
|
|
||||||
EndLine: 172,
|
|
||||||
StartPos: 3577,
|
|
||||||
EndPos: 3599,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10020,15 +9861,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 172,
|
|
||||||
EndLine: 172,
|
|
||||||
StartPos: 3582,
|
|
||||||
EndPos: 3598,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -10109,9 +9941,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtGroupUse{
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 173,
|
StartLine: 173,
|
||||||
@ -10120,15 +9950,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3629,
|
EndPos: 3629,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 173,
|
|
||||||
EndLine: 173,
|
|
||||||
StartPos: 3605,
|
|
||||||
EndPos: 3628,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10140,15 +9961,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 173,
|
|
||||||
EndLine: 173,
|
|
||||||
StartPos: 3614,
|
|
||||||
EndPos: 3628,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10172,15 +9984,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 173,
|
|
||||||
EndLine: 173,
|
|
||||||
StartPos: 3619,
|
|
||||||
EndPos: 3627,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -10250,10 +10053,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtGroupUse{
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 174,
|
StartLine: 174,
|
||||||
@ -10262,15 +10062,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3656,
|
EndPos: 3656,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 174,
|
|
||||||
EndLine: 174,
|
|
||||||
StartPos: 3634,
|
|
||||||
EndPos: 3655,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Type: &ast.Identifier{
|
Type: &ast.Identifier{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10282,15 +10073,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 174,
|
|
||||||
EndLine: 174,
|
|
||||||
StartPos: 3640,
|
|
||||||
EndPos: 3655,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10314,15 +10096,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 174,
|
|
||||||
EndLine: 174,
|
|
||||||
StartPos: 3646,
|
|
||||||
EndPos: 3654,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
@ -10392,10 +10165,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtGroupUse{
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 175,
|
StartLine: 175,
|
||||||
@ -10404,15 +10174,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
EndPos: 3691,
|
EndPos: 3691,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtGroupUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 175,
|
|
||||||
EndLine: 175,
|
|
||||||
StartPos: 3661,
|
|
||||||
EndPos: 3690,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Prefix: &ast.NameName{
|
Prefix: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10436,17 +10197,8 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 175,
|
|
||||||
EndLine: 175,
|
|
||||||
StartPos: 3666,
|
|
||||||
EndPos: 3689,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseType{
|
&ast.StmtUseDeclaration{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 175,
|
StartLine: 175,
|
||||||
@ -10466,15 +10218,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("const"),
|
Value: []byte("const"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 175,
|
|
||||||
EndLine: 175,
|
|
||||||
StartPos: 3672,
|
|
||||||
EndPos: 3675,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Use: &ast.NameName{
|
Use: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10499,8 +10242,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtUseDeclaration{
|
||||||
&ast.StmtUseType{
|
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
StartLine: 175,
|
StartLine: 175,
|
||||||
@ -10520,15 +10262,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
Value: []byte("function"),
|
Value: []byte("function"),
|
||||||
},
|
},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Node: ast.Node{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 175,
|
|
||||||
EndLine: 175,
|
|
||||||
StartPos: 3686,
|
|
||||||
EndPos: 3689,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Use: &ast.NameName{
|
Use: &ast.NameName{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
@ -10555,9 +10288,6 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtExpression{
|
&ast.StmtExpression{
|
||||||
Node: ast.Node{
|
Node: ast.Node{
|
||||||
Position: &position.Position{
|
Position: &position.Position{
|
||||||
|
@ -84,10 +84,8 @@ type NodeVisitor interface {
|
|||||||
StmtTry(n *StmtTry)
|
StmtTry(n *StmtTry)
|
||||||
StmtUnset(n *StmtUnset)
|
StmtUnset(n *StmtUnset)
|
||||||
StmtUse(n *StmtUse)
|
StmtUse(n *StmtUse)
|
||||||
StmtGroupUseList(n *StmtGroupUseList)
|
StmtGroupUse(n *StmtGroupUse)
|
||||||
StmtUseList(n *StmtUseList)
|
|
||||||
StmtUseDeclaration(n *StmtUseDeclaration)
|
StmtUseDeclaration(n *StmtUseDeclaration)
|
||||||
StmtUseType(n *StmtUseType)
|
|
||||||
StmtWhile(n *StmtWhile)
|
StmtWhile(n *StmtWhile)
|
||||||
|
|
||||||
ExprArray(n *ExprArray)
|
ExprArray(n *ExprArray)
|
||||||
|
@ -796,56 +796,49 @@ func (n *StmtUnset) Accept(v NodeVisitor) {
|
|||||||
// StmtUse node
|
// StmtUse node
|
||||||
type StmtUse struct {
|
type StmtUse struct {
|
||||||
Node
|
Node
|
||||||
UseList Vertex
|
UseTkn *token.Token
|
||||||
|
Type Vertex
|
||||||
|
UseDeclarations []Vertex
|
||||||
|
SemiColonTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtUse) Accept(v NodeVisitor) {
|
func (n *StmtUse) Accept(v NodeVisitor) {
|
||||||
v.StmtUse(n)
|
v.StmtUse(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StmtGroupUseList node
|
// StmtGroupUse node
|
||||||
type StmtGroupUseList struct {
|
type StmtGroupUse struct {
|
||||||
Node
|
Node
|
||||||
|
UseTkn *token.Token
|
||||||
|
Type Vertex
|
||||||
|
LeadingNsSeparatorTkn *token.Token
|
||||||
Prefix Vertex
|
Prefix Vertex
|
||||||
UseList Vertex
|
NsSeparatorTkn *token.Token
|
||||||
}
|
OpenCurlyBracketTkn *token.Token
|
||||||
|
|
||||||
func (n *StmtGroupUseList) Accept(v NodeVisitor) {
|
|
||||||
v.StmtGroupUseList(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StmtUseList node
|
|
||||||
type StmtUseList struct {
|
|
||||||
Node
|
|
||||||
UseDeclarations []Vertex
|
UseDeclarations []Vertex
|
||||||
|
CloseCurlyBracketTkn *token.Token
|
||||||
|
SemiColonTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtUseList) Accept(v NodeVisitor) {
|
func (n *StmtGroupUse) Accept(v NodeVisitor) {
|
||||||
v.StmtUseList(n)
|
v.StmtGroupUse(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StmtUseDeclaration node
|
// StmtUseDeclaration node
|
||||||
type StmtUseDeclaration struct {
|
type StmtUseDeclaration struct {
|
||||||
Node
|
Node
|
||||||
|
Type Vertex
|
||||||
|
NsSeparatorTkn *token.Token
|
||||||
Use Vertex
|
Use Vertex
|
||||||
|
AsTkn *token.Token
|
||||||
Alias Vertex
|
Alias Vertex
|
||||||
|
CommaTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtUseDeclaration) Accept(v NodeVisitor) {
|
func (n *StmtUseDeclaration) Accept(v NodeVisitor) {
|
||||||
v.StmtUseDeclaration(n)
|
v.StmtUseDeclaration(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// StmtUseType node
|
|
||||||
type StmtUseType struct {
|
|
||||||
Node
|
|
||||||
Type Vertex
|
|
||||||
Use Vertex
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *StmtUseType) Accept(v NodeVisitor) {
|
|
||||||
v.StmtUseType(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
// StmtWhile node
|
// StmtWhile node
|
||||||
type StmtWhile struct {
|
type StmtWhile struct {
|
||||||
Node
|
Node
|
||||||
|
@ -1150,35 +1150,35 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
if !t.visitor.EnterNode(nn) {
|
if !t.visitor.EnterNode(nn) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if nn.UseList != nil {
|
if nn.Type != nil {
|
||||||
t.visitor.Enter("UseList", true)
|
t.visitor.Enter("Type", true)
|
||||||
t.Traverse(nn.UseList)
|
t.Traverse(nn.Type)
|
||||||
t.visitor.Leave("UseList", true)
|
t.visitor.Leave("Type", true)
|
||||||
}
|
}
|
||||||
case *ast.StmtGroupUseList:
|
if nn.UseDeclarations != nil {
|
||||||
|
t.visitor.Enter("UseDeclarations", false)
|
||||||
|
for _, c := range nn.UseDeclarations {
|
||||||
|
t.Traverse(c)
|
||||||
|
}
|
||||||
|
t.visitor.Leave("UseDeclarations", false)
|
||||||
|
}
|
||||||
|
case *ast.StmtGroupUse:
|
||||||
if nn == nil {
|
if nn == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !t.visitor.EnterNode(nn) {
|
if !t.visitor.EnterNode(nn) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if nn.Type != nil {
|
||||||
|
t.visitor.Enter("Type", true)
|
||||||
|
t.Traverse(nn.Type)
|
||||||
|
t.visitor.Leave("Type", true)
|
||||||
|
}
|
||||||
if nn.Prefix != nil {
|
if nn.Prefix != nil {
|
||||||
t.visitor.Enter("Prefix", true)
|
t.visitor.Enter("Prefix", true)
|
||||||
t.Traverse(nn.Prefix)
|
t.Traverse(nn.Prefix)
|
||||||
t.visitor.Leave("Prefix", true)
|
t.visitor.Leave("Prefix", true)
|
||||||
}
|
}
|
||||||
if nn.UseList != nil {
|
|
||||||
t.visitor.Enter("UseList", true)
|
|
||||||
t.Traverse(nn.UseList)
|
|
||||||
t.visitor.Leave("UseList", true)
|
|
||||||
}
|
|
||||||
case *ast.StmtUseList:
|
|
||||||
if nn == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !t.visitor.EnterNode(nn) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if nn.UseDeclarations != nil {
|
if nn.UseDeclarations != nil {
|
||||||
t.visitor.Enter("UseDeclarations", false)
|
t.visitor.Enter("UseDeclarations", false)
|
||||||
for _, c := range nn.UseDeclarations {
|
for _, c := range nn.UseDeclarations {
|
||||||
@ -1187,23 +1187,6 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
t.visitor.Leave("UseDeclarations", false)
|
t.visitor.Leave("UseDeclarations", false)
|
||||||
}
|
}
|
||||||
case *ast.StmtUseDeclaration:
|
case *ast.StmtUseDeclaration:
|
||||||
if nn == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !t.visitor.EnterNode(nn) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if nn.Use != nil {
|
|
||||||
t.visitor.Enter("Use", true)
|
|
||||||
t.Traverse(nn.Use)
|
|
||||||
t.visitor.Leave("Use", true)
|
|
||||||
}
|
|
||||||
if nn.Alias != nil {
|
|
||||||
t.visitor.Enter("Alias", true)
|
|
||||||
t.Traverse(nn.Alias)
|
|
||||||
t.visitor.Leave("Alias", true)
|
|
||||||
}
|
|
||||||
case *ast.StmtUseType:
|
|
||||||
if nn == nil {
|
if nn == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1220,6 +1203,11 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
t.Traverse(nn.Use)
|
t.Traverse(nn.Use)
|
||||||
t.visitor.Leave("Use", true)
|
t.visitor.Leave("Use", true)
|
||||||
}
|
}
|
||||||
|
if nn.Alias != nil {
|
||||||
|
t.visitor.Enter("Alias", true)
|
||||||
|
t.Traverse(nn.Alias)
|
||||||
|
t.visitor.Leave("Alias", true)
|
||||||
|
}
|
||||||
case *ast.StmtWhile:
|
case *ast.StmtWhile:
|
||||||
if nn == nil {
|
if nn == nil {
|
||||||
return
|
return
|
||||||
|
@ -169,6 +169,28 @@ func (v *Dump) printNode(n *ast.Node) {
|
|||||||
v.print("},\n")
|
v.print("},\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *Dump) printToken(key string, t *token.Token) {
|
||||||
|
if t == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
v.printIndent(v.indent)
|
||||||
|
v.print(key)
|
||||||
|
v.print(": &token.Token{\n")
|
||||||
|
|
||||||
|
v.printIndent(v.indent + 1)
|
||||||
|
v.print("ID: token." + t.ID.String() + ",\n")
|
||||||
|
|
||||||
|
v.printIndent(v.indent + 1)
|
||||||
|
v.print("Value: []byte(" + strconv.Quote(string(t.Value)) + "),\n")
|
||||||
|
|
||||||
|
v.printIndent(v.indent + 1)
|
||||||
|
v.print("Skipped: []byte(" + strconv.Quote(string(t.Skipped)) + "),\n")
|
||||||
|
|
||||||
|
v.printIndent(v.indent)
|
||||||
|
v.print("},\n")
|
||||||
|
}
|
||||||
|
|
||||||
func (v *Dump) Root(n *ast.Root) {
|
func (v *Dump) Root(n *ast.Root) {
|
||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.Root{\n")
|
v.print("&ast.Root{\n")
|
||||||
@ -588,30 +610,30 @@ func (v *Dump) StmtUse(n *ast.StmtUse) {
|
|||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.StmtUse{\n")
|
v.print("&ast.StmtUse{\n")
|
||||||
v.printNode(n.GetNode())
|
v.printNode(n.GetNode())
|
||||||
|
v.printToken("UseTkn", n.UseTkn)
|
||||||
|
v.printToken("SemiColonTkn", n.SemiColonTkn)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dump) StmtGroupUseList(n *ast.StmtGroupUseList) {
|
func (v *Dump) StmtGroupUse(n *ast.StmtGroupUse) {
|
||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.StmtGroupUseList{\n")
|
v.print("&ast.StmtGroupUse{\n")
|
||||||
v.printNode(n.GetNode())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Dump) StmtUseList(n *ast.StmtUseList) {
|
|
||||||
v.printIndentIfNotSingle(v.indent - 1)
|
|
||||||
v.print("&ast.StmtUseList{\n")
|
|
||||||
v.printNode(n.GetNode())
|
v.printNode(n.GetNode())
|
||||||
|
v.printToken("UseTkn", n.UseTkn)
|
||||||
|
v.printToken("LeadingNsSeparatorTkn", n.LeadingNsSeparatorTkn)
|
||||||
|
v.printToken("NsSeparatorTkn", n.NsSeparatorTkn)
|
||||||
|
v.printToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn)
|
||||||
|
v.printToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn)
|
||||||
|
v.printToken("SemiColonTkn", n.SemiColonTkn)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dump) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
|
func (v *Dump) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
|
||||||
v.printIndentIfNotSingle(v.indent - 1)
|
v.printIndentIfNotSingle(v.indent - 1)
|
||||||
v.print("&ast.StmtUseDeclaration{\n")
|
v.print("&ast.StmtUseDeclaration{\n")
|
||||||
v.printNode(n.GetNode())
|
v.printNode(n.GetNode())
|
||||||
}
|
v.printToken("NsSeparatorTkn", n.NsSeparatorTkn)
|
||||||
|
v.printToken("AsTkn", n.AsTkn)
|
||||||
func (v *Dump) StmtUseType(n *ast.StmtUseType) {
|
v.printToken("CommaTkn", n.CommaTkn)
|
||||||
v.printIndentIfNotSingle(v.indent - 1)
|
|
||||||
v.print("&ast.StmtUseType{\n")
|
|
||||||
v.printNode(n.GetNode())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dump) StmtWhile(n *ast.StmtWhile) {
|
func (v *Dump) StmtWhile(n *ast.StmtWhile) {
|
||||||
|
@ -13,34 +13,6 @@ func (v *FilterParserNodes) EnterNode(n ast.Vertex) bool {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *FilterParserNodes) StmtGroupUseList(n *ast.StmtGroupUseList) {
|
|
||||||
if nn, ok := n.Prefix.(*ast.ParserNsSeparator); ok {
|
|
||||||
n.Prefix = nn.Child
|
|
||||||
}
|
|
||||||
|
|
||||||
if nn, ok := n.UseList.(*ast.ParserNsSeparator); ok {
|
|
||||||
n.UseList = nn.Child
|
|
||||||
}
|
|
||||||
|
|
||||||
if nn, ok := n.UseList.(*ast.ParserBrackets); ok {
|
|
||||||
n.UseList = nn.Child
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *FilterParserNodes) StmtUseList(n *ast.StmtUseList) {
|
|
||||||
for k, v := range n.UseDeclarations {
|
|
||||||
if nn, ok := v.(*ast.ParserNsSeparator); ok {
|
|
||||||
n.UseDeclarations[k] = nn.Child
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *FilterParserNodes) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
|
|
||||||
if nn, ok := n.Alias.(*ast.ParserAs); ok {
|
|
||||||
n.Alias = nn.Child
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *FilterParserNodes) StmtAltIf(n *ast.StmtAltIf) {
|
func (v *FilterParserNodes) StmtAltIf(n *ast.StmtAltIf) {
|
||||||
for {
|
for {
|
||||||
if nn, ok := n.Cond.(*ast.ParserBrackets); ok {
|
if nn, ok := n.Cond.(*ast.ParserBrackets); ok {
|
||||||
|
@ -10,5 +10,26 @@ type FilterTokens struct {
|
|||||||
|
|
||||||
func (v *FilterTokens) EnterNode(n ast.Vertex) bool {
|
func (v *FilterTokens) EnterNode(n ast.Vertex) bool {
|
||||||
n.GetNode().Tokens = nil
|
n.GetNode().Tokens = nil
|
||||||
|
n.Accept(v)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (v *FilterTokens) StmtUse(n *ast.StmtUse) {
|
||||||
|
n.UseTkn = nil
|
||||||
|
n.SemiColonTkn = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *FilterTokens) StmtGroupUse(n *ast.StmtGroupUse) {
|
||||||
|
n.UseTkn = nil
|
||||||
|
n.LeadingNsSeparatorTkn = nil
|
||||||
|
n.NsSeparatorTkn = nil
|
||||||
|
n.OpenCurlyBracketTkn = nil
|
||||||
|
n.CloseCurlyBracketTkn = nil
|
||||||
|
n.SemiColonTkn = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *FilterTokens) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
|
||||||
|
n.NsSeparatorTkn = nil
|
||||||
|
n.AsTkn = nil
|
||||||
|
n.CommaTkn = nil
|
||||||
|
}
|
||||||
|
@ -14,8 +14,6 @@ type NamespaceResolver struct {
|
|||||||
ResolvedNames map[ast.Vertex]string
|
ResolvedNames map[ast.Vertex]string
|
||||||
|
|
||||||
goDeep bool
|
goDeep bool
|
||||||
useType string
|
|
||||||
usePrefix []ast.Vertex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNamespaceResolver NamespaceResolver type constructor
|
// NewNamespaceResolver NamespaceResolver type constructor
|
||||||
@ -47,28 +45,28 @@ func (nsr *NamespaceResolver) StmtNamespace(n *ast.StmtNamespace) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nsr *NamespaceResolver) StmtUseType(n *ast.StmtUseType) {
|
func (nsr *NamespaceResolver) StmtUse(n *ast.StmtUse) {
|
||||||
|
useType := ""
|
||||||
if n.Type != nil {
|
if n.Type != nil {
|
||||||
nsr.useType = string(n.Type.(*ast.Identifier).Value)
|
useType = string(n.Type.(*ast.Identifier).Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, nn := range n.UseDeclarations {
|
||||||
|
nsr.AddAlias(useType, nn, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
nsr.goDeep = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nsr *NamespaceResolver) StmtGroupUseList(n *ast.StmtGroupUseList) {
|
func (nsr *NamespaceResolver) StmtGroupUse(n *ast.StmtGroupUse) {
|
||||||
if n.Prefix != nil {
|
useType := ""
|
||||||
nsr.usePrefix = n.Prefix.(*ast.NameName).Parts
|
if n.Type != nil {
|
||||||
}
|
useType = string(n.Type.(*ast.Identifier).Value)
|
||||||
}
|
|
||||||
|
|
||||||
func (nsr *NamespaceResolver) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
|
|
||||||
useNameParts := n.Use.(*ast.NameName).Parts
|
|
||||||
var alias string
|
|
||||||
if n.Alias == nil {
|
|
||||||
alias = string(useNameParts[len(useNameParts)-1].(*ast.NameNamePart).Value)
|
|
||||||
} else {
|
|
||||||
alias = string(n.Alias.(*ast.Identifier).Value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsr.Namespace.AddAlias(nsr.useType, concatNameParts(nsr.usePrefix, useNameParts), alias)
|
for _, nn := range n.UseDeclarations {
|
||||||
|
nsr.AddAlias(useType, nn, n.Prefix.(*ast.NameName).Parts)
|
||||||
|
}
|
||||||
|
|
||||||
nsr.goDeep = false
|
nsr.goDeep = false
|
||||||
}
|
}
|
||||||
@ -215,10 +213,26 @@ func (nsr *NamespaceResolver) LeaveNode(n ast.Vertex) {
|
|||||||
if nn.Stmts != nil {
|
if nn.Stmts != nil {
|
||||||
nsr.Namespace = NewNamespace("")
|
nsr.Namespace = NewNamespace("")
|
||||||
}
|
}
|
||||||
case *ast.StmtUseType:
|
}
|
||||||
nsr.useType = ""
|
}
|
||||||
case *ast.StmtGroupUseList:
|
|
||||||
nsr.usePrefix = nil
|
// AddAlias adds a new alias
|
||||||
|
func (nsr *NamespaceResolver) AddAlias(useType string, nn ast.Vertex, prefix []ast.Vertex) {
|
||||||
|
switch use := nn.(type) {
|
||||||
|
case *ast.StmtUseDeclaration:
|
||||||
|
if use.Type != nil {
|
||||||
|
useType = string(use.Type.(*ast.Identifier).Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
useNameParts := use.Use.(*ast.NameName).Parts
|
||||||
|
var alias string
|
||||||
|
if use.Alias == nil {
|
||||||
|
alias = string(useNameParts[len(useNameParts)-1].(*ast.NameNamePart).Value)
|
||||||
|
} else {
|
||||||
|
alias = string(use.Alias.(*ast.Identifier).Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
nsr.Namespace.AddAlias(useType, concatNameParts(prefix, useNameParts), alias)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,14 +17,12 @@ func TestResolveStaticCall(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.ExprStaticCall{
|
&ast.ExprStaticCall{
|
||||||
Class: nameBC,
|
Class: nameBC,
|
||||||
Call: &ast.Identifier{Value: []byte("foo")},
|
Call: &ast.Identifier{Value: []byte("foo")},
|
||||||
@ -51,14 +49,12 @@ func TestResolveStaticPropertyFetch(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.ExprStaticPropertyFetch{
|
&ast.ExprStaticPropertyFetch{
|
||||||
Class: nameBC,
|
Class: nameBC,
|
||||||
Property: &ast.Identifier{Value: []byte("foo")},
|
Property: &ast.Identifier{Value: []byte("foo")},
|
||||||
@ -84,14 +80,12 @@ func TestResolveClassConstFetch(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.ExprClassConstFetch{
|
&ast.ExprClassConstFetch{
|
||||||
Class: nameBC,
|
Class: nameBC,
|
||||||
ConstantName: &ast.Identifier{Value: []byte("FOO")},
|
ConstantName: &ast.Identifier{Value: []byte("FOO")},
|
||||||
@ -117,14 +111,12 @@ func TestResolveNew(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.ExprNew{
|
&ast.ExprNew{
|
||||||
Class: nameBC,
|
Class: nameBC,
|
||||||
ArgumentList: &ast.ArgumentList{},
|
ArgumentList: &ast.ArgumentList{},
|
||||||
@ -150,14 +142,12 @@ func TestResolveInstanceOf(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.ExprInstanceOf{
|
&ast.ExprInstanceOf{
|
||||||
Expr: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
Expr: &ast.ExprVariable{VarName: &ast.Identifier{Value: []byte("foo")}},
|
||||||
Class: nameBC,
|
Class: nameBC,
|
||||||
@ -186,17 +176,16 @@ func TestResolveInstanceCatch(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
}, &ast.StmtUseDeclaration{
|
},
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameDE,
|
Use: nameDE,
|
||||||
Alias: &ast.Identifier{Value: []byte("F")},
|
Alias: &ast.Identifier{Value: []byte("F")},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtTry{
|
&ast.StmtTry{
|
||||||
Stmts: []ast.Vertex{},
|
Stmts: []ast.Vertex{},
|
||||||
Catches: []ast.Vertex{
|
Catches: []ast.Vertex{
|
||||||
@ -232,17 +221,13 @@ func TestResolveFunctionCall(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Type: &ast.Identifier{Value: []byte("function")},
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.ExprFunctionCall{
|
&ast.ExprFunctionCall{
|
||||||
Function: nameB,
|
Function: nameB,
|
||||||
ArgumentList: &ast.ArgumentList{},
|
ArgumentList: &ast.ArgumentList{},
|
||||||
@ -268,17 +253,13 @@ func TestResolveConstFetch(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Type: &ast.Identifier{Value: []byte("const")},
|
Type: &ast.Identifier{Value: []byte("const")},
|
||||||
Use: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.ExprConstFetch{
|
&ast.ExprConstFetch{
|
||||||
Const: nameB,
|
Const: nameB,
|
||||||
},
|
},
|
||||||
@ -305,42 +286,28 @@ func TestResolveGroupUse(t *testing.T) {
|
|||||||
|
|
||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtGroupUse{
|
||||||
UseList: &ast.StmtGroupUseList{
|
|
||||||
Prefix: nameAB,
|
Prefix: nameAB,
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseType{
|
&ast.StmtUseDeclaration{
|
||||||
Type: &ast.Identifier{Value: []byte("Function")},
|
Type: &ast.Identifier{Value: []byte("Function")},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Use: nameF,
|
Use: nameF,
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtUseDeclaration{
|
||||||
&ast.StmtUseType{
|
|
||||||
Type: &ast.Identifier{Value: []byte("const")},
|
Type: &ast.Identifier{Value: []byte("const")},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Use: nameC,
|
Use: nameC,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
&ast.StmtGroupUse{
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtUse{
|
|
||||||
UseList: &ast.StmtUseType{
|
|
||||||
Type: &ast.Identifier{Value: []byte("Function")},
|
|
||||||
Use: &ast.StmtGroupUseList{
|
|
||||||
Prefix: nameBD,
|
Prefix: nameBD,
|
||||||
UseList: &ast.StmtUseList{
|
Type: &ast.Identifier{Value: []byte("Function")},
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameE,
|
Use: nameE,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.ExprConstFetch{
|
&ast.ExprConstFetch{
|
||||||
Const: nameC,
|
Const: nameC,
|
||||||
},
|
},
|
||||||
@ -381,14 +348,12 @@ func TestResolveTraitUse(t *testing.T) {
|
|||||||
stxTree := &ast.StmtStmtList{
|
stxTree := &ast.StmtStmtList{
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAB,
|
Use: nameAB,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtTraitUse{
|
&ast.StmtTraitUse{
|
||||||
Traits: []ast.Vertex{
|
Traits: []ast.Vertex{
|
||||||
nameB,
|
nameB,
|
||||||
@ -704,14 +669,12 @@ func TestResolveNamespaces(t *testing.T) {
|
|||||||
NamespaceName: namespaceCD,
|
NamespaceName: namespaceCD,
|
||||||
Stmts: []ast.Vertex{
|
Stmts: []ast.Vertex{
|
||||||
&ast.StmtUse{
|
&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: nameAC,
|
Use: nameAC,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.ExprStaticCall{
|
&ast.ExprStaticCall{
|
||||||
Class: relativeNameCE,
|
Class: relativeNameCE,
|
||||||
Call: &ast.Identifier{Value: []byte("foo")},
|
Call: &ast.Identifier{Value: []byte("foo")},
|
||||||
|
@ -282,11 +282,7 @@ func (v *Null) StmtUse(_ *ast.StmtUse) {
|
|||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Null) StmtGroupUseList(_ *ast.StmtGroupUseList) {
|
func (v *Null) StmtGroupUse(_ *ast.StmtGroupUse) {
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Null) StmtUseList(_ *ast.StmtUseList) {
|
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,10 +290,6 @@ func (v *Null) StmtUseDeclaration(_ *ast.StmtUseDeclaration) {
|
|||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Null) StmtUseType(_ *ast.StmtUseType) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Null) StmtWhile(_ *ast.StmtWhile) {
|
func (v *Null) StmtWhile(_ *ast.StmtWhile) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -399,14 +399,10 @@ func (p *PrettyPrinter) printNode(n ast.Vertex) {
|
|||||||
p.printStmtUnset(n)
|
p.printStmtUnset(n)
|
||||||
case *ast.StmtUse:
|
case *ast.StmtUse:
|
||||||
p.printStmtUse(n)
|
p.printStmtUse(n)
|
||||||
case *ast.StmtGroupUseList:
|
case *ast.StmtGroupUse:
|
||||||
p.printStmtGroupUseList(n)
|
p.printStmtGroupUse(n)
|
||||||
case *ast.StmtUseList:
|
|
||||||
p.printStmtUseList(n)
|
|
||||||
case *ast.StmtUseDeclaration:
|
case *ast.StmtUseDeclaration:
|
||||||
p.printStmtUseDeclaration(n)
|
p.printStmtUseDeclaration(n)
|
||||||
case *ast.StmtUseType:
|
|
||||||
p.printStmtUseType(n)
|
|
||||||
case *ast.StmtWhile:
|
case *ast.StmtWhile:
|
||||||
p.printStmtWhile(n)
|
p.printStmtWhile(n)
|
||||||
}
|
}
|
||||||
@ -2139,30 +2135,41 @@ func (p *PrettyPrinter) printStmtUse(n ast.Vertex) {
|
|||||||
|
|
||||||
io.WriteString(p.w, "use ")
|
io.WriteString(p.w, "use ")
|
||||||
|
|
||||||
p.Print(nn.UseList)
|
if nn.Type != nil {
|
||||||
|
p.Print(nn.Type)
|
||||||
|
io.WriteString(p.w, " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
p.joinPrint(", ", nn.UseDeclarations)
|
||||||
|
|
||||||
io.WriteString(p.w, ";")
|
io.WriteString(p.w, ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrettyPrinter) printStmtGroupUseList(n ast.Vertex) {
|
func (p *PrettyPrinter) printStmtGroupUse(n ast.Vertex) {
|
||||||
nn := n.(*ast.StmtGroupUseList)
|
nn := n.(*ast.StmtGroupUse)
|
||||||
|
|
||||||
|
io.WriteString(p.w, "use ")
|
||||||
|
|
||||||
|
if nn.Type != nil {
|
||||||
|
p.Print(nn.Type)
|
||||||
|
io.WriteString(p.w, " ")
|
||||||
|
}
|
||||||
|
|
||||||
p.Print(nn.Prefix)
|
p.Print(nn.Prefix)
|
||||||
|
|
||||||
io.WriteString(p.w, "\\{")
|
io.WriteString(p.w, "\\{")
|
||||||
p.Print(nn.UseList)
|
|
||||||
io.WriteString(p.w, "}")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PrettyPrinter) printStmtUseList(n ast.Vertex) {
|
|
||||||
nn := n.(*ast.StmtUseList)
|
|
||||||
|
|
||||||
p.joinPrint(", ", nn.UseDeclarations)
|
p.joinPrint(", ", nn.UseDeclarations)
|
||||||
|
io.WriteString(p.w, "}")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrettyPrinter) printStmtUseDeclaration(n ast.Vertex) {
|
func (p *PrettyPrinter) printStmtUseDeclaration(n ast.Vertex) {
|
||||||
nn := n.(*ast.StmtUseDeclaration)
|
nn := n.(*ast.StmtUseDeclaration)
|
||||||
|
|
||||||
|
if nn.Type != nil {
|
||||||
|
p.Print(nn.Type)
|
||||||
|
io.WriteString(p.w, " ")
|
||||||
|
}
|
||||||
|
|
||||||
p.Print(nn.Use)
|
p.Print(nn.Use)
|
||||||
|
|
||||||
if nn.Alias != nil {
|
if nn.Alias != nil {
|
||||||
@ -2171,15 +2178,6 @@ func (p *PrettyPrinter) printStmtUseDeclaration(n ast.Vertex) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrettyPrinter) printStmtUseType(n ast.Vertex) {
|
|
||||||
nn := n.(*ast.StmtUseType)
|
|
||||||
|
|
||||||
p.Print(nn.Type)
|
|
||||||
io.WriteString(p.w, " ")
|
|
||||||
|
|
||||||
p.Print(nn.Use)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PrettyPrinter) printStmtWhile(n ast.Vertex) {
|
func (p *PrettyPrinter) printStmtWhile(n ast.Vertex) {
|
||||||
nn := n.(*ast.StmtWhile)
|
nn := n.(*ast.StmtWhile)
|
||||||
|
|
||||||
|
@ -3954,39 +3954,7 @@ func TestPrintUse(t *testing.T) {
|
|||||||
|
|
||||||
p := printer.NewPrettyPrinter(o, " ")
|
p := printer.NewPrettyPrinter(o, " ")
|
||||||
p.Print(&ast.StmtUse{
|
p.Print(&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{},
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
})
|
|
||||||
|
|
||||||
expected := `use ;`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrintStmtGroupUseList(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := printer.NewPrettyPrinter(o, " ")
|
|
||||||
p.Print(&ast.StmtGroupUseList{
|
|
||||||
Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
|
||||||
UseList: &ast.StmtUseList{},
|
|
||||||
})
|
|
||||||
|
|
||||||
expected := `Foo\{}`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrintStmtUseList(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := printer.NewPrettyPrinter(o, " ")
|
|
||||||
p.Print(&ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
@ -3998,7 +3966,33 @@ func TestPrintStmtUseList(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
expected := `Foo as Bar, Baz`
|
expected := `use function Foo as Bar, Baz;`
|
||||||
|
actual := o.String()
|
||||||
|
|
||||||
|
if expected != actual {
|
||||||
|
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPrintStmtGroupUse(t *testing.T) {
|
||||||
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
|
p := printer.NewPrettyPrinter(o, " ")
|
||||||
|
p.Print(&ast.StmtGroupUse{
|
||||||
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
|
Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
|
UseDeclarations: []ast.Vertex{
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
|
Alias: &ast.Identifier{Value: []byte("Bar")},
|
||||||
|
},
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expected := `use function Foo\{Foo as Bar, Baz}`
|
||||||
actual := o.String()
|
actual := o.String()
|
||||||
|
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
@ -4011,28 +4005,9 @@ func TestPrintUseDeclaration(t *testing.T) {
|
|||||||
|
|
||||||
p := printer.NewPrettyPrinter(o, " ")
|
p := printer.NewPrettyPrinter(o, " ")
|
||||||
p.Print(&ast.StmtUseDeclaration{
|
p.Print(&ast.StmtUseDeclaration{
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
|
||||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
|
||||||
})
|
|
||||||
|
|
||||||
expected := `Foo as Bar`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrintUseType(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := printer.NewPrettyPrinter(o, " ")
|
|
||||||
p.Print(&ast.StmtUseType{
|
|
||||||
Type: &ast.Identifier{Value: []byte("function")},
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
Alias: &ast.Identifier{Value: []byte("Bar")},
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expected := `function Foo as Bar`
|
expected := `function Foo as Bar`
|
||||||
|
@ -76,6 +76,23 @@ func (p *Printer) printFreeFloatingOrDefault(n ast.Vertex, pos token.Position, d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Printer) printToken(t *token.Token, def string) {
|
||||||
|
if t != nil {
|
||||||
|
p.w.Write(t.Skipped)
|
||||||
|
p.w.Write(t.Value)
|
||||||
|
p.bufStart = ""
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if def != "" {
|
||||||
|
p.w.Write([]byte(p.bufStart))
|
||||||
|
p.bufStart = ""
|
||||||
|
|
||||||
|
p.w.Write([]byte(def))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (p *Printer) printFreeFloating(n ast.Vertex, pos token.Position) {
|
func (p *Printer) printFreeFloating(n ast.Vertex, pos token.Position) {
|
||||||
if n == nil {
|
if n == nil {
|
||||||
return
|
return
|
||||||
@ -87,7 +104,7 @@ func (p *Printer) printFreeFloating(n ast.Vertex, pos token.Position) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) printNode(n ast.Vertex) {
|
func (p *Printer) printNode(n ast.Vertex) {
|
||||||
switch n.(type) {
|
switch n := n.(type) {
|
||||||
|
|
||||||
// node
|
// node
|
||||||
|
|
||||||
@ -438,14 +455,10 @@ func (p *Printer) printNode(n ast.Vertex) {
|
|||||||
p.printStmtUnset(n)
|
p.printStmtUnset(n)
|
||||||
case *ast.StmtUse:
|
case *ast.StmtUse:
|
||||||
p.printStmtUse(n)
|
p.printStmtUse(n)
|
||||||
case *ast.StmtGroupUseList:
|
case *ast.StmtGroupUse:
|
||||||
p.printStmtGroupUseList(n)
|
p.printStmtGroupUse(n)
|
||||||
case *ast.StmtUseList:
|
|
||||||
p.printStmtUseList(n)
|
|
||||||
case *ast.StmtUseDeclaration:
|
case *ast.StmtUseDeclaration:
|
||||||
p.printStmtUseDeclaration(n)
|
p.printStmtUseDeclaration(n)
|
||||||
case *ast.StmtUseType:
|
|
||||||
p.printStmtUseType(n)
|
|
||||||
case *ast.StmtWhile:
|
case *ast.StmtWhile:
|
||||||
p.printStmtWhile(n)
|
p.printStmtWhile(n)
|
||||||
case *ast.ParserAs:
|
case *ast.ParserAs:
|
||||||
@ -3260,74 +3273,66 @@ func (p *Printer) printStmtUnset(n ast.Vertex) {
|
|||||||
p.printFreeFloating(nn, token.End)
|
p.printFreeFloating(nn, token.End)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) printStmtUse(n ast.Vertex) {
|
func (p *Printer) printStmtUse(n *ast.StmtUse) {
|
||||||
nn := n.(*ast.StmtUse)
|
p.printToken(n.UseTkn, "use")
|
||||||
p.printFreeFloating(nn, token.Start)
|
|
||||||
|
|
||||||
io.WriteString(p.w, "use")
|
|
||||||
|
|
||||||
p.bufStart = " "
|
p.bufStart = " "
|
||||||
p.Print(nn.UseList)
|
p.Print(n.Type)
|
||||||
|
|
||||||
p.printFreeFloatingOrDefault(nn, token.End, ";")
|
p.bufStart = " "
|
||||||
|
p.joinPrint(",", n.UseDeclarations)
|
||||||
|
|
||||||
|
p.printToken(n.SemiColonTkn, ";")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) printStmtGroupUseList(n ast.Vertex) {
|
func (p *Printer) printStmtGroupUse(n *ast.StmtGroupUse) {
|
||||||
nn := n.(*ast.StmtGroupUseList)
|
p.printToken(n.UseTkn, "use")
|
||||||
p.printFreeFloating(nn, token.Start)
|
|
||||||
|
|
||||||
p.Print(nn.Prefix)
|
p.bufStart = " "
|
||||||
|
p.Print(n.Type)
|
||||||
|
|
||||||
if _, ok := nn.UseList.(*ast.ParserNsSeparator); !ok {
|
p.bufStart = " "
|
||||||
io.WriteString(p.w, "\\{")
|
p.printToken(n.LeadingNsSeparatorTkn, "")
|
||||||
|
|
||||||
|
p.Print(n.Prefix)
|
||||||
|
p.printToken(n.NsSeparatorTkn, "\\")
|
||||||
|
p.printToken(n.OpenCurlyBracketTkn, "{")
|
||||||
|
|
||||||
|
for k, v := range n.UseDeclarations {
|
||||||
|
p.Print(v)
|
||||||
|
var def string
|
||||||
|
if k != len(n.UseDeclarations)-1 {
|
||||||
|
def = ","
|
||||||
|
}
|
||||||
|
if decl, ok := v.(*ast.StmtUseDeclaration); ok {
|
||||||
|
p.printToken(decl.CommaTkn, def)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.Print(nn.UseList)
|
p.printToken(n.CloseCurlyBracketTkn, "}")
|
||||||
|
p.printToken(n.SemiColonTkn, ";")
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := nn.UseList.(*ast.ParserNsSeparator); !ok {
|
func (p *Printer) printStmtUseDeclaration(n *ast.StmtUseDeclaration) {
|
||||||
io.WriteString(p.w, "}")
|
p.Print(n.Type)
|
||||||
|
|
||||||
|
if n.Type != nil {
|
||||||
|
p.bufStart = " "
|
||||||
}
|
}
|
||||||
|
|
||||||
p.printFreeFloating(nn, token.End)
|
p.printToken(n.NsSeparatorTkn, "")
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Printer) printStmtUseList(n ast.Vertex) {
|
p.Print(n.Use)
|
||||||
nn := n.(*ast.StmtUseList)
|
|
||||||
p.printFreeFloating(nn, token.Start)
|
|
||||||
|
|
||||||
p.joinPrint(",", nn.UseDeclarations)
|
if n.Alias == nil {
|
||||||
|
return
|
||||||
p.printFreeFloating(nn, token.End)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Printer) printStmtUseDeclaration(n ast.Vertex) {
|
|
||||||
nn := n.(*ast.StmtUseDeclaration)
|
|
||||||
p.printFreeFloating(nn, token.Start)
|
|
||||||
|
|
||||||
p.Print(nn.Use)
|
|
||||||
|
|
||||||
if nn.Alias != nil {
|
|
||||||
if _, ok := nn.Alias.(*ast.ParserAs); !ok {
|
|
||||||
io.WriteString(p.w, " as")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.bufStart = " "
|
p.bufStart = " "
|
||||||
p.Print(nn.Alias)
|
p.printToken(n.AsTkn, "as")
|
||||||
}
|
|
||||||
|
|
||||||
p.printFreeFloating(nn, token.End)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Printer) printStmtUseType(n ast.Vertex) {
|
|
||||||
nn := n.(*ast.StmtUseType)
|
|
||||||
p.printFreeFloating(nn, token.Start)
|
|
||||||
|
|
||||||
p.Print(nn.Type)
|
|
||||||
|
|
||||||
p.bufStart = " "
|
p.bufStart = " "
|
||||||
p.Print(nn.Use)
|
p.Print(n.Alias)
|
||||||
|
|
||||||
p.printFreeFloating(nn, token.End)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Printer) printStmtWhile(n ast.Vertex) {
|
func (p *Printer) printStmtWhile(n ast.Vertex) {
|
||||||
|
@ -1308,7 +1308,8 @@ func TestParseAndPrintPhp5Unset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestParseAndPrintPhp5UseList(t *testing.T) {
|
func TestParseAndPrintPhp5UseList(t *testing.T) {
|
||||||
src := `<?php
|
// TODO: remove ; after <?php
|
||||||
|
src := `<?php ;
|
||||||
use Foo ;
|
use Foo ;
|
||||||
use \ Foo as Bar ;
|
use \ Foo as Bar ;
|
||||||
use function \ Foo as Bar ;
|
use function \ Foo as Bar ;
|
||||||
|
@ -1159,7 +1159,8 @@ func TestParseAndPrintGoto(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestParseAndPrintGroupUse(t *testing.T) {
|
func TestParseAndPrintGroupUse(t *testing.T) {
|
||||||
src := `<?php
|
// TODO: remove ; after <?php
|
||||||
|
src := `<?php ;
|
||||||
use function Foo \ { Bar as Baz , Quuz , } ;
|
use function Foo \ { Bar as Baz , Quuz , } ;
|
||||||
use Foo \ { function Bar as Baz , const Quuz } ;
|
use Foo \ { function Bar as Baz , const Quuz } ;
|
||||||
use \ Foo \ { function Bar as Baz , const Quuz , } ;
|
use \ Foo \ { function Bar as Baz , const Quuz , } ;
|
||||||
@ -1440,7 +1441,8 @@ func TestParseAndPrintUnset(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestParseAndPrintUseList(t *testing.T) {
|
func TestParseAndPrintUseList(t *testing.T) {
|
||||||
src := `<?php
|
// TODO: remove ; after <?php
|
||||||
|
src := `<?php ;
|
||||||
use Foo ;
|
use Foo ;
|
||||||
use \ Foo as Bar ;
|
use \ Foo as Bar ;
|
||||||
use function \ Foo as Bar ;
|
use function \ Foo as Bar ;
|
||||||
|
@ -4391,45 +4391,7 @@ func TestPrinterPrintUse(t *testing.T) {
|
|||||||
|
|
||||||
p := printer.NewPrinter(o)
|
p := printer.NewPrinter(o)
|
||||||
p.Print(&ast.StmtUse{
|
p.Print(&ast.StmtUse{
|
||||||
UseList: &ast.StmtUseList{
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
UseDeclarations: []ast.Vertex{
|
|
||||||
&ast.StmtUseDeclaration{
|
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
expected := `use Foo;`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrinterPrintStmtGroupUseList(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := printer.NewPrinter(o)
|
|
||||||
p.Print(&ast.StmtGroupUseList{
|
|
||||||
Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
|
||||||
UseList: &ast.StmtUseList{},
|
|
||||||
})
|
|
||||||
|
|
||||||
expected := `Foo\{}`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrinterPrintStmtUseList(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := printer.NewPrinter(o)
|
|
||||||
p.Print(&ast.StmtUseList{
|
|
||||||
UseDeclarations: []ast.Vertex{
|
UseDeclarations: []ast.Vertex{
|
||||||
&ast.StmtUseDeclaration{
|
&ast.StmtUseDeclaration{
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
@ -4441,7 +4403,33 @@ func TestPrinterPrintStmtUseList(t *testing.T) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
expected := `Foo as Bar,Baz`
|
expected := `use function Foo as Bar,Baz;`
|
||||||
|
actual := o.String()
|
||||||
|
|
||||||
|
if expected != actual {
|
||||||
|
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPrinterPrintStmtGroupUse(t *testing.T) {
|
||||||
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
|
p := printer.NewPrinter(o)
|
||||||
|
p.Print(&ast.StmtGroupUse{
|
||||||
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
|
Prefix: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
|
UseDeclarations: []ast.Vertex{
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
|
Alias: &ast.Identifier{Value: []byte("Bar")},
|
||||||
|
},
|
||||||
|
&ast.StmtUseDeclaration{
|
||||||
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Baz")}}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
expected := `use function Foo\{Foo as Bar,Baz};`
|
||||||
actual := o.String()
|
actual := o.String()
|
||||||
|
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
@ -4454,28 +4442,9 @@ func TestPrinterPrintUseDeclaration(t *testing.T) {
|
|||||||
|
|
||||||
p := printer.NewPrinter(o)
|
p := printer.NewPrinter(o)
|
||||||
p.Print(&ast.StmtUseDeclaration{
|
p.Print(&ast.StmtUseDeclaration{
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
|
||||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
|
||||||
})
|
|
||||||
|
|
||||||
expected := `Foo as Bar`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrinterPrintUseType(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := printer.NewPrinter(o)
|
|
||||||
p.Print(&ast.StmtUseType{
|
|
||||||
Type: &ast.Identifier{Value: []byte("function")},
|
Type: &ast.Identifier{Value: []byte("function")},
|
||||||
Use: &ast.StmtUseDeclaration{
|
|
||||||
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
Use: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
Alias: &ast.Identifier{Value: []byte("Bar")},
|
Alias: &ast.Identifier{Value: []byte("Bar")},
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
expected := `function Foo as Bar`
|
expected := `function Foo as Bar`
|
||||||
|
Loading…
Reference in New Issue
Block a user