mirror of https://github.com/golang/go.git
internal/lsp/cache: handle nil pointer exception in missing module error
Fixes golang/go#42349 Change-Id: I171495005298b8f55ae75ded5c2f40e457748082 Reviewed-on: https://go-review.googlesource.com/c/tools/+/267118 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
3f6de07740
commit
f46e424521
|
|
@ -415,10 +415,15 @@ func directnessError(m *protocol.ColumnMapper, req *modfile.Require, computeEdit
|
|||
}
|
||||
|
||||
func missingModuleError(snapshot source.Snapshot, pm *source.ParsedModule, req *modfile.Require) (source.Error, error) {
|
||||
start, end := pm.File.Module.Syntax.Span()
|
||||
rng, err := rangeFromPositions(pm.Mapper, start, end)
|
||||
if err != nil {
|
||||
return source.Error{}, err
|
||||
var rng protocol.Range
|
||||
// Default to the start of the file if there is no module declaration.
|
||||
if pm.File != nil && pm.File.Module != nil && pm.File.Module.Syntax != nil {
|
||||
start, end := pm.File.Module.Syntax.Span()
|
||||
var err error
|
||||
rng, err = rangeFromPositions(pm.Mapper, start, end)
|
||||
if err != nil {
|
||||
return source.Error{}, err
|
||||
}
|
||||
}
|
||||
args, err := source.MarshalArgs(pm.Mapper.URI, []string{req.Mod.Path + "@" + req.Mod.Version})
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue