-
-
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
Support Inlay hints for record wildcards #4351
Support Inlay hints for record wildcards #4351
Conversation
to writing test before new release of haskell/lsp.
This reverts commit 245049a.
and remove `instance PluginRequestMethod Method_InlayHintResolve` since have not decide how to combine.
I pushed some commits but it's broken on GHC 9.10.1, I'm working on fixing it. |
I have spent a lot of time trying to fix the problem in higher GHC versions, but so far I can't figure out how to solve it. The failed tests are I tested it in GHC 9.6.5 and 9.10.1. In 9.6.5, there are
haskell-language-server/plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs Lines 496 to 503 in 96a2550
|
@jetjinser Sorry for the delay! I spent a little bit of time on this and while I cannot really tell you what's going wrong, I think this is either a bug in our HLS parsing/type checking pipeline or straight-up a GHC bug. For example, the following {-# LANGUAGE RecordWildCards #-}
-- {-# LANGUAGE RebindableSyntax #-}
{-# LANGUAGE NamedFieldPuns #-}
module HsExpanded2 where
import Prelude
-- ifThenElse :: Int -> Int -> Int -> Int
-- ifThenElse x y z = x + y + z
data MyRec = MyRec
{ foo :: Int }
data YourRec = YourRec
{ bar :: Bool }
myRecExample = MyRec 5
yourRecExample = YourRec True
convertMe :: Int
convertMe =
if (let MyRec {..} = myRecExample
YourRec {..} = yourRecExample
in bar) then 1 else 2 However, this does also not work: convertMe :: Int
convertMe =
(let MyRec {..} = myRecExample
YourRec {..} = yourRecExample
in bar) + 1 + 2 I tested the file with
That means that at least the parser is accurate. My suggestion is to mark this test as broken for GHC 9.10.1 and move on for now. |
I found something else, take this ast representation of the
It looks like FYI, I am using Thus, I am taking back my prior conjecture, this is unlikely to be a HLS or GHC bug :) |
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.
Thanks, this looks quite nice already! Some small nitpicks and proposed changes :)
plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs
Outdated
Show resolved
Hide resolved
plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs
Outdated
Show resolved
Hide resolved
plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs
Show resolved
Hide resolved
plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs
Outdated
Show resolved
Hide resolved
plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs
Outdated
Show resolved
Hide resolved
plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin/ExplicitFields.hs
Outdated
Show resolved
Hide resolved
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 looks good to me now :)
* Provide explicit import in inlay hints * Filter explict imports inlay hints by visible range * Update lsp dep by source-repository-package to writing test before new release of haskell/lsp. * Add test for hls-explicit-imports-plugin inlay hints * Comment inlay hints start position * Use `isSubrangeOf` to test if the range is visible * Remove inlayHintsResolveProvider placeholder for now * Use explicit InlayHintKind_Type * Revert "Update lsp dep by source-repository-package" This reverts commit 245049a. * Combine InlayHints by sconcat them and remove `instance PluginRequestMethod Method_InlayHintResolve` since have not decide how to combine. * compress multiple spaces in abbr import tilte * update test to match inlay hints kind * rename squashedAbbreviateImportTitle to abbreviateImportTitleWithoutModule * Request inlay hints with testEdits * ExplicitImports fallback to codelens when inlay hints not support * fix explicitImports inlayHints test * simplify isInlayHintsSupported * comment fallback * empty list instead of null codeLens * clearify name `paddingLeft` * fix clientCapabilities * add test for inlay hints without its client caps * use codeActionNoInlayHintsCaps to avoid error * simplify isInlayHintSupported * comment about paddingLeft * use null as inlay hints kind * add tooltip for explicit imports inlay hints to improve UX * chore comments * refactor * comment InL [] to indicate no info * ignore refine inlay hints * add plcInlayHintsOn config * update func-test * keep order to make Parser works * always provide refine in code lens * init explicit record fields inlay hints * dotdot location in label part * update test for dotdot location in label part * get(Type)Definition with its Identifier * add flipped filterByRange * filter label with name * update test * re-generate schema * fix explict-record-fields plugin in GHC 910 * fix use correct currentPosition * comment * rename flippedFilterByRange to elementsInRange * refactor: lift * refactor: break pointfree * refactor * recover accidentally deleted macros --------- Co-authored-by: Michael Peyton Jones <me@michaelpj.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
* Provide explicit import in inlay hints * Filter explict imports inlay hints by visible range * Update lsp dep by source-repository-package to writing test before new release of haskell/lsp. * Add test for hls-explicit-imports-plugin inlay hints * Comment inlay hints start position * Use `isSubrangeOf` to test if the range is visible * Remove inlayHintsResolveProvider placeholder for now * Use explicit InlayHintKind_Type * Revert "Update lsp dep by source-repository-package" This reverts commit 245049a. * Combine InlayHints by sconcat them and remove `instance PluginRequestMethod Method_InlayHintResolve` since have not decide how to combine. * compress multiple spaces in abbr import tilte * update test to match inlay hints kind * rename squashedAbbreviateImportTitle to abbreviateImportTitleWithoutModule * Request inlay hints with testEdits * ExplicitImports fallback to codelens when inlay hints not support * fix explicitImports inlayHints test * simplify isInlayHintsSupported * comment fallback * empty list instead of null codeLens * clearify name `paddingLeft` * fix clientCapabilities * add test for inlay hints without its client caps * use codeActionNoInlayHintsCaps to avoid error * simplify isInlayHintSupported * comment about paddingLeft * use null as inlay hints kind * add tooltip for explicit imports inlay hints to improve UX * chore comments * refactor * comment InL [] to indicate no info * ignore refine inlay hints * add plcInlayHintsOn config * update func-test * keep order to make Parser works * always provide refine in code lens * init explicit record fields inlay hints * dotdot location in label part * update test for dotdot location in label part * get(Type)Definition with its Identifier * add flipped filterByRange * filter label with name * update test * re-generate schema * fix explict-record-fields plugin in GHC 910 * fix use correct currentPosition * comment * rename flippedFilterByRange to elementsInRange * refactor: lift * refactor: break pointfree * refactor * recover accidentally deleted macros --------- Co-authored-by: Michael Peyton Jones <me@michaelpj.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
resolve #4211.
This PR adds the feature to provide explicit records by inlay hints.
The inlay hints are located after dotdot and have left padding, It also provides textEdit, which is consistent with the textEdit of code actions.
e.g
part1:
bar
part2:
,
part3:
baz