// Double check for any type-checking inconsistencies. This can be
// removed once we're confident in IR generation results.
- syntax.Crawl(p.file, func(n syntax.Node) bool {
+ syntax.Inspect(p.file, func(n syntax.Node) bool {
g.validate(n)
- return false
+ return true
})
}
import "fmt"
-// Inspect traverses an AST in pre-order: It starts by calling
-// f(node); node must not be nil. If f returns true, Inspect invokes f
-// recursively for each of the non-nil children of node, followed by a
-// call of f(nil).
+// Inspect traverses an AST in pre-order: it starts by calling f(root);
+// root must not be nil. If f returns true, Inspect invokes f recursively
+// for each of the non-nil children of root, followed by a call of f(nil).
//
// See Walk for caveats about shared nodes.
func Inspect(root Node, f func(Node) bool) {
return nil
}
-// Crawl traverses a syntax in pre-order: It starts by calling f(root);
-// root must not be nil. If f returns false (== "continue"), Crawl calls
-// f recursively for each of the non-nil children of that node; if f
-// returns true (== "stop"), Crawl does not traverse the respective node's
-// children.
-//
-// See Walk for caveats about shared nodes.
-//
-// Deprecated: Use Inspect instead.
-func Crawl(root Node, f func(Node) bool) {
- Inspect(root, func(node Node) bool {
- return node != nil && !f(node)
- })
-}
-
// Walk traverses an AST in pre-order: It starts by calling
// v.Visit(node); node must not be nil. If the visitor w returned by
// v.Visit(node) is not nil, Walk is invoked recursively with visitor
}
}
- syntax.Crawl(f, func(n syntax.Node) bool {
+ syntax.Inspect(f, func(n syntax.Node) bool {
if decl, _ := n.(*syntax.TypeDecl); decl != nil {
if tv, ok := info.Types[decl.Type]; ok && decl.Name.Value == "T" {
want := strings.Count(src, ";") + 1
}
}
}
- return false
+ return true
})
}
}
// check that qualified identifiers are resolved
for _, f := range files {
- syntax.Crawl(f, func(n syntax.Node) bool {
+ syntax.Inspect(f, func(n syntax.Node) bool {
if s, ok := n.(*syntax.SelectorExpr); ok {
if x, ok := s.X.(*syntax.Name); ok {
obj := uses[x]
if obj == nil {
t.Errorf("%s: unresolved qualified identifier %s", x.Pos(), x.Value)
- return true
+ return false
}
if _, ok := obj.(*PkgName); ok && uses[s.Sel] == nil {
t.Errorf("%s: unresolved selector %s", s.Sel.Pos(), s.Sel.Value)
- return true
+ return false
}
- return true
+ return false
}
return true
}
- return false
+ return true
})
}
foundDefs := make(map[*syntax.Name]bool)
var both []string
for _, f := range files {
- syntax.Crawl(f, func(n syntax.Node) bool {
+ syntax.Inspect(f, func(n syntax.Node) bool {
if x, ok := n.(*syntax.Name); ok {
var objects int
if _, found := uses[x]; found {
case 3:
both = append(both, x.Value)
}
- return true
+ return false
}
- return false
+ return true
})
}
}
return false
}
- return false
+ return true
}
return true
})