Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
Fix panic when accessing documents (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismwendt authored Feb 18, 2022
1 parent f7ea242 commit 17f6f0e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/indexer/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ func (i *Indexer) emitImportMonikerReference(p *packages.Package, pkg *packages.
name := spec.Path.Value

position, document, _ := i.positionAndDocument(p, pos)
if document == nil {
return
}
obj := types.NewPkgName(pos, p.Types, name, pkg.Types)

rangeID, _ := i.ensureRangeFor(position, obj)
Expand Down Expand Up @@ -476,6 +479,9 @@ func (i *Indexer) emitImportMonikerNamedDefinition(p *packages.Package, pkg *pac
}

position, document, _ := i.positionAndDocument(p, pos)
if document == nil {
return
}
obj := types.NewPkgName(pos, p.Types, name, pkg.Types)

rangeID, _ := i.ensureRangeFor(position, obj)
Expand Down Expand Up @@ -526,7 +532,7 @@ func (i *Indexer) indexDefinitionsForPackage(p *packages.Package) {
}

position, document, ok := i.positionAndDocument(p, obj.Pos())
if !ok {
if !ok || document == nil {
continue
}

Expand Down Expand Up @@ -753,7 +759,7 @@ func (i *Indexer) indexReferencesForPackage(p *packages.Package) {
}

pos, document, ok := i.positionAndDocument(p, ident.Pos())
if !ok {
if !ok || document == nil {
continue
}

Expand Down Expand Up @@ -1015,7 +1021,7 @@ func (i *Indexer) indexPackageDeclarationForPackage(p *packages.Package) {

name := obj.Name()
_, d, ok := i.positionAndDocument(p, obj.Pos())
if !ok {
if !ok || d == nil {
return
}

Expand All @@ -1041,7 +1047,7 @@ func (i *Indexer) indexPackageDeclarationForPackage(p *packages.Package) {
name := obj.Name()

_, document, ok := i.positionAndDocument(p, obj.Pos())
if !ok {
if !ok || document == nil {
continue
}
ident := &ast.Ident{
Expand Down

0 comments on commit 17f6f0e

Please sign in to comment.