From 1847bda6c68066da439c56f11215da776bc8c87e Mon Sep 17 00:00:00 2001 From: Joe Kralicky Date: Sat, 3 Aug 2024 15:30:37 -0400 Subject: [PATCH] Bugfixes --- go.mod | 2 +- go.sum | 2 ++ pkg/lsp/semantic.go | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 7805fab..8a0e299 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/google/uuid v1.6.0 github.com/kralicky/codegen v0.0.0-20240522012557-5193d3fdbeca github.com/kralicky/gpkg v0.0.0-20240119195700-64f32830b14f - github.com/kralicky/protocompile v0.0.0-20240619225839-bdb3c73b0a9f + github.com/kralicky/protocompile v0.0.0-20240803192845-d63fb51209b3 github.com/kralicky/tools-lite v0.0.0-20240313161632-60bfa88304ff github.com/mattn/go-tty v0.0.7 github.com/mitchellh/mapstructure v1.5.0 diff --git a/go.sum b/go.sum index 604dec1..3eb814a 100644 --- a/go.sum +++ b/go.sum @@ -45,6 +45,8 @@ github.com/kralicky/gpkg v0.0.0-20240119195700-64f32830b14f h1:MsNe8A51V+7Fu5OMX github.com/kralicky/gpkg v0.0.0-20240119195700-64f32830b14f/go.mod h1:vOkwMjs49XmP/7Xfo9ZL6eg2ei51lmtD/4U/Az5GTq8= github.com/kralicky/protocompile v0.0.0-20240619225839-bdb3c73b0a9f h1:qC7Xkx8Kq5wgiN2fo+1zLXVWhZfMWC6DHVgv+mCh7gA= github.com/kralicky/protocompile v0.0.0-20240619225839-bdb3c73b0a9f/go.mod h1:aE9D9loDNucSzYmT854laAVbgGQwGOckiSXYuwAJJSI= +github.com/kralicky/protocompile v0.0.0-20240803192845-d63fb51209b3 h1:wCDUvsVb3BjsIAO0f3bZsrLuLno0cdfDumnouC+/iRg= +github.com/kralicky/protocompile v0.0.0-20240803192845-d63fb51209b3/go.mod h1:aE9D9loDNucSzYmT854laAVbgGQwGOckiSXYuwAJJSI= github.com/kralicky/tools-lite v0.0.0-20240313161632-60bfa88304ff h1:akxm/czMYHdr1xIGm6wmddABmc4M9KDcqksdwpIJx8A= github.com/kralicky/tools-lite v0.0.0-20240313161632-60bfa88304ff/go.mod h1:V8GGYRLr40bvX/W3nZFxG+6S3iDFWn6o5J3NGDClr8U= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= diff --git a/pkg/lsp/semantic.go b/pkg/lsp/semantic.go index ad67200..955a49f 100644 --- a/pkg/lsp/semantic.go +++ b/pkg/lsp/semantic.go @@ -183,6 +183,9 @@ func semanticTokensRange(cache *Cache, doc protocol.TextDocumentIdentifier, rng maybeLinkRes: maybeLinkRes, } a := enc.AST() + if a == nil { + return nil, fmt.Errorf("no AST for %s", doc.URI) + } startOff, endOff, _ := mapper.RangeOffsets(rng) startToken := a.TokenAtOffset(startOff) endToken := a.TokenAtOffset(endOff)