Presentation compiler: diagnostic provider #22259
Open
+150
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a capability to provide instant diagnostics for the opened buffers with almost 0 cost.
This can be utilised by tools, such as metals or Scastie, to provide diagnostics without saving a buffer and relying on build server to provide them.
It also publishes warnings and code actions if they are present.
One important bit is that the diagnostics are a subset of build server diagnostics, because presentation compiler runs only phases until typer, thus any diagnostic emitted in later phases will not be published. This should be a minimal problem as most issues come from Typer phase.
In the future, we should experiment with other phases such as
CheckUnused
to provide unused diagnostics along with quick fixes. This is a very powerful addition, as we can then try to reimplement remaining features such as organise imports, to not rely on Scalafix to do it and operate directly on compiler diagnostics. This will have to be well tested, as any extra phase added to theInteractiveCompiler
will slow down all other features that rely on it such as hovers, completions etc, so this is basically a tradeoff.Screencast is more than 1000 words.
Screen.Recording.2024-12-22.at.12.56.06-1.mov