From: Robert Griesemer Date: Thu, 12 May 2011 16:01:50 +0000 (-0700) Subject: go/printer: more accurate comment for incomplete structs/interfaces X-Git-Tag: weekly.2011-05-22~96 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=82d1a9dce7478abcd9cf5d3fdc94f231f2f7b614;p=gostls13.git go/printer: more accurate comment for incomplete structs/interfaces A struct or interface type node is marked incomplete if fields or methods have been removed through any kind of filtering, not just because entries are not exported. The current message was misleading in some cases (for instance: "godoc -src reflect Implements"). This CL requires CL 4527050 . R=rsc, bradfitz CC=golang-dev https://golang.org/cl/4529054 --- diff --git a/src/pkg/go/printer/nodes.go b/src/pkg/go/printer/nodes.go index 572c9bd28f..3b504bd2c5 100644 --- a/src/pkg/go/printer/nodes.go +++ b/src/pkg/go/printer/nodes.go @@ -439,7 +439,7 @@ func (p *printer) fieldList(fields *ast.FieldList, isStruct, isIncomplete bool) p.print(formfeed) } p.flush(p.fset.Position(rbrace), token.RBRACE) // make sure we don't loose the last line comment - p.setLineComment("// contains unexported fields") + p.setLineComment("// contains filtered or unexported fields") } } else { // interface @@ -466,7 +466,7 @@ func (p *printer) fieldList(fields *ast.FieldList, isStruct, isIncomplete bool) p.print(formfeed) } p.flush(p.fset.Position(rbrace), token.RBRACE) // make sure we don't loose the last line comment - p.setLineComment("// contains unexported methods") + p.setLineComment("// contains filtered or unexported methods") } } diff --git a/src/pkg/go/printer/testdata/comments.x b/src/pkg/go/printer/testdata/comments.x index 4d7a928ae0..30a182f490 100644 --- a/src/pkg/go/printer/testdata/comments.x +++ b/src/pkg/go/printer/testdata/comments.x @@ -8,7 +8,7 @@ type SZ struct{} // The S0 struct; no field is exported. type S0 struct { - // contains unexported fields + // contains filtered or unexported fields } // The S1 struct; some fields are not exported. @@ -16,7 +16,7 @@ type S1 struct { S0 A, B, C float // 3 exported fields D int // 2 unexported fields - // contains unexported fields + // contains filtered or unexported fields } // The S2 struct; all fields are exported. @@ -30,14 +30,14 @@ type SZ interface{} // The I0 interface; no method is exported. type I0 interface { - // contains unexported methods + // contains filtered or unexported methods } // The I1 interface; some methods are not exported. type I1 interface { I0 F(x float) float // exported methods - // contains unexported methods + // contains filtered or unexported methods } // The I2 interface; all methods are exported. @@ -53,5 +53,5 @@ type S3 struct { F1 int // line comment for F1 // lead comment for F2 F2 int // line comment for F2 - // contains unexported fields + // contains filtered or unexported fields }