mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
godoc: use "IsPredeclared" of go/doc
In the go/doc, the same map as "predeclared" is defined. Instead of the "predeclared" map use the "IsPredeclared" function which is an accessor for the go/doc map. Deleted unnecessary "predeclared". Fixes golang/go#20357 Change-Id: I4ea360efddd28a9a1236d5adfdafb1a0970a4215 Reviewed-on: https://go-review.googlesource.com/58890 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
bd4635fd25
commit
4de4a8d206
@ -13,6 +13,7 @@ package godoc
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
|
"go/doc"
|
||||||
"go/token"
|
"go/token"
|
||||||
"io"
|
"io"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -182,7 +183,7 @@ func linksFor(node ast.Node) (links []link) {
|
|||||||
links = append(links, l)
|
links = append(links, l)
|
||||||
} else {
|
} else {
|
||||||
l := link{name: n.Name}
|
l := link{name: n.Name}
|
||||||
if n.Obj == nil && predeclared[n.Name] {
|
if n.Obj == nil && doc.IsPredeclared(n.Name) {
|
||||||
l.path = builtinPkgPath
|
l.path = builtinPkgPath
|
||||||
}
|
}
|
||||||
links = append(links, l)
|
links = append(links, l)
|
||||||
@ -192,49 +193,3 @@ func linksFor(node ast.Node) (links []link) {
|
|||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// The predeclared map represents the set of all predeclared identifiers.
|
|
||||||
// TODO(gri) This information is also encoded in similar maps in go/doc,
|
|
||||||
// but not exported. Consider exporting an accessor and using
|
|
||||||
// it instead.
|
|
||||||
var predeclared = map[string]bool{
|
|
||||||
"bool": true,
|
|
||||||
"byte": true,
|
|
||||||
"complex64": true,
|
|
||||||
"complex128": true,
|
|
||||||
"error": true,
|
|
||||||
"float32": true,
|
|
||||||
"float64": true,
|
|
||||||
"int": true,
|
|
||||||
"int8": true,
|
|
||||||
"int16": true,
|
|
||||||
"int32": true,
|
|
||||||
"int64": true,
|
|
||||||
"rune": true,
|
|
||||||
"string": true,
|
|
||||||
"uint": true,
|
|
||||||
"uint8": true,
|
|
||||||
"uint16": true,
|
|
||||||
"uint32": true,
|
|
||||||
"uint64": true,
|
|
||||||
"uintptr": true,
|
|
||||||
"true": true,
|
|
||||||
"false": true,
|
|
||||||
"iota": true,
|
|
||||||
"nil": true,
|
|
||||||
"append": true,
|
|
||||||
"cap": true,
|
|
||||||
"close": true,
|
|
||||||
"complex": true,
|
|
||||||
"copy": true,
|
|
||||||
"delete": true,
|
|
||||||
"imag": true,
|
|
||||||
"len": true,
|
|
||||||
"make": true,
|
|
||||||
"new": true,
|
|
||||||
"panic": true,
|
|
||||||
"print": true,
|
|
||||||
"println": true,
|
|
||||||
"real": true,
|
|
||||||
"recover": true,
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user