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) name := x.intern(id.Name)
switch kind { switch kind {
case TypeDecl, FuncDecl: case TypeDecl, FuncDecl, ConstDecl, VarDecl:
x.curPkgExports[name] = kind x.curPkgExports[name] = kind
} }

View File

@ -20,6 +20,10 @@ package foo
import "bar" import "bar"
const Pi = 3.1415
var Foos []Foo
// Foo is stuff. // Foo is stuff.
type Foo struct{} type Foo struct{}
@ -87,7 +91,7 @@ func TestIndexWriteRead(t *testing.T) {
} }
func testIndex(t *testing.T, ix *Index) { 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) { if !reflect.DeepEqual(ix.Stats(), wantStats) {
t.Errorf("Stats = %#v; want %#v", ix.Stats(), wantStats) t.Errorf("Stats = %#v; want %#v", ix.Stats(), wantStats)
} }
@ -116,6 +120,8 @@ func testIndex(t *testing.T, ix *Index) {
if got, want := ix.Exports(), map[string]map[string]SpotKind{ if got, want := ix.Exports(), map[string]map[string]SpotKind{
"foo": map[string]SpotKind{ "foo": map[string]SpotKind{
"Pi": ConstDecl,
"Foos": VarDecl,
"Foo": TypeDecl, "Foo": TypeDecl,
"New": FuncDecl, "New": FuncDecl,
}, },