create TraitAdaptationList node
This commit is contained in:
parent
8fc4c60bfe
commit
f8d9d6d7c2
42
node/stmt/n_trait_adaptation_list.go
Normal file
42
node/stmt/n_trait_adaptation_list.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
package stmt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/z7zmey/php-parser/node"
|
||||||
|
"github.com/z7zmey/php-parser/walker"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TraitAdaptationList node
|
||||||
|
type TraitAdaptationList struct {
|
||||||
|
Adaptations []node.Node
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewTraitAdaptationList node constructor
|
||||||
|
func NewTraitAdaptationList(Adaptations []node.Node) *TraitAdaptationList {
|
||||||
|
return &TraitAdaptationList{
|
||||||
|
Adaptations,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attributes returns node attributes as map
|
||||||
|
func (n *TraitAdaptationList) Attributes() map[string]interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Walk traverses nodes
|
||||||
|
// Walk is invoked recursively until v.EnterNode returns true
|
||||||
|
func (n *TraitAdaptationList) Walk(v walker.Visitor) {
|
||||||
|
if v.EnterNode(n) == false {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if n.Adaptations != nil {
|
||||||
|
vv := v.GetChildrenVisitor("Adaptations")
|
||||||
|
for _, nn := range n.Adaptations {
|
||||||
|
if nn != nil {
|
||||||
|
nn.Walk(vv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
v.LeaveNode(n)
|
||||||
|
}
|
@ -8,14 +8,14 @@ import (
|
|||||||
// TraitUse node
|
// TraitUse node
|
||||||
type TraitUse struct {
|
type TraitUse struct {
|
||||||
Traits []node.Node
|
Traits []node.Node
|
||||||
Adaptations []node.Node
|
TraitAdaptationList *TraitAdaptationList
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTraitUse node constructor
|
// NewTraitUse node constructor
|
||||||
func NewTraitUse(Traits []node.Node, Adaptations []node.Node) *TraitUse {
|
func NewTraitUse(Traits []node.Node, InnerAdaptationList *TraitAdaptationList) *TraitUse {
|
||||||
return &TraitUse{
|
return &TraitUse{
|
||||||
Traits,
|
Traits,
|
||||||
Adaptations,
|
InnerAdaptationList,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,13 +40,9 @@ func (n *TraitUse) Walk(v walker.Visitor) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if n.Adaptations != nil {
|
if n.TraitAdaptationList != nil {
|
||||||
vv := v.GetChildrenVisitor("Adaptations")
|
vv := v.GetChildrenVisitor("TraitAdaptationList")
|
||||||
for _, nn := range n.Adaptations {
|
n.TraitAdaptationList.Walk(vv)
|
||||||
if nn != nil {
|
|
||||||
nn.Walk(vv)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
v.LeaveNode(n)
|
v.LeaveNode(n)
|
||||||
|
@ -2,9 +2,10 @@ package stmt_test
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"github.com/z7zmey/php-parser/node/name"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/z7zmey/php-parser/node/name"
|
||||||
|
|
||||||
"github.com/z7zmey/php-parser/node"
|
"github.com/z7zmey/php-parser/node"
|
||||||
"github.com/z7zmey/php-parser/node/stmt"
|
"github.com/z7zmey/php-parser/node/stmt"
|
||||||
"github.com/z7zmey/php-parser/php5"
|
"github.com/z7zmey/php-parser/php5"
|
||||||
@ -106,6 +107,7 @@ func TestTraitsUseEmptyAdaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -145,6 +147,7 @@ func TestTraitsUseModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -157,6 +160,7 @@ func TestTraitsUseModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||||
@ -192,6 +196,7 @@ func TestTraitsUseAliasModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -205,6 +210,7 @@ func TestTraitsUseAliasModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||||
@ -240,6 +246,7 @@ func TestTraitsUseAdaptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUsePrecedence{
|
&stmt.TraitUsePrecedence{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -279,6 +286,7 @@ func TestTraitsUseAdaptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
php7parser := php7.NewParser(bytes.NewBufferString(src), "test.php")
|
||||||
|
@ -409,9 +409,9 @@ var nodesToTest = []struct {
|
|||||||
{
|
{
|
||||||
&stmt.TraitUse{
|
&stmt.TraitUse{
|
||||||
Traits: []node.Node{&stmt.Expression{}},
|
Traits: []node.Node{&stmt.Expression{}},
|
||||||
Adaptations: []node.Node{&stmt.Expression{}},
|
TraitAdaptationList: &stmt.TraitAdaptationList{},
|
||||||
},
|
},
|
||||||
[]string{"Traits", "Adaptations"},
|
[]string{"Traits", "TraitAdaptationList"},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -479,6 +479,13 @@ var nodesToTest = []struct {
|
|||||||
[]string{"Stmts"},
|
[]string{"Stmts"},
|
||||||
map[string]interface{}{},
|
map[string]interface{}{},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
&stmt.TraitAdaptationList{
|
||||||
|
Adaptations: []node.Node{&stmt.TraitUsePrecedence{}},
|
||||||
|
},
|
||||||
|
[]string{"Adaptations"},
|
||||||
|
map[string]interface{}{},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type visitorMock struct {
|
type visitorMock struct {
|
||||||
|
1284
php5/php5.go
1284
php5/php5.go
File diff suppressed because it is too large
Load Diff
27
php5/php5.y
27
php5/php5.y
@ -243,6 +243,7 @@ import (
|
|||||||
%type <node> trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method
|
%type <node> trait_method_reference_fully_qualified trait_method_reference trait_modifiers member_modifier method
|
||||||
%type <node> static_scalar_value static_operation
|
%type <node> static_scalar_value static_operation
|
||||||
%type <node> ctor_arguments function_call_parameter_list
|
%type <node> ctor_arguments function_call_parameter_list
|
||||||
|
%type <node> trait_adaptations
|
||||||
|
|
||||||
%type <list> top_statement_list namespace_name use_declarations use_function_declarations use_const_declarations
|
%type <list> top_statement_list namespace_name use_declarations use_function_declarations use_const_declarations
|
||||||
%type <list> inner_statement_list global_var_list static_var_list encaps_list isset_variables non_empty_array_pair_list
|
%type <list> inner_statement_list global_var_list static_var_list encaps_list isset_variables non_empty_array_pair_list
|
||||||
@ -259,7 +260,7 @@ import (
|
|||||||
|
|
||||||
%type <simpleIndirectReference> simple_indirect_reference
|
%type <simpleIndirectReference> simple_indirect_reference
|
||||||
%type <foreachVariable> foreach_variable foreach_optional_arg
|
%type <foreachVariable> foreach_variable foreach_optional_arg
|
||||||
%type <nodesWithEndToken> switch_case_list method_body trait_adaptations
|
%type <nodesWithEndToken> switch_case_list method_body
|
||||||
%type <boolWithToken> is_reference is_variadic
|
%type <boolWithToken> is_reference is_variadic
|
||||||
%type <altSyntaxNode> while_statement for_statement foreach_statement
|
%type <altSyntaxNode> while_statement for_statement foreach_statement
|
||||||
|
|
||||||
@ -1550,8 +1551,16 @@ class_statement:
|
|||||||
trait_use_statement:
|
trait_use_statement:
|
||||||
T_USE trait_list trait_adaptations
|
T_USE trait_list trait_adaptations
|
||||||
{
|
{
|
||||||
$$ = stmt.NewTraitUse($2, $3.nodes)
|
var adaptationList *stmt.TraitAdaptationList
|
||||||
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3.endToken))
|
switch n := $3.(type) {
|
||||||
|
case *stmt.TraitAdaptationList:
|
||||||
|
adaptationList = n
|
||||||
|
default:
|
||||||
|
adaptationList = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
$$ = stmt.NewTraitUse($2, adaptationList)
|
||||||
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3))
|
||||||
yylex.(*Parser).comments.AddComments($$, $1.Comments())
|
yylex.(*Parser).comments.AddComments($$, $1.Comments())
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
@ -1565,9 +1574,17 @@ trait_list:
|
|||||||
|
|
||||||
trait_adaptations:
|
trait_adaptations:
|
||||||
';'
|
';'
|
||||||
{ $$ = &nodesWithEndToken{nil, $1} }
|
{
|
||||||
|
$$ = stmt.NewNop()
|
||||||
|
|
||||||
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1))
|
||||||
|
}
|
||||||
| '{' trait_adaptation_list '}'
|
| '{' trait_adaptation_list '}'
|
||||||
{ $$ = &nodesWithEndToken{$2, $3} }
|
{
|
||||||
|
$$ = stmt.NewTraitAdaptationList($2)
|
||||||
|
|
||||||
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
trait_adaptation_list:
|
trait_adaptation_list:
|
||||||
|
@ -1455,6 +1455,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1475,6 +1476,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -1486,6 +1488,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
ClassName: &node.Identifier{Value: "Foo"},
|
ClassName: &node.Identifier{Value: "Foo"},
|
||||||
@ -1503,6 +1506,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -1515,6 +1519,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
ClassName: &node.Identifier{Value: "Foo"},
|
ClassName: &node.Identifier{Value: "Foo"},
|
||||||
@ -1532,6 +1537,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUsePrecedence{
|
&stmt.TraitUsePrecedence{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -1570,6 +1576,7 @@ func TestPhp5(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
Catches: []node.Node{},
|
Catches: []node.Node{},
|
||||||
|
1058
php7/php7.go
1058
php7/php7.go
File diff suppressed because it is too large
Load Diff
47
php7/php7.y
47
php7/php7.y
@ -264,12 +264,13 @@ import (
|
|||||||
%type <node> isset_variable type return_type type_expr
|
%type <node> isset_variable type return_type type_expr
|
||||||
%type <node> class_modifier
|
%type <node> class_modifier
|
||||||
%type <node> argument_list ctor_arguments
|
%type <node> argument_list ctor_arguments
|
||||||
|
%type <node> trait_adaptations
|
||||||
|
|
||||||
%type <node> member_modifier
|
%type <node> member_modifier
|
||||||
%type <node> use_type
|
%type <node> use_type
|
||||||
%type <foreachVariable> foreach_variable
|
%type <foreachVariable> foreach_variable
|
||||||
|
|
||||||
%type <nodesWithEndToken> method_body switch_case_list trait_adaptations
|
%type <nodesWithEndToken> method_body switch_case_list
|
||||||
|
|
||||||
%type <list> encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list
|
%type <list> encaps_list backticks_expr namespace_name catch_name_list catch_list class_const_list
|
||||||
%type <list> const_list echo_expr_list for_exprs non_empty_for_exprs global_var_list
|
%type <list> const_list echo_expr_list for_exprs non_empty_for_exprs global_var_list
|
||||||
@ -1864,10 +1865,20 @@ class_statement:
|
|||||||
}
|
}
|
||||||
| T_USE name_list trait_adaptations
|
| T_USE name_list trait_adaptations
|
||||||
{
|
{
|
||||||
$$ = stmt.NewTraitUse($2, $3.nodes)
|
var adaptationList *stmt.TraitAdaptationList
|
||||||
|
|
||||||
|
switch n := $3.(type) {
|
||||||
|
case *stmt.TraitAdaptationList:
|
||||||
|
adaptationList = n
|
||||||
|
default:
|
||||||
|
adaptationList = nil
|
||||||
|
yylex.(*Parser).comments.AddFromChildNode($$, $3)
|
||||||
|
}
|
||||||
|
|
||||||
|
$$ = stmt.NewTraitUse($2, adaptationList)
|
||||||
|
|
||||||
// save position
|
// save position
|
||||||
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3.endToken))
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenNodePosition($1, $3))
|
||||||
|
|
||||||
// save comments
|
// save comments
|
||||||
yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken)
|
yylex.(*Parser).comments.AddFromToken($$, $1, comment.UseToken)
|
||||||
@ -1906,11 +1917,35 @@ name_list:
|
|||||||
|
|
||||||
trait_adaptations:
|
trait_adaptations:
|
||||||
';'
|
';'
|
||||||
{ $$ = &nodesWithEndToken{nil, $1} }
|
{
|
||||||
|
$$ = stmt.NewNop()
|
||||||
|
|
||||||
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokenPosition($1))
|
||||||
|
|
||||||
|
// save comments
|
||||||
|
yylex.(*Parser).comments.AddFromToken($$, $1, comment.SemiColonToken)
|
||||||
|
|
||||||
|
}
|
||||||
| '{' '}'
|
| '{' '}'
|
||||||
{ $$ = &nodesWithEndToken{nil, $2} }
|
{
|
||||||
|
$$ = stmt.NewTraitAdaptationList(nil)
|
||||||
|
|
||||||
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $2))
|
||||||
|
|
||||||
|
// save comments
|
||||||
|
yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken)
|
||||||
|
yylex.(*Parser).comments.AddFromToken($$, $2, comment.CloseCurlyBracesToken)
|
||||||
|
}
|
||||||
| '{' trait_adaptation_list '}'
|
| '{' trait_adaptation_list '}'
|
||||||
{ $$ = &nodesWithEndToken{$2, $3} }
|
{
|
||||||
|
$$ = stmt.NewTraitAdaptationList($2)
|
||||||
|
|
||||||
|
yylex.(*Parser).positions.AddPosition($$, yylex.(*Parser).positionBuilder.NewTokensPosition($1, $3))
|
||||||
|
|
||||||
|
// save comments
|
||||||
|
yylex.(*Parser).comments.AddFromToken($$, $1, comment.OpenCurlyBracesToken)
|
||||||
|
yylex.(*Parser).comments.AddFromToken($$, $3, comment.CloseCurlyBracesToken)
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
trait_adaptation_list:
|
trait_adaptation_list:
|
||||||
|
@ -1482,6 +1482,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1502,6 +1503,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -1513,6 +1515,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
ClassName: &node.Identifier{Value: "Foo"},
|
ClassName: &node.Identifier{Value: "Foo"},
|
||||||
@ -1530,6 +1533,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -1541,6 +1545,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
ClassName: &node.Identifier{Value: "Foo"},
|
ClassName: &node.Identifier{Value: "Foo"},
|
||||||
@ -1558,6 +1563,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -1570,6 +1576,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
&stmt.Class{
|
&stmt.Class{
|
||||||
PhpDocComment: "",
|
PhpDocComment: "",
|
||||||
ClassName: &node.Identifier{Value: "Foo"},
|
ClassName: &node.Identifier{Value: "Foo"},
|
||||||
@ -1587,6 +1594,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUsePrecedence{
|
&stmt.TraitUsePrecedence{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -1625,6 +1633,7 @@ func TestPhp7(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
&stmt.Try{
|
&stmt.Try{
|
||||||
Stmts: []node.Node{},
|
Stmts: []node.Node{},
|
||||||
Catches: []node.Node{},
|
Catches: []node.Node{},
|
||||||
|
@ -2066,9 +2066,10 @@ func (p *Printer) printStmtTraitUse(n node.Node) {
|
|||||||
io.WriteString(p.w, "use ")
|
io.WriteString(p.w, "use ")
|
||||||
p.joinPrint(", ", nn.Traits)
|
p.joinPrint(", ", nn.Traits)
|
||||||
|
|
||||||
if nn.Adaptations != nil {
|
if nn.TraitAdaptationList != nil {
|
||||||
|
adaptations := nn.TraitAdaptationList.Adaptations
|
||||||
io.WriteString(p.w, " {\n")
|
io.WriteString(p.w, " {\n")
|
||||||
p.printNodes(nn.Adaptations)
|
p.printNodes(adaptations)
|
||||||
io.WriteString(p.w, "\n")
|
io.WriteString(p.w, "\n")
|
||||||
p.printIndent()
|
p.printIndent()
|
||||||
io.WriteString(p.w, "}")
|
io.WriteString(p.w, "}")
|
||||||
|
@ -3789,6 +3789,7 @@ func TestPrintStmtTraitAdaptations(t *testing.T) {
|
|||||||
&name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
|
&name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
|
||||||
&name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
|
&name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUseAlias{
|
&stmt.TraitUseAlias{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -3800,6 +3801,7 @@ func TestPrintStmtTraitAdaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
expected := `namespace {
|
expected := `namespace {
|
||||||
|
@ -152,7 +152,7 @@ func (nsr *NamespaceResolver) EnterNode(w walker.Walkable) bool {
|
|||||||
nsr.ResolveName(t, "")
|
nsr.ResolveName(t, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range n.Adaptations {
|
for _, a := range n.TraitAdaptationList.Adaptations {
|
||||||
switch aa := a.(type) {
|
switch aa := a.(type) {
|
||||||
case *stmt.TraitUsePrecedence:
|
case *stmt.TraitUsePrecedence:
|
||||||
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
||||||
|
@ -368,6 +368,7 @@ func TestResolveTraitUse(t *testing.T) {
|
|||||||
nameB,
|
nameB,
|
||||||
relativeNameB,
|
relativeNameB,
|
||||||
},
|
},
|
||||||
|
TraitAdaptationList: &stmt.TraitAdaptationList{
|
||||||
Adaptations: []node.Node{
|
Adaptations: []node.Node{
|
||||||
&stmt.TraitUsePrecedence{
|
&stmt.TraitUsePrecedence{
|
||||||
Ref: &stmt.TraitMethodRef{
|
Ref: &stmt.TraitMethodRef{
|
||||||
@ -386,6 +387,7 @@ func TestResolveTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
expected := map[node.Node]string{
|
expected := map[node.Node]string{
|
||||||
|
Loading…
Reference in New Issue
Block a user