Skip to content

Wrong module name suggestions when using a bios cradle #1903

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

Closed
jneira opened this issue Jun 9, 2021 · 4 comments · Fixed by #2195
Closed

Wrong module name suggestions when using a bios cradle #1903

jneira opened this issue Jun 9, 2021 · 4 comments · Fixed by #2195
Labels
component: plugins type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@jneira
Copy link
Member

jneira commented Jun 9, 2021

-ihaskell/typeclasses/src
-XApplicativeDo
-XBlockArguments
-XDeriveFunctor
[...]
Typeclasses.Postgres.Querying
Typeclasses.Postgres.Connection.PoolSetup
Typeclasses.Postgres.Connection.Secrets
[...]
  • Wrong recommendation:

Screenshot from 2021-06-08 13-48-00

/cc @tittoassini (plugin author)

@jneira jneira added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: plugins labels Jun 9, 2021
@jneira jneira changed the title module name plugin wrong module name suggestions when using a cradle that outputs module names instead paths Wrong module name suggestions when using a cradle that outputs module names instead paths Jun 9, 2021
@chris-martin
Copy link

I've also tried modifying my cradle to output paths instead, and I still get the same result.

@jneira jneira changed the title Wrong module name suggestions when using a cradle that outputs module names instead paths Wrong module name suggestions when using a bios cradle Jun 9, 2021
@jneira
Copy link
Member Author

jneira commented Jun 9, 2021

Yeah it seems it is picking the workspace root dir (where the hie.yaml lives?) instead ${workspace_root}/haskell/typeclasses/src as base dir to produce suggestions

@cdsmith
Copy link
Contributor

cdsmith commented Sep 15, 2021

There are two problems here, one with haskell-language-server, and one with the test case:

  1. The problem with the test case is that it doesn't clear the import paths, so . is still in there. You can fix this by passing just -i followed by -ihaskell/typeclasses/src. The first argument clear the list of import paths to remove .
  2. The problem with haskell-language-server is that the module name plugin misbehaves when one source path is nested inside of another. It should really check whether the module name is correct relative to any of the import paths, rather than stopping at the first one.

@cdsmith
Copy link
Contributor

cdsmith commented Sep 15, 2021

I'm working on a PR for this.

cdsmith added a commit to cdsmith/haskell-language-server that referenced this issue Sep 15, 2021
If there are source root dirs nested inside each other, a module might have
more than one possible name, depending on where it's intended to be imported
from.  In this case, a rename should not be suggested unless the module name
doesn't match any possible correct name.  When suggesting a name, the shortest
name should be suggested, since that's more likely to be the intended one.

Fixes haskell#1903
@mergify mergify bot closed this as completed in #2195 Sep 16, 2021
mergify bot added a commit that referenced this issue Sep 16, 2021
If there are source root dirs nested inside each other, a module might have
more than one possible name, depending on where it's intended to be imported
from.  In this case, a rename should not be suggested unless the module name
doesn't match any possible correct name.  When suggesting a name, the shortest
name should be suggested, since that's more likely to be the intended one.

Fixes #1903

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Javier Neira <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: plugins type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants