godoc: Index const and vars in godoc.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/26990043
This commit is contained in:
Marko Mikulicic 2013-11-15 11:03:25 -08:00 committed by Brad Fitzpatrick
parent 9c112540f6
commit ae3dd78063
2 changed files with 10 additions and 4 deletions

View File

@ -430,7 +430,7 @@ func (x *Indexer) visitIdent(kind SpotKind, id *ast.Ident) {
name := x.intern(id.Name)
switch kind {
case TypeDecl, FuncDecl:
case TypeDecl, FuncDecl, ConstDecl, VarDecl:
x.curPkgExports[name] = kind
}

View File

@ -20,6 +20,10 @@ package foo
import "bar"
const Pi = 3.1415
var Foos []Foo
// Foo is stuff.
type Foo struct{}
@ -87,7 +91,7 @@ func TestIndexWriteRead(t *testing.T) {
}
func testIndex(t *testing.T, ix *Index) {
wantStats := Statistics{Bytes: 256, Files: 3, Lines: 16, Words: 6, Spots: 9}
wantStats := Statistics{Bytes: 291, Files: 3, Lines: 20, Words: 8, Spots: 12}
if !reflect.DeepEqual(ix.Stats(), wantStats) {
t.Errorf("Stats = %#v; want %#v", ix.Stats(), wantStats)
}
@ -116,8 +120,10 @@ func testIndex(t *testing.T, ix *Index) {
if got, want := ix.Exports(), map[string]map[string]SpotKind{
"foo": map[string]SpotKind{
"Foo": TypeDecl,
"New": FuncDecl,
"Pi": ConstDecl,
"Foos": VarDecl,
"Foo": TypeDecl,
"New": FuncDecl,
},
"other/bar": map[string]SpotKind{
"X": FuncDecl,