-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Add Kotlin BSP integration test #3643
Add Kotlin BSP integration test #3643
Conversation
Includes #3608 for now |
01bba7f
to
81da0cc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, to accept these weird kind of workaround, I'd require at least an upstream issue and/or discussion in the BSP project. Especially since this is a IDEA specific thing whereas BSP is a more general protocol, also serving other IDEs and editors.
We already have some BSP client specific handling (e.g. enable semanticDB for metals, or if you dig in the git history handling of the build.sc
for IDEA), so we should guard workaround behind a BSP client check.
In a similiar fashion, I'd like to propose to add the synthetic root module only when we detect we're connected to IntelliJ (that one could be made without breaking bin compat). |
Can you a bit more specific? How do you detect the missing support in IDEA and why can't it be binary compatible. Or if this was discussed before plz provide a pointer. |
The whole BSP implementation is far from simple, so a bit of context and explanation helps a lot. |
Right now, my understanding is that BSP support in IntelliJ is provided by intellij-scala. Intellij-scala advertizes support only for Java and Scala in its Yet, advertizing Kotlin modules as Scala ones doesn't allow to pass kotlinc arguments (and other Kotlin-specific details) to the BSP client. It seems Jetbrains is working on a better solution, with explicit support for Kotlin via BSP, in the intellij-bsp project (I mean, it's formerly called "intellij-bsp", it's now part of a bigger repo). Note that intellij-scala has its own BSP implementation, that differs from the one of intellij-bsp. @jastice said in #3619 that intellij-bsp would probabaly be used mid-term by intellij-scala too. So in #3644, we try to detect which IntelliJ BSP implementation we talk to, and advertize Kotlin modules either as Scala ones (for intellij-scala) or as Kotlin ones (for intellij-bsp). To detect which intellij BSP implementation we talk to, inspecting the BSP |
About the binary compatibility issue, we need details of the client |
The idea with the PR here is to advertize Kotlin modules as Scala ones via BSP, rather than Java ones as is currently the case (as |
Understood. Regarding the detection logic. The data in Technically, I'd rather avoid investing into the current monolithic BSP implementation in favor of a more modular approach, but it's currently blocked by bsp4j not being leightweight enough, |
I think Please note, that |
One last note: I can't recall if I checked whether Kotlin sources alongside a Java module (as should be the case currently without this PR) were fine in Intellij. I checked as Kotlin module as done in #3644 in the general case, and as a Scala one as done here, for sure. We should able to do #3644 without breaking bin compat if it works fine alongside a Java module, by changing the |
So is |
81da0cc
to
1f94faa
Compare
1f94faa
to
2d04d71
Compare
This repeatedly rebasing makes the review process harder than necessary. I'm going to set this PR to draft mode until PR #3608 is merged. |
The last commit is the only one specific to this PR. You can just look at this one. You'll have no diff between pushes, but that commit isn't that large. |
2d04d71
to
16f2eb5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit but looks good. What's the relationship between this and #3644? Does one depend on the other? Or are they unrelated?
@@ -314,6 +315,13 @@ trait KotlinModule extends JavaModule { outer => | |||
|
|||
private[kotlinlib] def internalReportOldProblems: Task[Boolean] = zincReportCachedProblems | |||
|
|||
@internal | |||
override def bspBuildTarget: BspBuildTarget = super.bspBuildTarget.copy( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the relation between this bspBuildTarget
and the jvmBuildTarget
you introduced in #3681?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bspBuildTarget
is defined in BspModule
, and was there before my PRs. It contains details about the module, passed to the BSP clients via the workspace/buildTargets
request. It goes along bspBuildTargetData
, that contains language-specific data passed along in the response to this request too.
bspJvmBuildTarget
contains JVM-specific details about the module. These are passed to clients via bspBuildTargetData
for JavaModule
, and as a field of what's passed in bspBuildTargetData
for ScalaModule
(same for KotlinModule
in #3644). So ScalaModule
(and KotlinModule
in #3644) also use bspJvmBuildTarget
, but uses it differently in bspBuildTargetData
.
#3644 includes the PR here. It adds things to it (it actually adds Kotlin-specific data in some BSP responses, to pass kotlinc arguments to clients in particular). It adds what intellij-bsp expects for Kotlin modules, although I wasn't able to use it in practice, and it breaks binary compatibility in order to detect which IntelliJ BSP implementation it's talking to (the one of intellij-scala or the new one of intellij-bsp). |
This PR adds non-regression integration tests for Kotlin support via BSP. Kotlin modules are currently advertized as Java ones, and IntelliJ seems to handle fine Kotlin sources in those (using non-experimental BSP support).