refactoring: remove StmtTraitAdaptationList node
This commit is contained in:
parent
74b0949255
commit
03c7979ccd
@ -23235,13 +23235,6 @@ func TestStmtTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtNop{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 22,
|
|
||||||
EndPos: 23,
|
|
||||||
},
|
|
||||||
SemiColonTkn: &token.Token{
|
SemiColonTkn: &token.Token{
|
||||||
ID: token.ID(59),
|
ID: token.ID(59),
|
||||||
Value: []byte(";"),
|
Value: []byte(";"),
|
||||||
@ -23254,7 +23247,6 @@ func TestStmtTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -23518,13 +23510,6 @@ func TestStmtTraitUse_Uses(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtNop{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 27,
|
|
||||||
EndPos: 28,
|
|
||||||
},
|
|
||||||
SemiColonTkn: &token.Token{
|
SemiColonTkn: &token.Token{
|
||||||
ID: token.ID(59),
|
ID: token.ID(59),
|
||||||
Value: []byte(";"),
|
Value: []byte(";"),
|
||||||
@ -23537,7 +23522,6 @@ func TestStmtTraitUse_Uses(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -23801,13 +23785,6 @@ func TestStmtTraitUse_EmptyAdaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -23842,7 +23819,6 @@ func TestStmtTraitUse_EmptyAdaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -24106,13 +24082,6 @@ func TestStmtTraitUse_Modifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 46,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -24271,7 +24240,6 @@ func TestStmtTraitUse_Modifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -24535,13 +24503,6 @@ func TestStmtTraitUse_AliasModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 50,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -24731,7 +24692,6 @@ func TestStmtTraitUse_AliasModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -24995,13 +24955,6 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 78,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -25413,7 +25366,6 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
|
BIN
internal/php5/php5.go
generated
BIN
internal/php5/php5.go
generated
Binary file not shown.
@ -2150,13 +2150,23 @@ class_statement:
|
|||||||
trait_use_statement:
|
trait_use_statement:
|
||||||
T_USE trait_list trait_adaptations
|
T_USE trait_list trait_adaptations
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUse{
|
traitUse := &ast.StmtTraitUse{
|
||||||
Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3),
|
Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3),
|
||||||
UseTkn: $1,
|
UseTkn: $1,
|
||||||
Traits: $2.(*ast.ParserSeparatedList).Items,
|
Traits: $2.(*ast.ParserSeparatedList).Items,
|
||||||
SeparatorTkns: $2.(*ast.ParserSeparatedList).SeparatorTkns,
|
SeparatorTkns: $2.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||||
Adaptations: $3,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch n := $3.(type) {
|
||||||
|
case *ast.TraitAdaptationList :
|
||||||
|
traitUse.OpenCurlyBracketTkn = n.OpenCurlyBracketTkn
|
||||||
|
traitUse.Adaptations = n.Adaptations
|
||||||
|
traitUse.CloseCurlyBracketTkn = n.CloseCurlyBracketTkn
|
||||||
|
case *ast.StmtNop :
|
||||||
|
traitUse.SemiColonTkn = n.SemiColonTkn
|
||||||
|
};
|
||||||
|
|
||||||
|
$$ = traitUse
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2186,7 +2196,7 @@ trait_adaptations:
|
|||||||
}
|
}
|
||||||
| '{' trait_adaptation_list '}'
|
| '{' trait_adaptation_list '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitAdaptationList{
|
$$ = &ast.TraitAdaptationList{
|
||||||
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
|
||||||
OpenCurlyBracketTkn: $1,
|
OpenCurlyBracketTkn: $1,
|
||||||
Adaptations: $2,
|
Adaptations: $2,
|
||||||
|
@ -25219,13 +25219,6 @@ func TestStmtTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtNop{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 22,
|
|
||||||
EndPos: 23,
|
|
||||||
},
|
|
||||||
SemiColonTkn: &token.Token{
|
SemiColonTkn: &token.Token{
|
||||||
ID: token.ID(59),
|
ID: token.ID(59),
|
||||||
Value: []byte(";"),
|
Value: []byte(";"),
|
||||||
@ -25238,7 +25231,6 @@ func TestStmtTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -25502,13 +25494,6 @@ func TestStmtTraitUse_Uses(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtNop{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 27,
|
|
||||||
EndPos: 28,
|
|
||||||
},
|
|
||||||
SemiColonTkn: &token.Token{
|
SemiColonTkn: &token.Token{
|
||||||
ID: token.ID(59),
|
ID: token.ID(59),
|
||||||
Value: []byte(";"),
|
Value: []byte(";"),
|
||||||
@ -25521,7 +25506,6 @@ func TestStmtTraitUse_Uses(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -25785,13 +25769,6 @@ func TestStmtTraitUse_EmptyAdaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 30,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -25826,7 +25803,6 @@ func TestStmtTraitUse_EmptyAdaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -26090,13 +26066,6 @@ func TestStmtTraitUse_Modifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 46,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -26255,7 +26224,6 @@ func TestStmtTraitUse_Modifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -26519,13 +26487,6 @@ func TestStmtTraitUse_AliasModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 50,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -26715,7 +26676,6 @@ func TestStmtTraitUse_AliasModifier(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
@ -26979,13 +26939,6 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Position: &position.Position{
|
|
||||||
StartLine: 1,
|
|
||||||
EndLine: 1,
|
|
||||||
StartPos: 28,
|
|
||||||
EndPos: 78,
|
|
||||||
},
|
|
||||||
OpenCurlyBracketTkn: &token.Token{
|
OpenCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(123),
|
ID: token.ID(123),
|
||||||
Value: []byte("{"),
|
Value: []byte("{"),
|
||||||
@ -27397,7 +27350,6 @@ func TestStmtTraitUse_Adaptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
CloseCurlyBracketTkn: &token.Token{
|
CloseCurlyBracketTkn: &token.Token{
|
||||||
ID: token.ID(125),
|
ID: token.ID(125),
|
||||||
Value: []byte("}"),
|
Value: []byte("}"),
|
||||||
|
BIN
internal/php7/php7.go
generated
BIN
internal/php7/php7.go
generated
Binary file not shown.
@ -1970,13 +1970,23 @@ class_statement:
|
|||||||
}
|
}
|
||||||
| T_USE name_list trait_adaptations
|
| T_USE name_list trait_adaptations
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitUse{
|
traitUse := &ast.StmtTraitUse{
|
||||||
Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3),
|
Position: yylex.(*Parser).builder.NewTokenNodePosition($1, $3),
|
||||||
UseTkn: $1,
|
UseTkn: $1,
|
||||||
Traits: $2.(*ast.ParserSeparatedList).Items,
|
Traits: $2.(*ast.ParserSeparatedList).Items,
|
||||||
SeparatorTkns: $2.(*ast.ParserSeparatedList).SeparatorTkns,
|
SeparatorTkns: $2.(*ast.ParserSeparatedList).SeparatorTkns,
|
||||||
Adaptations: $3,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch n := $3.(type) {
|
||||||
|
case *ast.TraitAdaptationList :
|
||||||
|
traitUse.OpenCurlyBracketTkn = n.OpenCurlyBracketTkn
|
||||||
|
traitUse.Adaptations = n.Adaptations
|
||||||
|
traitUse.CloseCurlyBracketTkn = n.CloseCurlyBracketTkn
|
||||||
|
case *ast.StmtNop :
|
||||||
|
traitUse.SemiColonTkn = n.SemiColonTkn
|
||||||
|
};
|
||||||
|
|
||||||
|
$$ = traitUse
|
||||||
}
|
}
|
||||||
| method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body
|
| method_modifiers T_FUNCTION returns_ref identifier backup_doc_comment '(' parameter_list ')' return_type method_body
|
||||||
{
|
{
|
||||||
@ -2032,7 +2042,7 @@ trait_adaptations:
|
|||||||
}
|
}
|
||||||
| '{' '}'
|
| '{' '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitAdaptationList{
|
$$ = &ast.TraitAdaptationList{
|
||||||
Position: yylex.(*Parser).builder.NewTokensPosition($1, $2),
|
Position: yylex.(*Parser).builder.NewTokensPosition($1, $2),
|
||||||
OpenCurlyBracketTkn: $1,
|
OpenCurlyBracketTkn: $1,
|
||||||
CloseCurlyBracketTkn: $2,
|
CloseCurlyBracketTkn: $2,
|
||||||
@ -2040,7 +2050,7 @@ trait_adaptations:
|
|||||||
}
|
}
|
||||||
| '{' trait_adaptation_list '}'
|
| '{' trait_adaptation_list '}'
|
||||||
{
|
{
|
||||||
$$ = &ast.StmtTraitAdaptationList{
|
$$ = &ast.TraitAdaptationList{
|
||||||
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
|
Position: yylex.(*Parser).builder.NewTokensPosition($1, $3),
|
||||||
OpenCurlyBracketTkn: $1,
|
OpenCurlyBracketTkn: $1,
|
||||||
Adaptations: $2,
|
Adaptations: $2,
|
||||||
|
@ -67,7 +67,6 @@ type NodeVisitor interface {
|
|||||||
StmtSwitch(n *StmtSwitch)
|
StmtSwitch(n *StmtSwitch)
|
||||||
StmtThrow(n *StmtThrow)
|
StmtThrow(n *StmtThrow)
|
||||||
StmtTrait(n *StmtTrait)
|
StmtTrait(n *StmtTrait)
|
||||||
StmtTraitAdaptationList(n *StmtTraitAdaptationList)
|
|
||||||
StmtTraitMethodRef(n *StmtTraitMethodRef)
|
StmtTraitMethodRef(n *StmtTraitMethodRef)
|
||||||
StmtTraitUse(n *StmtTraitUse)
|
StmtTraitUse(n *StmtTraitUse)
|
||||||
StmtTraitUseAlias(n *StmtTraitUseAlias)
|
StmtTraitUseAlias(n *StmtTraitUseAlias)
|
||||||
|
@ -945,22 +945,6 @@ func (n *StmtTrait) GetPosition() *position.Position {
|
|||||||
return n.Position
|
return n.Position
|
||||||
}
|
}
|
||||||
|
|
||||||
// StmtTraitAdaptationList node
|
|
||||||
type StmtTraitAdaptationList struct {
|
|
||||||
Position *position.Position
|
|
||||||
OpenCurlyBracketTkn *token.Token
|
|
||||||
Adaptations []Vertex
|
|
||||||
CloseCurlyBracketTkn *token.Token
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *StmtTraitAdaptationList) Accept(v NodeVisitor) {
|
|
||||||
v.StmtTraitAdaptationList(n)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (n *StmtTraitAdaptationList) GetPosition() *position.Position {
|
|
||||||
return n.Position
|
|
||||||
}
|
|
||||||
|
|
||||||
// StmtTraitMethodRef node
|
// StmtTraitMethodRef node
|
||||||
type StmtTraitMethodRef struct {
|
type StmtTraitMethodRef struct {
|
||||||
Position *position.Position
|
Position *position.Position
|
||||||
@ -983,7 +967,10 @@ type StmtTraitUse struct {
|
|||||||
UseTkn *token.Token
|
UseTkn *token.Token
|
||||||
Traits []Vertex
|
Traits []Vertex
|
||||||
SeparatorTkns []*token.Token
|
SeparatorTkns []*token.Token
|
||||||
Adaptations Vertex
|
OpenCurlyBracketTkn *token.Token
|
||||||
|
Adaptations []Vertex
|
||||||
|
CloseCurlyBracketTkn *token.Token
|
||||||
|
SemiColonTkn *token.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *StmtTraitUse) Accept(v NodeVisitor) {
|
func (n *StmtTraitUse) Accept(v NodeVisitor) {
|
||||||
@ -2699,6 +2686,22 @@ func (n *ParserSeparatedList) GetPosition() *position.Position {
|
|||||||
return n.Position
|
return n.Position
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TraitAdaptationList node
|
||||||
|
type TraitAdaptationList struct {
|
||||||
|
Position *position.Position
|
||||||
|
OpenCurlyBracketTkn *token.Token
|
||||||
|
Adaptations []Vertex
|
||||||
|
CloseCurlyBracketTkn *token.Token
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *TraitAdaptationList) Accept(v NodeVisitor) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n *TraitAdaptationList) GetPosition() *position.Position {
|
||||||
|
return n.Position
|
||||||
|
}
|
||||||
|
|
||||||
// ArgumentList node
|
// ArgumentList node
|
||||||
type ArgumentList struct {
|
type ArgumentList struct {
|
||||||
Position *position.Position
|
Position *position.Position
|
||||||
|
@ -812,20 +812,6 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
}
|
}
|
||||||
t.visitor.Leave("Stmts", false)
|
t.visitor.Leave("Stmts", false)
|
||||||
}
|
}
|
||||||
case *ast.StmtTraitAdaptationList:
|
|
||||||
if nn == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !t.visitor.EnterNode(nn) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if nn.Adaptations != nil {
|
|
||||||
t.visitor.Enter("Adaptations", false)
|
|
||||||
for _, c := range nn.Adaptations {
|
|
||||||
t.Traverse(c)
|
|
||||||
}
|
|
||||||
t.visitor.Leave("Adaptations", false)
|
|
||||||
}
|
|
||||||
case *ast.StmtTraitMethodRef:
|
case *ast.StmtTraitMethodRef:
|
||||||
if nn == nil {
|
if nn == nil {
|
||||||
return
|
return
|
||||||
@ -858,9 +844,11 @@ func (t *DFS) Traverse(n ast.Vertex) {
|
|||||||
t.visitor.Leave("Traits", false)
|
t.visitor.Leave("Traits", false)
|
||||||
}
|
}
|
||||||
if nn.Adaptations != nil {
|
if nn.Adaptations != nil {
|
||||||
t.visitor.Enter("Adaptations", true)
|
t.visitor.Enter("Adaptations", false)
|
||||||
t.Traverse(nn.Adaptations)
|
for _, c := range nn.Adaptations {
|
||||||
t.visitor.Leave("Adaptations", true)
|
t.Traverse(c)
|
||||||
|
}
|
||||||
|
t.visitor.Leave("Adaptations", false)
|
||||||
}
|
}
|
||||||
case *ast.StmtTraitUseAlias:
|
case *ast.StmtTraitUseAlias:
|
||||||
if nn == nil {
|
if nn == nil {
|
||||||
|
@ -858,19 +858,6 @@ func (v *Dumper) StmtTrait(n *ast.StmtTrait) {
|
|||||||
v.print(v.indent, "},\n")
|
v.print(v.indent, "},\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Dumper) StmtTraitAdaptationList(n *ast.StmtTraitAdaptationList) {
|
|
||||||
v.print(0, "&ast.StmtTraitAdaptationList{\n")
|
|
||||||
v.indent++
|
|
||||||
|
|
||||||
v.dumpPosition(n.Position)
|
|
||||||
v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn)
|
|
||||||
v.dumpVertexList("Adaptations", n.Adaptations)
|
|
||||||
v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn)
|
|
||||||
|
|
||||||
v.indent--
|
|
||||||
v.print(v.indent, "},\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Dumper) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
func (v *Dumper) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
||||||
v.print(0, "&ast.StmtTraitMethodRef{\n")
|
v.print(0, "&ast.StmtTraitMethodRef{\n")
|
||||||
v.indent++
|
v.indent++
|
||||||
@ -892,7 +879,10 @@ func (v *Dumper) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
v.dumpToken("UseTkn", n.UseTkn)
|
v.dumpToken("UseTkn", n.UseTkn)
|
||||||
v.dumpVertexList("Traits", n.Traits)
|
v.dumpVertexList("Traits", n.Traits)
|
||||||
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
|
v.dumpTokenList("SeparatorTkns", n.SeparatorTkns)
|
||||||
v.dumpVertex("Adaptations", n.Adaptations)
|
v.dumpToken("OpenCurlyBracketTkn", n.OpenCurlyBracketTkn)
|
||||||
|
v.dumpVertexList("Adaptations", n.Adaptations)
|
||||||
|
v.dumpToken("CloseCurlyBracketTkn", n.CloseCurlyBracketTkn)
|
||||||
|
v.dumpToken("SemiColonTkn", n.SemiColonTkn)
|
||||||
|
|
||||||
v.indent--
|
v.indent--
|
||||||
v.print(v.indent, "},\n")
|
v.print(v.indent, "},\n")
|
||||||
|
@ -886,21 +886,6 @@ func (f *formatter) StmtTrait(n *ast.StmtTrait) {
|
|||||||
n.CloseCurlyBracketTkn = f.newToken('}', []byte("}"))
|
n.CloseCurlyBracketTkn = f.newToken('}', []byte("}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *formatter) StmtTraitAdaptationList(n *ast.StmtTraitAdaptationList) {
|
|
||||||
n.OpenCurlyBracketTkn = f.newToken('{', []byte("{"))
|
|
||||||
|
|
||||||
if len(n.Adaptations) > 0 {
|
|
||||||
f.indent++
|
|
||||||
f.formatStmts(&n.Adaptations)
|
|
||||||
f.indent--
|
|
||||||
|
|
||||||
f.addFreeFloating(token.T_WHITESPACE, []byte("\n"))
|
|
||||||
f.addIndent()
|
|
||||||
}
|
|
||||||
|
|
||||||
n.CloseCurlyBracketTkn = f.newToken('}', []byte("}"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (f *formatter) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
func (f *formatter) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
||||||
if n.Trait != nil {
|
if n.Trait != nil {
|
||||||
n.Trait.Accept(f)
|
n.Trait.Accept(f)
|
||||||
@ -916,11 +901,27 @@ func (f *formatter) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
|
|
||||||
n.SeparatorTkns = f.formatList(n.Traits, ',')
|
n.SeparatorTkns = f.formatList(n.Traits, ',')
|
||||||
|
|
||||||
if _, ok := n.Adaptations.(*ast.StmtTraitAdaptationList); ok {
|
n.OpenCurlyBracketTkn = nil
|
||||||
|
n.CloseCurlyBracketTkn = nil
|
||||||
|
n.SemiColonTkn = nil
|
||||||
|
|
||||||
|
if len(n.Adaptations) > 0 {
|
||||||
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
f.addFreeFloating(token.T_WHITESPACE, []byte(" "))
|
||||||
|
n.OpenCurlyBracketTkn = f.newToken('{', []byte("{"))
|
||||||
|
|
||||||
|
if len(n.Adaptations) > 0 {
|
||||||
|
f.indent++
|
||||||
|
f.formatStmts(&n.Adaptations)
|
||||||
|
f.indent--
|
||||||
|
|
||||||
|
f.addFreeFloating(token.T_WHITESPACE, []byte("\n"))
|
||||||
|
f.addIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
n.Adaptations.Accept(f)
|
n.CloseCurlyBracketTkn = f.newToken('}', []byte("}"))
|
||||||
|
} else {
|
||||||
|
n.SemiColonTkn = f.newToken(';', []byte(";"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *formatter) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
func (f *formatter) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
||||||
|
@ -2503,76 +2503,6 @@ func TestFormatter_StmtTrait_Implements(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFormatter_StmtTraitAdaptationList(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
n := &ast.StmtTraitAdaptationList{}
|
|
||||||
|
|
||||||
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
|
||||||
n.Accept(f)
|
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
|
||||||
n.Accept(p)
|
|
||||||
|
|
||||||
expected := `{}`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFormatter_StmtTraitAdaptationList_List(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
n := &ast.StmtTraitAdaptationList{
|
|
||||||
Adaptations: []ast.Vertex{
|
|
||||||
&ast.StmtTraitUseAlias{
|
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
|
||||||
Method: &ast.Identifier{
|
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Alias: &ast.Identifier{
|
|
||||||
Value: []byte("bar"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
&ast.StmtTraitUsePrecedence{
|
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
|
||||||
Method: &ast.Identifier{
|
|
||||||
Value: []byte("foo"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Insteadof: []ast.Vertex{
|
|
||||||
&ast.NameName{
|
|
||||||
Parts: []ast.Vertex{
|
|
||||||
&ast.NameNamePart{
|
|
||||||
Value: []byte("bar"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
|
||||||
n.Accept(f)
|
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
|
||||||
n.Accept(p)
|
|
||||||
|
|
||||||
expected := `{
|
|
||||||
foo as bar;
|
|
||||||
foo insteadof bar;
|
|
||||||
}`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestFormatter_StmtTraitMethodRef(t *testing.T) {
|
func TestFormatter_StmtTraitMethodRef(t *testing.T) {
|
||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
@ -2646,7 +2576,6 @@ func TestFormatter_StmtTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtNop{},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
||||||
@ -2683,7 +2612,18 @@ func TestFormatter_StmtTraitUse_Adaptations(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{},
|
Adaptations: []ast.Vertex{
|
||||||
|
&ast.StmtTraitUseAlias{
|
||||||
|
Ref: &ast.StmtTraitMethodRef{
|
||||||
|
Method: &ast.Identifier{
|
||||||
|
Value: []byte("foo"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Alias: &ast.Identifier{
|
||||||
|
Value: []byte("baz"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
f := visitor.NewFormatter().WithState(visitor.FormatterStatePHP).WithIndent(1)
|
||||||
@ -2692,7 +2632,9 @@ func TestFormatter_StmtTraitUse_Adaptations(t *testing.T) {
|
|||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
||||||
n.Accept(p)
|
n.Accept(p)
|
||||||
|
|
||||||
expected := `use foo, bar {}`
|
expected := `use foo, bar {
|
||||||
|
foo as baz;
|
||||||
|
}`
|
||||||
actual := o.String()
|
actual := o.String()
|
||||||
|
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
|
@ -184,8 +184,7 @@ func (nsr *NamespaceResolver) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
nsr.ResolveName(t, "")
|
nsr.ResolveName(t, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
if adaptationList, ok := n.Adaptations.(*ast.StmtTraitAdaptationList); ok {
|
for _, a := range n.Adaptations {
|
||||||
for _, a := range adaptationList.Adaptations {
|
|
||||||
switch aa := a.(type) {
|
switch aa := a.(type) {
|
||||||
case *ast.StmtTraitUsePrecedence:
|
case *ast.StmtTraitUsePrecedence:
|
||||||
refTrait := aa.Ref.(*ast.StmtTraitMethodRef).Trait
|
refTrait := aa.Ref.(*ast.StmtTraitMethodRef).Trait
|
||||||
@ -204,7 +203,6 @@ func (nsr *NamespaceResolver) StmtTraitUse(n *ast.StmtTraitUse) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// LeaveNode is invoked after node process
|
// LeaveNode is invoked after node process
|
||||||
func (nsr *NamespaceResolver) LeaveNode(n ast.Vertex) {
|
func (nsr *NamespaceResolver) LeaveNode(n ast.Vertex) {
|
||||||
|
@ -354,7 +354,6 @@ func TestResolveTraitUse(t *testing.T) {
|
|||||||
nameB,
|
nameB,
|
||||||
relativeNameB,
|
relativeNameB,
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Adaptations: []ast.Vertex{
|
Adaptations: []ast.Vertex{
|
||||||
&ast.StmtTraitUsePrecedence{
|
&ast.StmtTraitUsePrecedence{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Ref: &ast.StmtTraitMethodRef{
|
||||||
@ -372,7 +371,6 @@ func TestResolveTraitUse(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
&ast.StmtTraitUse{
|
&ast.StmtTraitUse{
|
||||||
Traits: []ast.Vertex{
|
Traits: []ast.Vertex{
|
||||||
nameD,
|
nameD,
|
||||||
|
@ -206,10 +206,6 @@ func (v *Null) StmtTrait(_ *ast.StmtTrait) {
|
|||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Null) StmtTraitAdaptationList(_ *ast.StmtTraitAdaptationList) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
func (v *Null) StmtTraitMethodRef(_ *ast.StmtTraitMethodRef) {
|
func (v *Null) StmtTraitMethodRef(_ *ast.StmtTraitMethodRef) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
|
@ -531,12 +531,6 @@ func (p *printer) StmtTrait(n *ast.StmtTrait) {
|
|||||||
p.printToken(n.CloseCurlyBracketTkn, []byte("}"))
|
p.printToken(n.CloseCurlyBracketTkn, []byte("}"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *printer) StmtTraitAdaptationList(n *ast.StmtTraitAdaptationList) {
|
|
||||||
p.printToken(n.OpenCurlyBracketTkn, []byte("{"))
|
|
||||||
p.printList(n.Adaptations)
|
|
||||||
p.printToken(n.CloseCurlyBracketTkn, []byte("}"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *printer) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
func (p *printer) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
||||||
p.printNode(n.Trait)
|
p.printNode(n.Trait)
|
||||||
p.printToken(n.DoubleColonTkn, p.ifNode(n.Trait, []byte("::")))
|
p.printToken(n.DoubleColonTkn, p.ifNode(n.Trait, []byte("::")))
|
||||||
@ -546,7 +540,10 @@ func (p *printer) StmtTraitMethodRef(n *ast.StmtTraitMethodRef) {
|
|||||||
func (p *printer) StmtTraitUse(n *ast.StmtTraitUse) {
|
func (p *printer) StmtTraitUse(n *ast.StmtTraitUse) {
|
||||||
p.printToken(n.UseTkn, []byte("use"))
|
p.printToken(n.UseTkn, []byte("use"))
|
||||||
p.printSeparatedList(n.Traits, n.SeparatorTkns, []byte(","))
|
p.printSeparatedList(n.Traits, n.SeparatorTkns, []byte(","))
|
||||||
p.printNode(n.Adaptations)
|
p.printToken(n.OpenCurlyBracketTkn, p.ifNodeList(n.Adaptations, []byte("{")))
|
||||||
|
p.printList(n.Adaptations)
|
||||||
|
p.printToken(n.CloseCurlyBracketTkn, p.ifNodeList(n.Adaptations, []byte("}")))
|
||||||
|
p.printToken(n.SemiColonTkn, p.ifNotToken(n.OpenCurlyBracketTkn, p.ifNotNodeList(n.Adaptations, []byte(";"))))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *printer) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
func (p *printer) StmtTraitUseAlias(n *ast.StmtTraitUseAlias) {
|
||||||
|
@ -4339,31 +4339,6 @@ func TestPrinterPrintStmtThrow(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestPrinterPrintStmtTraitAdaptationList(t *testing.T) {
|
|
||||||
o := bytes.NewBufferString("")
|
|
||||||
|
|
||||||
p := visitor.NewPrinter(o).WithState(visitor.PrinterStatePHP)
|
|
||||||
n := &ast.StmtTraitAdaptationList{
|
|
||||||
Adaptations: []ast.Vertex{
|
|
||||||
&ast.StmtTraitUseAlias{
|
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
|
||||||
Trait: &ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
|
||||||
Method: &ast.Identifier{Value: []byte("a")},
|
|
||||||
},
|
|
||||||
Alias: &ast.Identifier{Value: []byte("b")},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
n.Accept(p)
|
|
||||||
|
|
||||||
expected := `{Foo::a as b;}`
|
|
||||||
actual := o.String()
|
|
||||||
|
|
||||||
if expected != actual {
|
|
||||||
t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrinterPrintStmtTraitMethodRef(t *testing.T) {
|
func TestPrinterPrintStmtTraitMethodRef(t *testing.T) {
|
||||||
o := bytes.NewBufferString("")
|
o := bytes.NewBufferString("")
|
||||||
|
|
||||||
@ -4454,7 +4429,6 @@ func TestPrinterPrintStmtTraitUse(t *testing.T) {
|
|||||||
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
|
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtNop{},
|
|
||||||
}
|
}
|
||||||
n.Accept(p)
|
n.Accept(p)
|
||||||
|
|
||||||
@ -4475,7 +4449,6 @@ func TestPrinterPrintStmtTraitAdaptations(t *testing.T) {
|
|||||||
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Foo")}}},
|
||||||
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
|
&ast.NameName{Parts: []ast.Vertex{&ast.NameNamePart{Value: []byte("Bar")}}},
|
||||||
},
|
},
|
||||||
Adaptations: &ast.StmtTraitAdaptationList{
|
|
||||||
Adaptations: []ast.Vertex{
|
Adaptations: []ast.Vertex{
|
||||||
&ast.StmtTraitUseAlias{
|
&ast.StmtTraitUseAlias{
|
||||||
Ref: &ast.StmtTraitMethodRef{
|
Ref: &ast.StmtTraitMethodRef{
|
||||||
@ -4485,7 +4458,6 @@ func TestPrinterPrintStmtTraitAdaptations(t *testing.T) {
|
|||||||
Alias: &ast.Identifier{Value: []byte("b")},
|
Alias: &ast.Identifier{Value: []byte("b")},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
}
|
||||||
n.Accept(p)
|
n.Accept(p)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user