]> Cypherpunks repositories - gostls13.git/commitdiff
- don't show methods of non-exported types
authorRobert Griesemer <gri@golang.org>
Fri, 3 Apr 2009 05:39:52 +0000 (22:39 -0700)
committerRobert Griesemer <gri@golang.org>
Fri, 3 Apr 2009 05:39:52 +0000 (22:39 -0700)
(even if the methods are exported)

R=rsc
OCL=27056
CL=27056

usr/gri/pretty/docprinter.go

index a901bdee080c6a3a69828350175122dd5447491c..94fe50119304145f9c6abb8cc90dd1378bbb9cd5 100644 (file)
@@ -129,11 +129,14 @@ func (doc *PackageDoc) addFunc(fun *ast.FuncDecl) {
        var typ *typeDoc;
        if fun.Recv != nil {
                // method
+               // (all receiver types must be declared before they are used)
                typ = doc.lookupTypeDoc(fun.Recv.Type);
                if typ != nil {
+                       // type found (i.e., exported)
                        typ.methods[name] = fdoc;
-                       return;
                }
+               // if the type wasn't found, it wasn't exported
+
        } else {
                // perhaps a factory function
                // determine result type, if any
@@ -148,11 +151,10 @@ func (doc *PackageDoc) addFunc(fun *ast.FuncDecl) {
                                }
                        }
                }
+
+               // ordinary function
+               doc.funcs[name] = fdoc;
        }
-       // TODO other heuristics (e.g. name is "NewTypename"?)
-       
-       // ordinary function
-       doc.funcs[name] = fdoc;
 }