-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
[Feature Request] Add missing fields in record #333
Comments
I think this should be a completion provider |
A completion provider would be great. But in Rust, it's also a diagnostic fix, which has been a very nice way to use it. |
I plan to take a stab at this, thanks to @pepeiborra's awesome tutorial on how to write a plugin. So, should I start exploring this as a completion provider? I was able to explore the Can one of you provide me pointers, on where I can explore the AST information in ghcide for this? |
Look at how completions are done in ghcide, in particular check https://github.com/haskell/ghcide/blob/9ae5134d79972405415ce5062dbae67aeb938f21/src/Development/IDE/Plugin/Completions/Logic.hs#L232 You will need to generate new completions for records that include not only the constructor, but also the fields. For that you will need to find all the |
I am testing this now, and we do get completions for records. I have added some tests to show what I found so far: Looks, like what we need is inspection of currently used fields in the context and provide a code action for missing fields. Which kind of suggests, we should use diagnostics as the original issue comment suggested. Now, I need to look at, how to determine if I am inside a context of Of course, in terms of enhancements, creating a |
I observed and added tests to show that missing record fields are already being report under diagnostics by hls. haskell/ghcide#824. Please suggest if we would like to extend this any further as part of this issue. Perhaps, we need a code action generated for each missing field? |
I have started iterating over the changes required for this feature. For now, I have support for Local completions. Please could I have some feedback on the initial approach and if I can proceed in this path to support completions that are available from other modules. #512 |
Before this change: [nix-shell:~/scratch/ghcide]$ /home/pepe/scratch/ghcide/dist-newstyle/build/x86_64-linux/ghc-8.8.1/ghcide-0.0.6/x/ghcide/build/ghcide/ghcide +RTS --info [("GHC RTS", "YES") ,("GHC version", "8.8.1") ,("RTS way", "rts_thr_p") ,("Build platform", "x86_64-unknown-linux") ,("Build architecture", "x86_64") ,("Build OS", "linux") ,("Build vendor", "unknown") ,("Host platform", "x86_64-unknown-linux") ,("Host architecture", "x86_64") ,("Host OS", "linux") ,("Host vendor", "unknown") ,("Target platform", "x86_64-unknown-linux") ,("Target architecture", "x86_64") ,("Target OS", "linux") ,("Target vendor", "unknown") ,("Word size", "64") ,("Compiler unregisterised", "NO") ,("Tables next to code", "YES") ,("Flag -with-rtsopts", "-A128M") ] After this change: [nix-shell:~/scratch/ghcide]$ /home/pepe/scratch/ghcide/dist-newstyle/build/x86_64-linux/ghc-8.8.1/ghcide-0.0.6/x/ghcide/build/ghcide/ghcide +RTS --info [("GHC RTS", "YES") ,("GHC version", "8.8.1") ,("RTS way", "rts_thr") ,("Build platform", "x86_64-unknown-linux") ,("Build architecture", "x86_64") ,("Build OS", "linux") ,("Build vendor", "unknown") ,("Host platform", "x86_64-unknown-linux") ,("Host architecture", "x86_64") ,("Host OS", "linux") ,("Host vendor", "unknown") ,("Target platform", "x86_64-unknown-linux") ,("Target architecture", "x86_64") ,("Target OS", "linux") ,("Target vendor", "unknown") ,("Word size", "64") ,("Compiler unregisterised", "NO") ,("Tables next to code", "YES") ,("Flag -with-rtsopts", "-I0 -qg -A128M") ]
Can we close this issue now? |
Yeah, thanks @gdevanla |
It would be great if HLS could hint a code action to add (and import) missing fields of a record.
Say I write (using the process library)
many other fields are missing (see doc), and need to be imported.
The text was updated successfully, but these errors were encountered: