-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gopls/internal/server: CodeAction: interpret Only=[] as [QuickFix]
This CL changes the interpretation of an empty list of CodeActionKind. Previously, we have always used it to mean "all kinds"; however, the new guidance in the LSP 3.18 spec is that servers should treat it equivalent to [QuickFix]. Following the spec exactly would reduce the frequency of distracting lightbulbs displayed by VS Code's ⌘-. menu for actions that are not fixes (e.g. Inline call to f). But it would deny most clients (VS Code, Emacs, Vim, ...) the natural way to ask the server what code actions are currently available, making it impossible to discover any code action (e.g. Browse gopls docs) that doesn't fit into one of the existing categories with its own command (e.g. Refactor, Source Action). So, we compromise: if the CodeAction query was triggered by cursor motion (Automatic), we treat [] as [QuickFix]. But if it was explicitly Invoked, we respond with all available actions, equivalent to [""]. This does unfortunately double the test space; all but one of our tests (TestVSCodeIssue65167)use TriggerKindUnknown. Details: - Adjust hierarchical matching to permit kind="" (protocol.Empty) to match all kinds. - Change CLI and fake.Editor clients to populate Capabilities.TextDocument.CodeAction.CodeActionLiteralSupport.\ CodeActionKind.ValueSet (!!), a 3.18 feature. (This isn't really needed now that the latest draft returns all available actions when trigger=automatic.) - The @codeaction marker passes kind="". - 'gopls codeaction' now passes Only=[""] when no -kind flag is specified. - 'gopls imports' now passes Only=[SourceOrganizeImports] instead of obsolete title filtering. - Editor.{serverCapabilities,semTokOpts} are no longer unnecessarily guarded by the mutex. (In an earlier draft I needed to expose Editor.ServerCapabilities but it proved unnecessary.) Fixes golang/go#68783 Change-Id: Ia4246c47b54b59f6f03eada3e916428de50c42f4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/616837 Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Findley <rfindley@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
Showing
9 changed files
with
139 additions
and
70 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
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.