Skip to content

Commit

Permalink
lsp: No error when missing keywords for hover (StyraInc#974)
Browse files Browse the repository at this point in the history
This means that the keywords for the file have not been computed yet and
should be shortly.

There is unlikely much that this message would help with so I have
removed it.

The error when processing hover content updates should be enough to
establish that the keywords are not being computed, if that ever were to
be the case.

Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 authored and srenatus committed Oct 1, 2024
1 parent 72870c3 commit d04fc3e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (l *LanguageServer) StartHoverWorker(ctx context.Context) {
case evt := <-l.builtinsPositionFile:
err := l.processHoverContentUpdate(ctx, evt.URI, evt.Content)
if err != nil {
l.logError(fmt.Errorf("failed to process builtin positions update: %w", err))
l.logError(fmt.Errorf("failed to process builtin and keyword positions update: %w", err))
}
}
}
Expand Down Expand Up @@ -707,6 +707,8 @@ func (l *LanguageServer) processTextContentUpdate(
return false, nil
}

// processHoverContentUpdate updates information about built in, and keyword
// positions in the cache for use when handling hover requests.
func (l *LanguageServer) processHoverContentUpdate(ctx context.Context, fileURI string, content string) error {
if l.ignoreURI(fileURI) {
return nil
Expand Down Expand Up @@ -836,10 +838,8 @@ func (l *LanguageServer) handleTextDocumentHover(
}

keywordsOnLine, ok := l.cache.GetKeywordLocations(params.TextDocument.URI)
// when no keywords are found, we can't return a useful hover response.
if !ok {
l.logError(fmt.Errorf("could not get keywords for uri %q", params.TextDocument.URI))

// when no keywords are found, we can't return a useful hover response.
// return "null" as per the spec
return nil, nil
}
Expand Down

0 comments on commit d04fc3e

Please sign in to comment.