Commit b6735211 authored by Robert Griesemer's avatar Robert Griesemer

- 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
parent 9dd2e1e3
...@@ -485,16 +485,13 @@ func (p *parser) parseStructType() *ast.StructType { ...@@ -485,16 +485,13 @@ func (p *parser) parseStructType() *ast.StructType {
pos := p.expect(token.STRUCT); pos := p.expect(token.STRUCT);
lbrace := p.expect(token.LBRACE); lbrace := p.expect(token.LBRACE);
list := vector.New(0); 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(); f := p.parseFieldDecl();
list.Push(f); if p.tok != token.RBRACE {
if p.tok == token.SEMICOLON { p.expect(token.SEMICOLON);
p.next();
f.Comment = p.lineComment;
} else {
f.Comment = p.lineComment;
break;
} }
f.Comment = p.lineComment;
list.Push(f);
} }
rbrace := p.expect(token.RBRACE); rbrace := p.expect(token.RBRACE);
p.optSemi = true; p.optSemi = true;
...@@ -699,10 +696,12 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType { ...@@ -699,10 +696,12 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType {
lbrace := p.expect(token.LBRACE); lbrace := p.expect(token.LBRACE);
list := vector.New(0); list := vector.New(0);
for p.tok == token.IDENT { for p.tok == token.IDENT {
list.Push(p.parseMethodSpec()); m := p.parseMethodSpec();
if p.tok != token.RBRACE { if p.tok != token.RBRACE {
p.expect(token.SEMICOLON); p.expect(token.SEMICOLON);
} }
m.Comment = p.lineComment;
list.Push(m);
} }
rbrace := p.expect(token.RBRACE); rbrace := p.expect(token.RBRACE);
p.optSemi = true; p.optSemi = true;
......
...@@ -42,7 +42,7 @@ type I0 interface { ...@@ -42,7 +42,7 @@ type I0 interface {
// The I1 interface; some methods are not exported. // The I1 interface; some methods are not exported.
type I1 interface { type I1 interface {
I0; I0;
F(x float) float; F(x float) float; // exported methods
// contains unexported methods // contains unexported methods
} }
...@@ -50,6 +50,6 @@ type I1 interface { ...@@ -50,6 +50,6 @@ type I1 interface {
// The I2 interface; all methods are exported. // The I2 interface; all methods are exported.
type I2 interface { type I2 interface {
I0; I0;
F(x float) float; F(x float) float; // exported method
G(x float) float; G(x float) float; // exported method
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment