Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Insert imports code action #295

Merged
merged 3 commits into from
Jan 6, 2020
Merged

Conversation

pepeiborra
Copy link
Collaborator

Initial stab at a code action to insert imports based on GHC suggestions. Outstanding issues (to my knowledge):

  • the suggestions for missing constructors lead to compile errors when applied, see below. To deal with this, a second code action is provided to fix these imports.
    In module ‘Data.Maybe’:
      ‘Just’ is a data constructor of ‘Maybe’
    To import it use
      import Data.Maybe( Maybe( Just ) )
    or
      import Data.Maybe( Maybe(..) )
  • If a missing constructor has the same name as the defining data type (e.g. Identity), neither code action can deal with it properly.

I'd say that this PR gets ghcide 80% there. I will add tests for these outstanding issues later today.

@pepeiborra
Copy link
Collaborator Author

This is ready for review

@cocreature cocreature self-assigned this Jan 6, 2020
Copy link
Collaborator

@cocreature cocreature left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, thanks a lot!

@cocreature cocreature merged commit fd163cd into haskell:master Jan 6, 2020
pepeiborra added a commit to pepeiborra/ghcide that referenced this pull request Feb 1, 2020
*  #46 Code action to add suggested imports

* code action to fix constructor imports

* #46 Add test for (broken) constructor import
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
*  haskell/ghcide#46 Code action to add suggested imports

* code action to fix constructor imports

* haskell/ghcide#46 Add test for (broken) constructor import
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
*  haskell/ghcide#46 Code action to add suggested imports

* code action to fix constructor imports

* haskell/ghcide#46 Add test for (broken) constructor import
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
*  haskell/ghcide#46 Code action to add suggested imports

* code action to fix constructor imports

* haskell/ghcide#46 Add test for (broken) constructor import
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants