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

Also suggest importing methods without parent class #766

Merged
merged 4 commits into from
Jan 5, 2021

Conversation

mrBliss
Copy link
Contributor

@mrBliss mrBliss commented Dec 31, 2020

For example, when using foldl' without it being imported, the following import suggestions are currently given:

  • import Data.Foldable
  • import Data.Foldable (Foldable(foldl'))
  • ...

This PR adds an additional suggestion to import the method as a top-level export, without mentioning the class:

  • import Data.Foldable
  • import Data.Foldable (Foldable(foldl'))
  • import Data.Foldable (foldl')
  • ...

Besides methods, this suggestion is made for associated type and data families, but not for constructors. A constructor must always be imported as part of its enclosing data type.

This PR adds the same suggestions when extending an existing import list.

@mrBliss
Copy link
Contributor Author

mrBliss commented Jan 4, 2021

I'll rebase this branch to solve the merge conflict caused by merging #769.

UPDATE: force-pushed.

Let the order of the expected code actions dictate which one to execute, i.e.,
the first one. This means we no longer test the *order* of the suggested code
actions. Through this simple change, we can now test the execution of a code
action that doesn't come first in the list of suggested code actions.
When suggesting to import a method `m` of class `C` from module `M`, in addition
to the suggestions `import M` and `import M (C(m))`, also suggest importing the
method without mentioning the enclosing class: `import M (m)`.
@mrBliss mrBliss force-pushed the import-without-parent branch from 2beb1e4 to 25d3dfb Compare January 4, 2021 09:03
Copy link
Collaborator

@pepeiborra pepeiborra left a comment

Choose a reason for hiding this comment

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

very nice, thanks!

@pepeiborra pepeiborra added the merge me Label to trigger pull request merge label Jan 5, 2021
@mergify mergify bot merged commit 8b7090f into haskell:master Jan 5, 2021
@mrBliss mrBliss deleted the import-without-parent branch January 5, 2021 11:20
pepeiborra pushed a commit to pepeiborra/ide that referenced this pull request Jan 9, 2021
* Make it possible to choose the code action in extendImportTests

Let the order of the expected code actions dictate which one to execute, i.e.,
the first one. This means we no longer test the *order* of the suggested code
actions. Through this simple change, we can now test the execution of a code
action that doesn't come first in the list of suggested code actions.

* Suggest imports without the parent class

When suggesting to import a method `m` of class `C` from module `M`, in addition
to the suggestions `import M` and `import M (C(m))`, also suggest importing the
method without mentioning the enclosing class: `import M (m)`.

Co-authored-by: Javier Neira <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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.

3 participants