summaryrefslogtreecommitdiff
path: root/src/pkg/go/doc/doc.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-01-15 13:27:45 -0800
committerRobert Griesemer <gri@golang.org>2010-01-15 13:27:45 -0800
commit1dd0f7c2e78657111e265fbc76f281f7850c38c5 (patch)
treef7a2ae997c05b400635bc380102dd73102b05b0f /src/pkg/go/doc/doc.go
parent2442a6ddd956d1a902282d9bef429c16348fcf37 (diff)
downloadgolang-1dd0f7c2e78657111e265fbc76f281f7850c38c5.tar.gz
Steps towards tracking scopes for identifiers.
- Identifiers refer now to the language entity (Object) that they denote. At the moment this is at best an approximation. - Initial data structures for language entities (Objects) and expression types (Type) independent of the actual type notations. - Initial support for declaring and looking up identifiers. - Updated various dependent files and added support functions. - Extensively tested to avoid breakage. This is an AST change. R=rsc CC=golang-dev, rog http://codereview.appspot.com/189080
Diffstat (limited to 'src/pkg/go/doc/doc.go')
-rw-r--r--src/pkg/go/doc/doc.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/pkg/go/doc/doc.go b/src/pkg/go/doc/doc.go
index be03ddfd6..d97548715 100644
--- a/src/pkg/go/doc/doc.go
+++ b/src/pkg/go/doc/doc.go
@@ -55,7 +55,7 @@ func (doc *docReader) init(pkgName string) {
func (doc *docReader) addType(decl *ast.GenDecl) {
spec := decl.Specs[0].(*ast.TypeSpec)
- typ := doc.lookupTypeDoc(spec.Name.Value)
+ typ := doc.lookupTypeDoc(spec.Name.Name())
// typ should always be != nil since declared types
// are always named - be conservative and check
if typ != nil {
@@ -86,7 +86,7 @@ func baseTypeName(typ ast.Expr) string {
// if the type is not exported, the effect to
// a client is as if there were no type name
if t.IsExported() {
- return string(t.Value)
+ return string(t.Name())
}
case *ast.StarExpr:
return baseTypeName(t.X)
@@ -148,7 +148,7 @@ func (doc *docReader) addValue(decl *ast.GenDecl) {
func (doc *docReader) addFunc(fun *ast.FuncDecl) {
- name := fun.Name.Value
+ name := fun.Name.Name()
// determine if it should be associated with a type
if fun.Recv != nil {
@@ -291,7 +291,7 @@ func (doc *docReader) addFile(src *ast.File) {
func NewFileDoc(file *ast.File) *PackageDoc {
var r docReader
- r.init(file.Name.Value)
+ r.init(file.Name.Name())
r.addFile(file)
return r.newDoc("", "", nil)
}
@@ -336,9 +336,9 @@ func declName(d *ast.GenDecl) string {
switch v := d.Specs[0].(type) {
case *ast.ValueSpec:
- return v.Names[0].Value
+ return v.Names[0].Name()
case *ast.TypeSpec:
- return v.Name.Value
+ return v.Name.Name()
}
return ""
@@ -400,7 +400,7 @@ func makeFuncDocs(m map[string]*ast.FuncDecl) []*FuncDoc {
if f.Recv != nil {
doc.Recv = f.Recv.Type
}
- doc.Name = f.Name.Value
+ doc.Name = f.Name.Name()
doc.Decl = f
d[i] = doc
i++
@@ -433,7 +433,7 @@ func (p sortTypeDoc) Less(i, j int) bool {
// sort by name
// pull blocks (name = "") up to top
// in original order
- if ni, nj := p[i].Type.Name.Value, p[j].Type.Name.Value; ni != nj {
+ if ni, nj := p[i].Type.Name.Name(), p[j].Type.Name.Name(); ni != nj {
return ni < nj
}
return p[i].order < p[j].order
@@ -581,12 +581,12 @@ func matchDecl(d *ast.GenDecl, names []string) bool {
switch v := d.(type) {
case *ast.ValueSpec:
for _, name := range v.Names {
- if match(name.Value, names) {
+ if match(name.Name(), names) {
return true
}
}
case *ast.TypeSpec:
- if match(v.Name.Value, names) {
+ if match(v.Name.Name(), names) {
return true
}
}