-
-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge definitions from all plugins for Document(Type)Definition message #3846
Merge definitions from all plugins for Document(Type)Definition message #3846
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for the addition!
One nitpick and a little bit more documentation, looks good to me as is otherwise :)
mergeDefinitions :: Definitions -> Definitions -> Definitions | ||
mergeDefinitions definitions1 definitions2 = case (definitions1, definitions2) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some haddock explaining what this does, especially what the merging rules are would be great!
hls-plugin-api/src/Ide/Types.hs
Outdated
defToLinks (Definition (InL location)) = [DefinitionLink $ locationToLocationLink location] | ||
defToLinks (Definition (InR locations)) = map (DefinitionLink . locationToLocationLink) locations | ||
|
||
locationToLocationLink :: Location -> LocationLink |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick
How about:
locationToLocationLink :: Location -> LocationLink | |
locationToDefinitionLink :: Location -> DefinitionLink |
Since you use locationToLocationLink
exclusively to create a DefinitionLink
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we don't have tests for any of the other response combination, but if you felt motivated it would be great to start some!
hls-plugin-api/src/Ide/Types.hs
Outdated
defToLinks (Definition (InR locations)) = map (DefinitionLink . locationToLocationLink) locations | ||
|
||
locationToLocationLink :: Location -> LocationLink | ||
locationToLocationLink Location{_uri, _range} = LocationLink{_originSelectionRange = Just _range, _targetUri = _uri, _targetRange = _range, _targetSelectionRange = _range} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, originSelectiomRange
is quite different and we can't come up with a definition for it, so we should put Nothing
.
type Definitions = (Definition |? ([DefinitionLink] |? Null)) | ||
|
||
mergeDefinitions :: Definitions -> Definitions -> Definitions | ||
mergeDefinitions definitions1 definitions2 = case (definitions1, definitions2) of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's are client capabilities controlling whether location links are supported. Ideally we should check those and if they're not sent we should instead downgrade the LocationLink
s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a new downgradeLinks
function instead and used it to downgrade all LocationLink
s in the implementation of combineResponses
when required by the missing capability.
Thank you both for the review. I will address the comments as soon as possible, most likely this week. |
295f25b
to
a3bf0bf
Compare
- enables multiple plugins to provide Document(Type)Definition for the same message
…nLink in combineResponses of plugins to TextDocumentDefinition message
…eResponses (plugin API) - Upgrade locations to links only when necessary (some responses are links)
a3bf0bf
to
f1a69a5
Compare
Oh, it seems I was too eager with the new extensions. I thought I could use GHC 9.6 (probably since it is in the snapshot in the default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good, some of this stuff probably belongs in lsp
, but we can move that later if we want.
Haven't reviewed the tests yet, but happy to merge regardless.
Build failures are genuine. |
I suspect that thanks to the CI cache By the way, do you generally use the |
CI issues should be worked out, can you fix the conflicts and try again? |
Thanks! |
Great, thank you for your help! |
* hls-notes-plugin: Initial implementation * hls-notes-plugin: add to feature list and plugin table * hls-notes-plugin: Add more documentation comments * hls-notes-plugin: Fix tests after #3846, add CI job * hls-notes-plugin: Address review comments * hls-notes-plugin: Allow Note definition within single line comments * hls-notes-plugin: Improve "Note not found" error message * hls-notes-plugin: Allow single line notes to be indented * treewide: Add missing underscores to note definitions * hls-notes-plugin: Wait until HLS is done in tests * hls-notes-plugin: Fix tests on windows The regex did not allow windows line endings in note definitions --------- Co-authored-by: Jan Hrcek <2716069+jhrcek@users.noreply.github.com> Co-authored-by: fendor <fendor@users.noreply.github.com>
This PR fixes issue #3634 by merging the definition responses from all plugins into one definition response. It (only when necessary) transforms
Location
toLocationLink
as suggested by @michaelpj in the issue.I didn't refactor the type the plugins return as suggested by @joyfulmantis, because I think it will be better to address it in a separate PR and have a straightforward fix merged before that.