update Makefile

This commit is contained in:
z7zmey 2018-02-24 00:17:51 +02:00
parent 91eb67279d
commit 90f451293d
2 changed files with 16 additions and 5 deletions

View File

@ -1,12 +1,14 @@
PHPFILE=example.php
all: compile run
all: compile fmt build run
fmt:
find . -type f -iregex '.*\.go' -exec gofmt -l -s -w '{}' +
build:
find . -type f -iregex '.*\.go' -exec gofmt -l -s -w '{}' +
go build
run: build
run:
./php-parser $(PHPFILE)
test:

View File

@ -2,7 +2,6 @@
package visitor
import (
"fmt"
"strings"
"github.com/z7zmey/php-parser/node"
@ -60,22 +59,33 @@ func (nsr *NsResolver) EnterNode(w walker.Walkable) bool {
NSParts := n.NamespaceName.(*name.Name).Parts
nsr.Namespace = NewNamespace(concatNameParts(NSParts))
}
case *stmt.UseList:
useType := ""
if n.UseType != nil {
useType = n.UseType.(*node.Identifier).Value
}
for _, nn := range n.Uses {
nsr.AddAlias(useType, nn, nil)
}
// no reason to iterate into depth
return false
case *stmt.GroupUse:
useType := ""
if n.UseType != nil {
useType = n.UseType.(*node.Identifier).Value
}
for _, nn := range n.UseList {
nsr.AddAlias(useType, nn, n.Prefix.(*name.Name).Parts)
}
// no reason to iterate into depth
return false
}
return true
@ -110,7 +120,6 @@ func (nsr *NsResolver) LeaveNode(w walker.Walkable) {
switch n := w.(type) {
case *stmt.Namespace:
if n.Stmts != nil {
fmt.Printf("%+v \n", nsr.Namespace.Aliases)
nsr.Namespace = NewNamespace("")
}
}