haskell / haskell/haskell-language-server

`combineResponses` is suspicious

Open
#2,559 0 comments 0 reactions 0 assignees View on GitHub
component: hls-plugin-api type: enhancement
Dominant language
Haskell
Stars
3k
Forks
455
Avg merge
3d 21h
Merged PRs (30d)
13

Description

`combineResponses` is suspicious in two ways:

1. It does more than combine responses

- For code actions it does a whole bunch of compatibility stuff _and_ filters down to the requested code action kinds: https://github.com/haskell/haskell-language-server/blob/master/hls-plugin-api/src/Ide/Types.hs#L181
- For document symbols, it does some compatibility stuff: https://github.com/haskell/haskell-language-server/blob/master/hls-plugin-api/src/Ide/Types.hs#L227

These are important things to do, but doing them in `combineResponses` is definitely the wrong place. If nothing else, it means that any handlers which don't go through `PluginMethod` won't benefit from this logic!

I'm not sure where this stuff should live, maybe even upstream in `lsp` somewhere. Perhaps we could provide a conformance/compatibility handler-transformer than does this stuff...

2. it has no way to signal errors, so does some "arbitrary" choosing

For formatting providers and custom methods, there is no way to combine responses, so it just picks the first response! IMO this isn't great: if you *do* end up with multiple plugins which have handlers for those methods, one of them will just not work at random. Better to signal some kind of error ("you've enabled plugins A and B which both provide formatting, please disable one of them").

cc @wz1000 who wrote most of this originally.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in hls-plugin-api/src/Ide/Types.hs, especially the combineResponses logic referenced for code actions and document symbols, and trace how PluginMethod uses it. Determine where compatibility and filtering should live, including whether they belong upstream in lsp, and define error handling for multiple formatting or custom-method providers instead of choosing one arbitrarily.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
devtools
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.