[refactoring] update ast structure of "name" nodes
This commit is contained in:
@@ -33,3 +33,30 @@ func (v *FilterTokens) StmtUseDeclaration(n *ast.StmtUseDeclaration) {
|
||||
n.AsTkn = nil
|
||||
n.CommaTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) NameNamePart(n *ast.NameNamePart) {
|
||||
n.NsSeparatorTkn = nil
|
||||
n.StringTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) NameName(n *ast.NameName) {
|
||||
n.ListSeparatorTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) NameFullyQualified(n *ast.NameFullyQualified) {
|
||||
n.NsSeparatorTkn = nil
|
||||
n.ListSeparatorTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) NameRelative(n *ast.NameRelative) {
|
||||
n.NsTkn = nil
|
||||
n.NsSeparatorTkn = nil
|
||||
n.ListSeparatorTkn = nil
|
||||
}
|
||||
|
||||
func (v *FilterTokens) StmtNamespace(n *ast.StmtNamespace) {
|
||||
n.NsTkn = nil
|
||||
n.OpenCurlyBracket = nil
|
||||
n.CloseCurlyBracket = nil
|
||||
n.SemiColonTkn = nil
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ func (nsr *NamespaceResolver) EnterNode(n ast.Vertex) bool {
|
||||
}
|
||||
|
||||
func (nsr *NamespaceResolver) StmtNamespace(n *ast.StmtNamespace) {
|
||||
if n.NamespaceName == nil {
|
||||
if n.Name == nil {
|
||||
nsr.Namespace = NewNamespace("")
|
||||
} else {
|
||||
NSParts := n.NamespaceName.(*ast.NameName).Parts
|
||||
NSParts := n.Name.(*ast.NameName).Parts
|
||||
nsr.Namespace = NewNamespace(concatNameParts(NSParts))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,7 +605,7 @@ func TestResolveConstantsName(t *testing.T) {
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: nameAB,
|
||||
Name: nameAB,
|
||||
},
|
||||
&ast.StmtConstList{
|
||||
Consts: []ast.Vertex{
|
||||
@@ -649,7 +649,7 @@ func TestResolveNamespaces(t *testing.T) {
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: namespaceAB,
|
||||
Name: namespaceAB,
|
||||
},
|
||||
&ast.StmtConstList{
|
||||
Consts: []ast.Vertex{
|
||||
@@ -666,7 +666,7 @@ func TestResolveNamespaces(t *testing.T) {
|
||||
Stmts: []ast.Vertex{},
|
||||
},
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: namespaceCD,
|
||||
Name: namespaceCD,
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtUse{
|
||||
UseDeclarations: []ast.Vertex{
|
||||
@@ -749,7 +749,7 @@ func TestDoNotResolveReservedConstants(t *testing.T) {
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: namespaceName,
|
||||
Name: namespaceName,
|
||||
},
|
||||
&ast.StmtExpression{
|
||||
Expr: &ast.ExprConstFetch{
|
||||
@@ -877,7 +877,7 @@ func TestDoNotResolveReservedNames(t *testing.T) {
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: &ast.NameName{
|
||||
Name: &ast.NameName{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NameNamePart{Value: []byte("Foo")},
|
||||
},
|
||||
@@ -955,7 +955,7 @@ func TestDoNotResolveReservedSpecialNames(t *testing.T) {
|
||||
stxTree := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: &ast.NameName{
|
||||
Name: &ast.NameName{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NameNamePart{Value: []byte("Foo")},
|
||||
},
|
||||
@@ -1007,7 +1007,7 @@ func TestResolvePropertyTypeName(t *testing.T) {
|
||||
stmts := &ast.StmtStmtList{
|
||||
Stmts: []ast.Vertex{
|
||||
&ast.StmtNamespace{
|
||||
NamespaceName: &ast.NameName{
|
||||
Name: &ast.NameName{
|
||||
Parts: []ast.Vertex{
|
||||
&ast.NameNamePart{Value: []byte("Foo")},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user