aboutsummaryrefslogtreecommitdiff
path: root/oracle/oracle.go
diff options
context:
space:
mode:
Diffstat (limited to 'oracle/oracle.go')
-rw-r--r--oracle/oracle.go23
1 files changed, 7 insertions, 16 deletions
diff --git a/oracle/oracle.go b/oracle/oracle.go
index 55566c3..3cff219 100644
--- a/oracle/oracle.go
+++ b/oracle/oracle.go
@@ -8,7 +8,7 @@
// http://golang.org/s/oracle-design
// http://golang.org/s/oracle-user-manual
//
-package oracle
+package oracle // import "golang.org/x/tools/oracle"
// This file defines oracle.Query, the entry point for the oracle tool.
// The actual executable is defined in cmd/oracle.
@@ -56,7 +56,7 @@ import (
"go/token"
"io"
- "golang.org/x/tools/astutil"
+ "golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/loader"
"golang.org/x/tools/go/pointer"
"golang.org/x/tools/go/ssa"
@@ -101,6 +101,7 @@ var modes = []*modeInfo{
{"callstack", needPTA | needPos, callstack},
{"peers", needPTA | needSSADebug | needPos, peers},
{"pointsto", needPTA | needSSADebug | needExactPos, pointsto},
+ {"whicherrs", needPTA | needSSADebug | needExactPos, whicherrs},
// Type-based, modular analyses:
{"definition", needPos, definition},
@@ -192,7 +193,7 @@ func (res *Result) Serial() *serial.Result {
// Clients that intend to perform multiple queries against the same
// analysis scope should use this pattern instead:
//
-// conf := loader.Config{Build: buildContext, SourceImports: true}
+// conf := loader.Config{Build: buildContext}
// ... populate config, e.g. conf.FromArgs(args) ...
// iprog, err := conf.Load()
// if err != nil { ... }
@@ -222,7 +223,7 @@ func Query(args []string, mode, pos string, ptalog io.Writer, buildContext *buil
return nil, fmt.Errorf("invalid mode type: %q", mode)
}
- conf := loader.Config{Build: buildContext, SourceImports: true}
+ conf := loader.Config{Build: buildContext}
// Determine initial packages.
args, err := conf.FromArgs(args, true)
@@ -321,7 +322,7 @@ func reduceScope(pos string, conf *loader.Config) {
// (and possibly its corresponding tests/production code).
// TODO(adonovan): set 'augment' based on which file list
// contains
- _ = conf.ImportWithTests(importPath) // ignore error
+ conf.ImportWithTests(importPath)
}
func pkgContainsFile(bp *build.Package, filename string) bool {
@@ -481,17 +482,7 @@ func ptrAnalysis(o *Oracle) *pointer.Result {
return result
}
-// unparen returns e with any enclosing parentheses stripped.
-func unparen(e ast.Expr) ast.Expr {
- for {
- p, ok := e.(*ast.ParenExpr)
- if !ok {
- break
- }
- e = p.X
- }
- return e
-}
+func unparen(e ast.Expr) ast.Expr { return astutil.Unparen(e) }
// deref returns a pointer's element type; otherwise it returns typ.
func deref(typ types.Type) types.Type {