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

improvement: shared diagnostics between compiler and language server #239

Merged
merged 3 commits into from
Aug 23, 2020

Conversation

baszalmstra
Copy link
Collaborator

This PR introduces the mun_diagnostics crate. This crate provides the Diagnostic trait which is used by both the compiler and the language server to provide the same detailed diagnotics. The crate enables conversion from hir::Diagnostic to mun_diagnostics::Diagnostic which also adds more detailed information (which first resided in the compiler itself).

The compiler uses the Diagnostic trait to convert it to a Snippet from annotate_snippets to emit the diagnostic information to the console.

The language server uses the Diagnostic trait to convert it to a lsp_types::Diagnostic which is send to the language server client.

This enables sharing a lot of the logic of diagnostics between these two use cases.

In the future, we could also add quick-fixes to the crate to be able to provide hints on the console and provide quick actions for the LSP.

This PR is branched of from #236 which should be merged first.

@baszalmstra baszalmstra self-assigned this Jul 4, 2020
@baszalmstra baszalmstra added the type: perf Changes that improve performance label Jul 4, 2020
@baszalmstra baszalmstra changed the title Feature: shared diagnostics between compiler and language server feature: shared diagnostics between compiler and language server Jul 4, 2020
@baszalmstra baszalmstra changed the title feature: shared diagnostics between compiler and language server improvement: shared diagnostics between compiler and language server Jul 4, 2020
@codecov
Copy link

codecov bot commented Jul 4, 2020

Codecov Report

Merging #239 into master will decrease coverage by 0.52%.
The diff coverage is 67.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #239      +/-   ##
==========================================
- Coverage   79.10%   78.57%   -0.53%     
==========================================
  Files         201      210       +9     
  Lines       12807    12771      -36     
==========================================
- Hits        10131    10035      -96     
- Misses       2676     2736      +60     
Impacted Files Coverage Δ
crates/mun_compiler/src/diagnostics.rs 100.00% <ø> (+6.30%) ⬆️
crates/mun_compiler/src/lib.rs 67.50% <ø> (ø)
crates/mun_diagnostics/src/hir/missing_fields.rs 0.00% <0.00%> (ø)
crates/mun_hir/src/diagnostics.rs 59.70% <ø> (-6.80%) ⬇️
crates/mun_hir/src/ty.rs 84.00% <0.00%> (-2.78%) ⬇️
crates/mun_language_server/src/diagnostics.rs 0.00% <0.00%> (ø)
crates/mun_language_server/src/main_loop.rs 23.55% <0.00%> (-1.33%) ⬇️
crates/mun_diagnostics/src/hir.rs 57.69% <57.69%> (ø)
crates/mun_hir/src/ty/infer.rs 70.94% <77.77%> (-0.04%) ⬇️
crates/mun_compiler/src/diagnostics_snippets.rs 84.00% <84.00%> (-7.94%) ⬇️
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a6b437...eb0da2c. Read the comment docs.

@Wodann Wodann self-requested a review July 20, 2020 12:23
@baszalmstra baszalmstra force-pushed the feature/lsp/diagnostics branch 5 times, most recently from af0217d to 88ed4bc Compare July 25, 2020 09:21
@baszalmstra baszalmstra added this to the Mun v0.3.0 milestone Jul 25, 2020
crates/mun_compiler/src/lib.rs Outdated Show resolved Hide resolved
crates/mun_diagnostics/Cargo.toml Outdated Show resolved Hide resolved
crates/mun_diagnostics/src/hir/access_unknown_field.rs Outdated Show resolved Hide resolved
crates/mun_diagnostics/src/lib.rs Show resolved Hide resolved
crates/mun_diagnostics/src/lib.rs Show resolved Hide resolved
crates/mun_hir/src/ty.rs Outdated Show resolved Hide resolved
@baszalmstra baszalmstra force-pushed the feature/lsp/diagnostics branch from 88ed4bc to 4fd59be Compare August 22, 2020 17:21
@baszalmstra baszalmstra force-pushed the feature/lsp/diagnostics branch from 35bf917 to c676431 Compare August 22, 2020 17:37
crates/mun_diagnostics/src/lib.rs Outdated Show resolved Hide resolved
crates/mun_diagnostics/src/lib.rs Outdated Show resolved Hide resolved
@baszalmstra baszalmstra force-pushed the feature/lsp/diagnostics branch from c676431 to eb0da2c Compare August 22, 2020 17:41
@baszalmstra baszalmstra merged commit cfdb98e into mun-lang:master Aug 23, 2020
@Wodann Wodann added type: refactor Refactor existing code and removed type: perf Changes that improve performance labels Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: refactor Refactor existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants