Skip to content

Commit 0211585

Browse files
committed
Add unsafe RawPresentationCompiler implementation (scala#24133)
`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. [Cherry-picked 582366c][modified]
1 parent 908dbaf commit 0211585

File tree

0 file changed

+0
-0
lines changed

    0 file changed

    +0
    -0
    lines changed

    0 commit comments

    Comments
     (0)