Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module currently includes helper functions to provide fallback support to code actions that use resolve in HLS. The difference between the two functions for code actions that don't support resolve is that mkCodeActionHandlerWithResolve will immediately resolve your code action before sending it on to the client, while mkCodeActionWithResolveAndCommand will turn your resolve into a command.
General support for resolve in HLS can be used with mkResolveHandler from Ide.Types. Resolve theoretically should allow us to delay computation of parts of the request till the client needs it, allowing us to answer requests faster and with less resource usage.
Synopsis
- mkCodeActionHandlerWithResolve :: forall ideState a. FromJSON a => Recorder (WithPriority Log) -> PluginMethodHandler ideState 'Method_TextDocumentCodeAction -> ResolveFunction ideState a 'Method_CodeActionResolve -> PluginHandlers ideState
- mkCodeActionWithResolveAndCommand :: forall ideState a. FromJSON a => Recorder (WithPriority Log) -> PluginId -> PluginMethodHandler ideState 'Method_TextDocumentCodeAction -> ResolveFunction ideState a 'Method_CodeActionResolve -> ([PluginCommand ideState], PluginHandlers ideState)
Documentation
mkCodeActionHandlerWithResolve :: forall ideState a. FromJSON a => Recorder (WithPriority Log) -> PluginMethodHandler ideState 'Method_TextDocumentCodeAction -> ResolveFunction ideState a 'Method_CodeActionResolve -> PluginHandlers ideState Source #
When provided with both a codeAction provider and an affiliated codeAction resolve provider, this function creates a handler that automatically uses your resolve provider to fill out you original codeAction if the client doesn't have codeAction resolve support. This means you don't have to check whether the client supports resolve and act accordingly in your own providers.
mkCodeActionWithResolveAndCommand :: forall ideState a. FromJSON a => Recorder (WithPriority Log) -> PluginId -> PluginMethodHandler ideState 'Method_TextDocumentCodeAction -> ResolveFunction ideState a 'Method_CodeActionResolve -> ([PluginCommand ideState], PluginHandlers ideState) Source #
When provided with both a codeAction provider with a data field and a resolve provider, this function creates a handler that creates a command that uses your resolve if the client doesn't have code action resolve support. This means you don't have to check whether the client supports resolve and act accordingly in your own providers. see Note [Code action resolve fallback to commands] Also: This helper only works with workspace edits, not commands. Any command set either in the original code action or in the resolve will be ignored.