update Makefile
This commit is contained in:
parent
91eb67279d
commit
90f451293d
8
Makefile
8
Makefile
@ -1,12 +1,14 @@
|
|||||||
PHPFILE=example.php
|
PHPFILE=example.php
|
||||||
|
|
||||||
all: compile run
|
all: compile fmt build run
|
||||||
|
|
||||||
|
fmt:
|
||||||
|
find . -type f -iregex '.*\.go' -exec gofmt -l -s -w '{}' +
|
||||||
|
|
||||||
build:
|
build:
|
||||||
find . -type f -iregex '.*\.go' -exec gofmt -l -s -w '{}' +
|
|
||||||
go build
|
go build
|
||||||
|
|
||||||
run: build
|
run:
|
||||||
./php-parser $(PHPFILE)
|
./php-parser $(PHPFILE)
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
package visitor
|
package visitor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/z7zmey/php-parser/node"
|
"github.com/z7zmey/php-parser/node"
|
||||||
@ -60,22 +59,33 @@ func (nsr *NsResolver) EnterNode(w walker.Walkable) bool {
|
|||||||
NSParts := n.NamespaceName.(*name.Name).Parts
|
NSParts := n.NamespaceName.(*name.Name).Parts
|
||||||
nsr.Namespace = NewNamespace(concatNameParts(NSParts))
|
nsr.Namespace = NewNamespace(concatNameParts(NSParts))
|
||||||
}
|
}
|
||||||
|
|
||||||
case *stmt.UseList:
|
case *stmt.UseList:
|
||||||
useType := ""
|
useType := ""
|
||||||
if n.UseType != nil {
|
if n.UseType != nil {
|
||||||
useType = n.UseType.(*node.Identifier).Value
|
useType = n.UseType.(*node.Identifier).Value
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, nn := range n.Uses {
|
for _, nn := range n.Uses {
|
||||||
nsr.AddAlias(useType, nn, nil)
|
nsr.AddAlias(useType, nn, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no reason to iterate into depth
|
||||||
|
return false
|
||||||
|
|
||||||
case *stmt.GroupUse:
|
case *stmt.GroupUse:
|
||||||
useType := ""
|
useType := ""
|
||||||
if n.UseType != nil {
|
if n.UseType != nil {
|
||||||
useType = n.UseType.(*node.Identifier).Value
|
useType = n.UseType.(*node.Identifier).Value
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, nn := range n.UseList {
|
for _, nn := range n.UseList {
|
||||||
nsr.AddAlias(useType, nn, n.Prefix.(*name.Name).Parts)
|
nsr.AddAlias(useType, nn, n.Prefix.(*name.Name).Parts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// no reason to iterate into depth
|
||||||
|
return false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@ -110,7 +120,6 @@ func (nsr *NsResolver) LeaveNode(w walker.Walkable) {
|
|||||||
switch n := w.(type) {
|
switch n := w.(type) {
|
||||||
case *stmt.Namespace:
|
case *stmt.Namespace:
|
||||||
if n.Stmts != nil {
|
if n.Stmts != nil {
|
||||||
fmt.Printf("%+v \n", nsr.Namespace.Aliases)
|
|
||||||
nsr.Namespace = NewNamespace("")
|
nsr.Namespace = NewNamespace("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user