mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
internal/lsp: ensure that an AST cannot be nil without an error
Fixes golang/go#34366 Change-Id: I2f5269cd0b270aef5accc69adeced8be4523cb65 Reviewed-on: https://go-review.googlesource.com/c/tools/+/196142 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
3d643c64ae
commit
2c18af7e64
13
internal/lsp/cache/parse.go
vendored
13
internal/lsp/cache/parse.go
vendored
@ -130,14 +130,19 @@ func parseGo(ctx context.Context, c *cache, fh source.FileHandle, mode source.Pa
|
||||
log.Error(ctx, "failed to fix AST", err)
|
||||
}
|
||||
}
|
||||
// If the file is nil only due to parse errors,
|
||||
// the parse errors are the actual errors.
|
||||
|
||||
if file == nil {
|
||||
return nil, nil, parseError, parseError
|
||||
// If the file is nil only due to parse errors,
|
||||
// the parse errors are the actual errors.
|
||||
err := parseError
|
||||
if err == nil {
|
||||
err = errors.Errorf("no AST for %s", fh.Identity().URI)
|
||||
}
|
||||
return nil, nil, parseError, err
|
||||
}
|
||||
tok := c.FileSet().File(file.Pos())
|
||||
if tok == nil {
|
||||
return nil, nil, parseError, err
|
||||
return nil, nil, parseError, errors.Errorf("no token.File for %s", fh.Identity().URI)
|
||||
}
|
||||
uri := fh.Identity().URI
|
||||
content, _, err := fh.Read(ctx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user