Skip to content

Conversation

@tgodzik
Copy link

@tgodzik tgodzik commented Nov 6, 2025

Backports scala#24133 to the 3.3.7.

PR submitted by the release tooling.
[skip ci]

@tgodzik tgodzik force-pushed the backport-lts-3.3-24133 branch from 0211585 to 0643fc5 Compare November 6, 2025 18:56
@tgodzik tgodzik force-pushed the backport-lts-3.3-24036 branch 2 times, most recently from 0770ad6 to caf2731 Compare November 7, 2025 08:35
`RawPresentationCompiler` is a direct, unsafe way to access presentation
compiler interface provided in
scalameta/metals#7841

It is up to the consumer to guarantee thread safety and sequential
request processing.
This solves many issues with the current `PresentationCompiler`
interface but most important are:
- We now have control where and how each presentation compiler method is
run. Before it was always run on a `SingleThreadExecutor` created by the
`PresentationCompiler`. The original behavior will stay with the
standard `ScalaPresentationCompiler` interface. (There is another PR
that refactors that part),
- If there was bug in scheduler all versions were affected,

On top of that this PR implements all things that will work out of the
box:
- Diagnostic provider - trivial implementation, previously not possible
to LIFO task used by `Scala3CompilerAccess`. Will be super useful e.g
for Scastie which will become a consumer of this new raw API.
- `InteractiveDriver` compilation cancellation by checking
Thread.interrupted(). Future changes are required to make it work with
safe `ScalaPresentationCompiler` and `CancelTokens`. Here we can omit
the cancel token support for now, because we would check for
`Thread.interrupted()` along the `cancelToken.isCancelled` anyway, and
we can now easily interrupt it from e.g `IO.interruptible`

Those changes were adapted from my other PR's that required adjustment
of `Scala3CompilerAccess` but I don't think it is ready / I'm not happy
with current state of that refactor.

In the future we should think of replacing the implementation of
`ScalaPresentationCompiler` to use `RawPresentationCompiler` as
underlying impl and just call it in safe way.

The implementation was tested on the actual LSP server and it works
fine.
@tgodzik tgodzik force-pushed the backport-lts-3.3-24133 branch from 0643fc5 to 8c7949c Compare November 7, 2025 08:37
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.

3 participants