This repository has been archived by the owner on Aug 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] added Kotlin specific data | #BAZEL-460 Done
Merge-request: BAZEL-MR-321 Merged-by: Xuan Son Trinh <[email protected]>
- Loading branch information
1 parent
333e3e6
commit c06acc6
Showing
10 changed files
with
230 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...r/src/main/java/org/jetbrains/bsp/bazel/server/sync/languages/kotlin/KotlinBuildTarget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.jetbrains.bsp.bazel.server.sync.languages.kotlin | ||
|
||
import ch.epfl.scala.bsp4j.BuildTargetIdentifier | ||
import ch.epfl.scala.bsp4j.JvmBuildTarget | ||
|
||
data class KotlinBuildTarget( | ||
val languageVersion: String, | ||
val apiVersion: String, | ||
val kotlincOptions: KotlincOpts?, | ||
val associates: List<BuildTargetIdentifier>, | ||
var jvmBuildTarget: JvmBuildTarget? = null | ||
) |
84 changes: 84 additions & 0 deletions
84
...rc/main/java/org/jetbrains/bsp/bazel/server/sync/languages/kotlin/KotlinLanguagePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package org.jetbrains.bsp.bazel.server.sync.languages.kotlin | ||
|
||
import ch.epfl.scala.bsp4j.BuildTarget | ||
import ch.epfl.scala.bsp4j.BuildTargetIdentifier | ||
import org.jetbrains.bsp.bazel.info.BspTargetInfo | ||
import org.jetbrains.bsp.bazel.server.sync.BazelPathsResolver | ||
import org.jetbrains.bsp.bazel.server.sync.dependencytree.DependencyTree | ||
import org.jetbrains.bsp.bazel.server.sync.languages.LanguagePlugin | ||
import org.jetbrains.bsp.bazel.server.sync.languages.java.JavaLanguagePlugin | ||
import java.net.URI | ||
import java.nio.file.Path | ||
|
||
class KotlinLanguagePlugin( | ||
private val javaLanguagePlugin: JavaLanguagePlugin | ||
) : LanguagePlugin<KotlinModule>() { | ||
|
||
override fun applyModuleData(moduleData: KotlinModule, buildTarget: BuildTarget) { | ||
val kotlinBuildTarget = with(moduleData) { | ||
KotlinBuildTarget( | ||
languageVersion = languageVersion, | ||
apiVersion = apiVersion, | ||
associates = associates, | ||
kotlincOptions = kotlincOptions | ||
) | ||
} | ||
moduleData.javaModule?.let { javaLanguagePlugin.toJvmBuildTarget(it) }?.let { | ||
kotlinBuildTarget.jvmBuildTarget = it | ||
} | ||
|
||
buildTarget.dataKind = "kotlin" | ||
buildTarget.data = kotlinBuildTarget | ||
} | ||
|
||
override fun resolveModule(targetInfo: BspTargetInfo.TargetInfo): KotlinModule? { | ||
if (!targetInfo.hasKotlinTargetInfo()) return null | ||
|
||
val kotlinTargetInfo = targetInfo.kotlinTargetInfo | ||
var kotlincOptsRes: KotlincOpts? = null | ||
if (kotlinTargetInfo.hasKotlincOpts()) { | ||
val kotlincOpts = kotlinTargetInfo.kotlincOpts | ||
with(kotlincOpts) { | ||
kotlincOptsRes = KotlincOpts( | ||
includeStdlibs = includeStdlibs, | ||
javaParameters = javaParameters, | ||
jvmTarget = jvmTarget, | ||
warn = warn, | ||
xAllowResultReturnType = xAllowResultReturnType, | ||
xBackendThreads = xBackendThreads, | ||
xEmitJvmTypeAnnotations = xEmitJvmTypeAnnotations, | ||
xEnableIncrementalCompilation = xEnableIncrementalCompilation, | ||
xExplicitApiMode = xExplicitApiMode, | ||
xInlineClasses = xInlineClasses, | ||
xJvmDefault = xJvmDefault, | ||
xLambdas = xLambdas, | ||
xMultiPlatform = xMultiPlatform, | ||
xNoCallAssertions = xNoCallAssertions, | ||
xNoOptimize = xNoOptimize, | ||
xNoOptimizedCallableReferences = xNoOptimizedCallableReferences, | ||
xNoParamAssertions = xNoParamAssertions, | ||
xNoReceiverAssertions = xNoReceiverAssertions, | ||
xOptinList = xOptinList, | ||
xReportPerf = xReportPerf, | ||
xSamConversions = xSamConversions, | ||
xSkipPrereleaseCheck = xSkipPrereleaseCheck, | ||
xUseFirLt = xUseFirLt, | ||
xUseK2 = xUseK2 | ||
) | ||
} | ||
} | ||
return KotlinModule( | ||
languageVersion = kotlinTargetInfo.languageVersion, | ||
apiVersion = kotlinTargetInfo.apiVersion, | ||
associates = kotlinTargetInfo.associatesList.map { BuildTargetIdentifier(it) }, | ||
kotlincOptions = kotlincOptsRes, | ||
javaModule = javaLanguagePlugin.resolveModule(targetInfo) | ||
) | ||
} | ||
|
||
override fun dependencySources(targetInfo: BspTargetInfo.TargetInfo, dependencyTree: DependencyTree): Set<URI> = | ||
javaLanguagePlugin.dependencySources(targetInfo, dependencyTree) | ||
|
||
override fun calculateSourceRoot(source: Path): Path? = | ||
javaLanguagePlugin.calculateSourceRoot(source) | ||
} |
40 changes: 40 additions & 0 deletions
40
server/src/main/java/org/jetbrains/bsp/bazel/server/sync/languages/kotlin/KotlinModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.jetbrains.bsp.bazel.server.sync.languages.kotlin | ||
|
||
import ch.epfl.scala.bsp4j.BuildTargetIdentifier | ||
import org.jetbrains.bsp.bazel.server.sync.languages.LanguageData | ||
import org.jetbrains.bsp.bazel.server.sync.languages.java.JavaModule | ||
|
||
data class KotlinModule( | ||
val languageVersion: String, | ||
val apiVersion: String, | ||
val kotlincOptions: KotlincOpts?, | ||
val associates: List<BuildTargetIdentifier>, | ||
val javaModule: JavaModule? | ||
) : LanguageData | ||
|
||
data class KotlincOpts( | ||
val includeStdlibs: String, | ||
val javaParameters: Boolean, | ||
val jvmTarget: String, | ||
val warn : String, | ||
val xAllowResultReturnType : Boolean, | ||
val xBackendThreads: Int, | ||
val xEmitJvmTypeAnnotations: Boolean, | ||
val xEnableIncrementalCompilation: Boolean, | ||
val xExplicitApiMode: String, | ||
val xInlineClasses: Boolean, | ||
val xJvmDefault: String, | ||
val xLambdas: String, | ||
val xMultiPlatform: Boolean, | ||
val xNoCallAssertions: Boolean, | ||
val xNoOptimize: Boolean, | ||
val xNoOptimizedCallableReferences: Boolean, | ||
val xNoParamAssertions: Boolean, | ||
val xNoReceiverAssertions: Boolean, | ||
val xOptinList: List<String>, | ||
val xReportPerf: Boolean, | ||
val xSamConversions: String, | ||
val xSkipPrereleaseCheck: Boolean, | ||
val xUseFirLt: Boolean, | ||
val xUseK2: Boolean, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters