mirror of https://github.com/golang/go.git
internal/lsp/mod: handle nil pointers in code lenses
Fixes golang/vscode-go#650 Change-Id: I05a3991853d9e61a2e287d4d166264cdbf7231ba Reviewed-on: https://go-review.googlesource.com/c/tools/+/255127 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Go Bot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
56d9a0cd34
commit
587cf2330c
|
|
@ -44,6 +44,9 @@ func upgradeLens(ctx context.Context, snapshot source.Snapshot, fh source.FileHa
|
|||
if !ok {
|
||||
continue
|
||||
}
|
||||
if req.Syntax == nil {
|
||||
continue
|
||||
}
|
||||
// Get the range of the require directive.
|
||||
rng, err := positionsToRange(fh.URI(), pm.Mapper, req.Syntax.Start, req.Syntax.End)
|
||||
if err != nil {
|
||||
|
|
@ -103,6 +106,9 @@ func tidyLens(ctx context.Context, snapshot source.Snapshot, fh source.FileHandl
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if pm.File == nil || pm.File.Module == nil || pm.File.Module.Syntax == nil {
|
||||
return nil, fmt.Errorf("no parsed go.mod for %s", fh.URI())
|
||||
}
|
||||
rng, err := positionsToRange(pm.Mapper.URI, pm.Mapper, pm.File.Module.Syntax.Start, pm.File.Module.Syntax.End)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -126,6 +132,9 @@ func vendorLens(ctx context.Context, snapshot source.Snapshot, fh source.FileHan
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if pm.File == nil || pm.File.Module == nil || pm.File.Module.Syntax == nil {
|
||||
return nil, fmt.Errorf("no parsed go.mod for %s", fh.URI())
|
||||
}
|
||||
rng, err := positionsToRange(pm.Mapper.URI, pm.Mapper, pm.File.Module.Syntax.Start, pm.File.Module.Syntax.End)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
Loading…
Reference in New Issue