1
0
mirror of https://github.com/golang/go synced 2024-10-01 01:38:33 -06:00

internal/lsp/cache: clean up parse.go

switch the ioLimit channel from a bool to a struct{} as the values
stuffed into the channel have no meaning.

A mix of consistency and comment cleanups in *importer.parseFiles.

sameFile is reported as unused, so removed, removing some now unused
imports.

The assignment to lit in *view.parseDeferOrGoStmt's for{} loop was
reported as ineffective.

Update the comment of fix a little for clarity.

Change-Id: I50f0442bfd7e4d0cc0e6fdadbf1f6272366a716c

Change-Id: I50f0442bfd7e4d0cc0e6fdadbf1f6272366a716c
GitHub-Last-Rev: 74d8a8bdb768a827db3c1fd1723a528818e222ee
GitHub-Pull-Request: golang/tools#109
Reviewed-on: https://go-review.googlesource.com/c/tools/+/179957
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Edward Muller 2019-07-28 00:52:02 +00:00 committed by Rebecca Stambler
parent ff9f140924
commit 7deaedd405

View File

@ -18,7 +18,7 @@ import (
) )
// Limits the number of parallel parser calls per process. // Limits the number of parallel parser calls per process.
var parseLimit = make(chan bool, 20) var parseLimit = make(chan struct{}, 20)
// parseKey uniquely identifies a parsed Go file. // parseKey uniquely identifies a parsed Go file.
type parseKey struct { type parseKey struct {
@ -80,7 +80,7 @@ func parseGo(ctx context.Context, c *cache, fh source.FileHandle, mode source.Pa
if err != nil { if err != nil {
return nil, err return nil, err
} }
parseLimit <- true parseLimit <- struct{}{}
defer func() { <-parseLimit }() defer func() { <-parseLimit }()
parserMode := parser.AllErrors | parser.ParseComments parserMode := parser.AllErrors | parser.ParseComments
if mode == source.ParseHeader { if mode == source.ParseHeader {
@ -140,8 +140,8 @@ func isEllipsisArray(n ast.Expr) bool {
return ok return ok
} }
// fix inspects and potentially modifies any *ast.BadStmts or *ast.BadExprs in the AST. // fix inspects the AST and potentially modifies any *ast.BadStmts so that it can be
// We attempt to modify the AST such that we can type-check it more effectively. // type-checked more effectively.
func fix(ctx context.Context, file *ast.File, tok *token.File, src []byte) error { func fix(ctx context.Context, file *ast.File, tok *token.File, src []byte) error {
var parent ast.Node var parent ast.Node
var err error var err error
@ -207,7 +207,7 @@ func parseDeferOrGoStmt(bad *ast.BadStmt, parent ast.Node, tok *token.File, src
var to, curr token.Pos var to, curr token.Pos
FindTo: FindTo:
for { for {
curr, tkn, lit = s.Scan() curr, tkn, _ = s.Scan()
// TODO(rstambler): This still needs more handling to work correctly. // TODO(rstambler): This still needs more handling to work correctly.
// We encounter a specific issue with code that looks like this: // We encounter a specific issue with code that looks like this:
// //