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

Use qualified module name from diagnostics in suggestNewImport #945

Merged
merged 9 commits into from
Dec 15, 2020

Conversation

berberman
Copy link
Contributor

GHC helps us to split the qualified module name from the identifier. Closes haskell/haskell-language-server#629

@pepeiborra
Copy link
Collaborator

Haven't looked at the code yet, but haskell/haskell-language-server#629 is about operators and the title of this PR "Use qualified module name in suggestNewImport" doesn't seem related.

@berberman
Copy link
Contributor Author

Ah, the issue was caused by we mistakenly stripped the qualified import prefix of identifiers. For example, if I write T.null , where the T is not in scope, diagnostic will report:

Not in scope: ‘T.null’
No module named ‘T’ is imported.

The previous logic only took the first line, then tried to use splitOn "." to strip T., obtaining the identifier null, which we use to lookup the export map. Everything goes well.

But operators like .|. were split unexpectedly, result in |. as the identifer. In this PR, I try to extract the qualified module name from the second line of the diagnostic message, so we no longer to use splitOn and intercalate manually, removing the qualified module name by T.stripPrefix instead.

@berberman
Copy link
Contributor Author

Looks like the CI broke for some unknown reasons, but all checks passed on my fork: https://github.com/berberman/ghcide/tree/patch-qual
Ready to be reviewed and merged :-)

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.

Thank you, this is an awesome bug fix.

I don't know what the problem is with CI, could you perhaps rebase on top of master?

@pepeiborra
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@pepeiborra pepeiborra merged commit 22d9fde into haskell:master Dec 15, 2020
@berberman berberman deleted the patch-qual branch December 16, 2020 08:25
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
…ll/ghcide#945)

* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Remove unused renderImport

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
…ll/ghcide#945)

* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Remove unused renderImport

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
pepeiborra added a commit to pepeiborra/ide that referenced this pull request Dec 29, 2020
…ll/ghcide#945)

* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Use qualified module name from diagnostics in suggestNewImport

* Update tests

* Add newline

* Remove unused renderImport

Co-authored-by: Pepe Iborra <pepeiborra@gmail.com>
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.

Import suggestion code action doesn't suggest importing operators
2 participants