Skip to content
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

Add custom code action kinds for import related code actions #1570

Merged
merged 7 commits into from
Mar 15, 2021

Conversation

berberman
Copy link
Collaborator

Closes #1556

Suggestions are welcome! /cc @isovector

Several examples:

Code Action Title Before After Code Action Kind
Add stuffA to the import list of ModuleA import ModuleA (stuffB) import ModuleA (stuffB, stuffA) quickfix.import.extend.thing.topLevel
Add A to the import list of ModuleA import ModuleA () import ModuleA (A) quickfix.import.extend.thing.topLevel
Add A(Constructor) to the import list of ModuleA import ModuleA (A) import ModuleA (A (Constructor)) quickfix.import.extend.thing.withParent
import Bar (Bar) import Bar (Bar) quickfix.import.new.thing.topLevel
import Bar (Bar(Bar)) import Bar (Bar(Bar)) quickfix.import.new.thing.withParent
import Numeric.Natural import Numeric.Natural quickfix.import.new.all
import qualified Data.List.NonEmpty as NE import qualified Data.List.NonEmpty as NE quickfix.import.new.qualified

@pepeiborra
Copy link
Collaborator

Just a minor nitpick, I would prefer list instead of thing for the imports that extend or create an import list, eg. quickfix.import.extend.list.topLevel and quickfix.import.new.list.toplevel

@isovector
Copy link
Collaborator

This is marvelous, thanks so much!

@berberman berberman added the merge me Label to trigger pull request merge label Mar 15, 2021
@mergify mergify bot merged commit 0e9dca4 into haskell:master Mar 15, 2021
@berberman berberman deleted the import-ca-kinds branch March 15, 2021 02:48
@pepeiborra
Copy link
Collaborator

@berberman we should document these names in the read me and add instructions on how to use them

@berberman
Copy link
Collaborator Author

Yeah, and I think we should document all ghcide code actions in some place

@michaelpj
Copy link
Collaborator

👍 for documenting all these as they come up.

One thing that occurs to me with the naming: it would be nice if the kind and the message sort of had the same structure and terminology? Let me show what I mean:

kind current suggestion
quickfix.import.extend.list.topLevel Add stuffA to the import list of ModuleA Import: extend the import list of ModuleA with the top-level entity stuffA
quickfix.import.extend.list.withParent Add A(Constructor) to the import list of ModuleA Import: extend the import list of ModuleA with the entity Constructor and its parent A
quickfix.import.new.thing.topLevel import Bar (Bar) Import: add a new import importing the top-level entity Bar

etc.

At the moment there's a sort of implicit translation of terminology that users have to do: "add to import list" -> "extend"; "" -> "create a new import"; "top-level" and "withParent" aren't used in those ways.

@pepeiborra
Copy link
Collaborator

@berberman we are very close to having full import management on save, the main thing missing is "remove redundant import", which did not get a custom kind in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add LSP kinds to "import" code actions
4 participants