Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/lsp/source: rewrite hover
Significantly rewrite the logic involved in textDocument/hover requests, eliminate dependence on type checking, and remove the source.Identifier abstraction. The existing logichad become very hard to follow, and while I spent many hours trying to make sure I understood it, some logic seemed inaccurate and other remained opaque. Notably, it appears much of the old code was effectively dead, due to impossible combinations of Node/Object in various execution paths. Rewrite the essential bits of logic from scratch, preserving only that which was necessary for hover (the last user of source.Identifier). After doing this, the intermediate HoverContext and IdentifierInfo data types became unnecessary. Along the way, a pair of decisions impacted gopls observable behavior: - Hovering over a rune was made consistent with other hovering (by way of HoverJSON), which had the side effect of introducing newlines to hover content. - Support for hovering over variables with constant initializers was removed (#58220). This feature will be revisited in a follow-up CL. This eliminates both posToMappedRange and findFileInDeps helpers, which were two of the remaining places where we could incidentally type-check. After this change, the only uses of TypecheckWorkspace are in renaming. For #57987 Change-Id: I3e0d673b914f6277c3713f74450134ceeb181319 Reviewed-on: https://go-review.googlesource.com/c/tools/+/464415 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
- Loading branch information
Showing
13 changed files
with
564 additions
and
1,139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.