go.tools/go/oracle: show import path (not just name) when describing an import.

+ test.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/88190044
This commit is contained in:
Alan Donovan 2014-04-15 15:37:44 -04:00
parent bc722df585
commit b3970ee159
3 changed files with 12 additions and 2 deletions

View File

@ -498,7 +498,7 @@ func describePackage(o *Oracle, qpos *QueryPos, path []ast.Node) (*describePacka
switch n := path[0].(type) { switch n := path[0].(type) {
case *ast.ImportSpec: case *ast.ImportSpec:
pkgname := qpos.info.ImportSpecPkg(n) pkgname := qpos.info.ImportSpecPkg(n)
description = fmt.Sprintf("import of package %q", pkgname.Name()) description = fmt.Sprintf("import of package %q", pkgname.Pkg().Path())
pkg = pkgname.Pkg() pkg = pkgname.Pkg()
case *ast.Ident: case *ast.Ident:

View File

@ -1,6 +1,7 @@
package imports package imports
import ( import (
"hash/fnv" // @describe ref-pkg-import2 "fnv"
"lib" // @describe ref-pkg-import "lib" "lib" // @describe ref-pkg-import "lib"
) )
@ -23,4 +24,6 @@ func main() {
print(*p + 1) // @pointsto p "p " print(*p + 1) // @pointsto p "p "
var _ lib.Type // @describe ref-pkg "lib" var _ lib.Type // @describe ref-pkg "lib"
fnv.New32()
} }

View File

@ -1,3 +1,10 @@
-------- @describe ref-pkg-import2 --------
import of package "hash/fnv"
func New32 func() hash.Hash32
func New32a func() hash.Hash32
func New64 func() hash.Hash64
func New64a func() hash.Hash64
-------- @describe ref-pkg-import -------- -------- @describe ref-pkg-import --------
import of package "lib" import of package "lib"
const Const untyped int = 3 const Const untyped int = 3