lampepfl / dotty-feature-requests

Historical feature requests. Please create new feature requests at https://github.com/lampepfl/dotty/discussions/new?category=feature-requests
31 stars 2 forks source link

compiler plugins able to register with the Reporter #329

Closed fommil closed 1 year ago

fommil commented 2 years ago

In Scala 2 I am able to get callbacks from the Reporter by hijacking it and forwarding to the existing reporter, e.g. in my plugin's init

    global.reporter = new MyReporter(global.reporter)

but in Scala 3, there is no equivalent mechanism. I agree fully that this mechanism is a massive hack in Scala 2, but there's no possibility to wind back time and add APIs so it must remain. Ideally I'd be able to pass a callback to a register.

My usecase is to tee all the logs / diagnostics into a file, so that the ENSIME LSP can watch for changes and show diagnostics in the user's text editor. This is build tool agnostic. It also means that the diagnostics are computed on-demand by the user, and are effectively calculated "for free" since there is no separate batch or interactive compile step, saving laptop battery life.

I can imagine that other kinds of tooling would want access to the reporter logs as well as ENSIME, in which case you might want to consider just offering that as a feature. But for it to work with ENSIME, the compiler plugin would need to be able to enable the feature and either specify the location of the file or obtain the location.

// @robmwalsh

bertlebee commented 2 years ago

Yep this is a great idea. @ckipp01 also seemed interested in this approach on the scala tooling discord.

gvolpe commented 1 year ago

Second this 👍🏽 , would love to get ENSIME working with Scala 3!

fommil commented 1 year ago

@gvolpe ensime already works on Scala 3, it is just missing this one feature.

gvolpe commented 1 year ago

Thanks @fommil , I mean diagnostics, saw this on the README file :)

fommil commented 1 year ago

@robmwalsh solved this, it turns out that you can ctx.typerState.setReporter