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

Draft: Migrate hls-class-plugin to use structured diagnostics #4472

Draft
wants to merge 74 commits into
base: master
Choose a base branch
from

Conversation

fendor
Copy link
Collaborator

@fendor fendor commented Dec 23, 2024

Split off from #4433, this PR moves the hls-class-plugin to use the structured diagnostics.

It worked well in my tests, but unfortunately it is incompatible with GHC 9.4, because the error message the plugin cares about is not structured in 9.4.
We can either wait until we drop support for 9.4 or maintain both paths until we drop support for 9.4.

Unfortunately, the only way to push GHC into the direction we want, is to do the latter and report any lacking error messages to GHC ASAP.

FYI, only the last commit matters.

We're leaving the TODOs for either later in this PR or in another PR
Had to move `attachReason` between modules to achieve this, which is
fine because it was never exported from its own module.
noughtmare and others added 22 commits October 24, 2024 19:22
Implement 'rangesOverlap' function which checks whether two 'Range's
overlap in any way.
Implement two new plugin utility functions which allow to conveniently
get all currently displayed diagnostics for a given 'Range'.
Add compatibility module for GHC's structured error messages.
Introduce 'Prism's and 'Lens's to easily access nested structures.
Expand documentation for 'StructuredMessage'
Fixes haskell#4440

Fixes test for disabling deferred-type-errors.
Co-authored-by: Mergify <37929162+mergify[bot]@users.noreply.github.com>
* new tests

* change codeAction title

* more tests and docs

---------

Co-authored-by: fendor <[email protected]>
Allows HLS to 'Goto Definition' for Note references.
@fendor fendor marked this pull request as draft December 23, 2024 10:32
@fendor fendor changed the title WIP: Migrate hls-class-plugin to use structured diagnostics Draft: Migrate hls-class-plugin to use structured diagnostics Dec 23, 2024
Copy link
Collaborator

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

Looks nice! It's a shame about not everything being structured. I wonder if we should just do an inventory of the places where we use GHC's diagnostics and check manually that they've been made structured? Maybe that's cheaper than doing all the PRs and either letting them get stale or adding a bunch of CPP?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants