Skip to content

Adding placeholder for instance method is inserted in the wrong section #2947

Open
@fendor

Description

@fendor

Your environment

Which OS do you use: Arch
Which LSP client (editor/plugin) do you use: VSCode
Describe your project (alternative: link to the project): HLS
GHC: 8.10.7

Steps to reproduce

write

instance PluginMethod TextDocumentDocumentHighlight where

like this between:

class HasTracing (MessageParams m) => PluginMethod m where

  -- | Parse the configuration to check if this plugin is enabled
  pluginEnabled :: SMethod m -> MessageParams m -> PluginDescriptor c -> Config -> Bool

  -- | How to combine responses from different plugins
  combineResponses
    :: SMethod m
    -> Config -- ^ IDE Configuration
    -> ClientCapabilities
    -> MessageParams m
    -> NonEmpty (ResponseResult m) -> ResponseResult m

  default combineResponses :: Semigroup (ResponseResult m)
    => SMethod m -> Config -> ClientCapabilities -> MessageParams m -> NonEmpty (ResponseResult m) -> ResponseResult m
  combineResponses _method _config _caps _params = sconcat

instance PluginMethod TextDocumentDocumentHighlight where

instance PluginMethod TextDocumentCodeAction where
  pluginEnabled _ msgParams pluginDesc config =
    pluginResponsible uri pluginDesc && pluginEnabledConfig plcCodeActionsOn (pluginId pluginDesc) config
    where
      uri = msgParams ^. J.textDocument . J.uri
...

Triggering "Add placeholder for 'pluginEnabled'" leads to this change:

instance PluginMethod TextDocumentCodeAction where
  pluginEnabled _ msgParams pluginDesc config =
    pluginResponsible uri pluginDesc && pluginEnabledConfig plcCodeActionsOn (pluginId pluginDesc) config
    where
  pluginEnabled = _
      uri = msgParams ^. J.textDocument . J.uri

Note, the method was added to the wrong instance and produced invalid code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    component: hls-class-plugintype: bugSomething isn't right: doesn't work as intended, documentation is missing/outdated, etc..

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions