diff options
author | Agniva De Sarker <agnivade@yahoo.co.in> | 2019-07-08 20:33:42 +0530 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2019-07-08 20:59:49 +0000 |
commit | a19c0ceda59b2223ca873b61f059c8ccb447fa80 (patch) | |
tree | 186757715fb761051f43ebb484eace2703f1450b /src/go/parser/parser.go | |
parent | c893ea8f8b5fc824b1fdd0b2e56d0cda5eacb02b (diff) | |
download | go-a19c0ceda59b2223ca873b61f059c8ccb447fa80.tar.gz go-a19c0ceda59b2223ca873b61f059c8ccb447fa80.zip |
Revert "go/parser: include more comments in a struct or interface"
This reverts commit https://golang.org/cl/161177/.
Reason for revert: this led to non-contiguous comments spaced
by an empty line to be grouped into a single CommentGroup
Fixes #32944
Updates #10858
Change-Id: I5e16663b308c3b560496da8e66c33befdf9ed9dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/185040
Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/go/parser/parser.go')
-rw-r--r-- | src/go/parser/parser.go | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go index 9294bb6b3e..ba16b65224 100644 --- a/src/go/parser/parser.go +++ b/src/go/parser/parser.go @@ -63,7 +63,6 @@ type parser struct { topScope *ast.Scope // top-most scope; may be pkgScope unresolved []*ast.Ident // unresolved identifiers imports []*ast.ImportSpec // list of imports - inStruct bool // if set, parser is parsing a struct or interface (for comment collection) // Label scopes // (maintained by open/close LabelScope) @@ -338,15 +337,7 @@ func (p *parser) next() { // consume successor comments, if any endline = -1 for p.tok == token.COMMENT { - n := 1 - // When inside a struct (or interface), we don't want to lose comments - // separated from individual field (or method) documentation by empty - // lines. Allow for some white space in this case and collect those - // comments as a group. See issue #10858 for details. - if p.inStruct { - n = 2 - } - comment, endline = p.consumeCommentGroup(n) + comment, endline = p.consumeCommentGroup(1) } if endline+1 == p.file.Line(p.pos) { @@ -757,7 +748,6 @@ func (p *parser) parseStructType() *ast.StructType { } pos := p.expect(token.STRUCT) - p.inStruct = true lbrace := p.expect(token.LBRACE) scope := ast.NewScope(nil) // struct scope var list []*ast.Field @@ -768,7 +758,6 @@ func (p *parser) parseStructType() *ast.StructType { list = append(list, p.parseFieldDecl(scope)) } rbrace := p.expect(token.RBRACE) - p.inStruct = false return &ast.StructType{ Struct: pos, @@ -970,7 +959,6 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType { } pos := p.expect(token.INTERFACE) - p.inStruct = true lbrace := p.expect(token.LBRACE) scope := ast.NewScope(nil) // interface scope var list []*ast.Field @@ -978,7 +966,6 @@ func (p *parser) parseInterfaceType() *ast.InterfaceType { list = append(list, p.parseMethodSpec(scope)) } rbrace := p.expect(token.RBRACE) - p.inStruct = false return &ast.InterfaceType{ Interface: pos, |