1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:05:00 -07:00

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
This commit is contained in:
Robert Griesemer 2011-05-12 09:01:50 -07:00
parent d376935a18
commit 82d1a9dce7
2 changed files with 7 additions and 7 deletions

View File

@ -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")
}
}

View File

@ -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
}