mirror of
https://github.com/golang/go
synced 2024-11-22 00:54:43 -07:00
- collect line comments for methods in interfaces
(previously not shown in godoc) - simplify parsing of struct types (match code structure for parsing interface types) R=rsc, r http://go/go-review/1016019
This commit is contained in:
parent
9dd2e1e30f
commit
b67352110f
@ -485,16 +485,13 @@ func (p *parser) parseStructType() *ast.StructType {
|
||||
pos := p.expect(token.STRUCT);
|
||||
lbrace := p.expect(token.LBRACE);
|
||||
list := vector.New(0);
|
||||
for p.tok != token.RBRACE && p.tok != token.EOF {
|
||||
for p.tok == token.IDENT || p.tok == token.MUL {
|
||||
f := p.parseFieldDecl();
|
||||
list.Push(f);
|
||||
if p.tok == token.SEMICOLON {
|
||||
p.next();
|
||||
f.Comment = p.lineComment;
|
||||
} else {
|
||||
f.Comment = p.lineComment;
|
||||
break;
|
||||
if p.tok != token.RBRACE {
|
||||
p.expect(token.SEMICOLON);
|
||||
}
|
||||
f.Comment = p.lineComment;
|
||||
list.Push(f);
|
||||
}
|
||||
rbrace := p.expect(token.RBRACE);
|
||||
p.optSemi = true;
|
||||
@ -699,10 +696,12 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
|
||||
lbrace := p.expect(token.LBRACE);
|
||||
list := vector.New(0);
|
||||
for p.tok == token.IDENT {
|
||||
list.Push(p.parseMethodSpec());
|
||||
m := p.parseMethodSpec();
|
||||
if p.tok != token.RBRACE {
|
||||
p.expect(token.SEMICOLON);
|
||||
}
|
||||
m.Comment = p.lineComment;
|
||||
list.Push(m);
|
||||
}
|
||||
rbrace := p.expect(token.RBRACE);
|
||||
p.optSemi = true;
|
||||
|
6
src/pkg/go/printer/testdata/comments.x
vendored
6
src/pkg/go/printer/testdata/comments.x
vendored
@ -42,7 +42,7 @@ type I0 interface {
|
||||
// The I1 interface; some methods are not exported.
|
||||
type I1 interface {
|
||||
I0;
|
||||
F(x float) float;
|
||||
F(x float) float; // exported methods
|
||||
// contains unexported methods
|
||||
}
|
||||
|
||||
@ -50,6 +50,6 @@ type I1 interface {
|
||||
// The I2 interface; all methods are exported.
|
||||
type I2 interface {
|
||||
I0;
|
||||
F(x float) float;
|
||||
G(x float) float;
|
||||
F(x float) float; // exported method
|
||||
G(x float) float; // exported method
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user