[CLI] Extract classes of compiler configuration from :compiler:cli to the separate module
Those classes mainly include KotlinCoreEnvironment and its dependencies
This change is needed for two reasons:
1. Splitting of some common configuration of compiler from logic of CLI
makes code structure more clean
2. There is a need to add dependency on `:analysis:analysis-api-standalone`
to `:compiler:cli`, because FIR analogue of AnalysysHandlerExtension uses
services from it. But the problems is that standalone AA itself depends
on classes for compiler configuration, which leads to circular
dependency between those modules. Extracting configuration to
`:compiler:cli-base` solves the problem
This commit is contained in:
committed by
Space Team
parent
507ef3e951
commit
b6a41c6d93
@@ -7,7 +7,7 @@ dependencies {
|
||||
implementation(intellijCore())
|
||||
implementation(kotlinStdlib())
|
||||
implementation(project(":compiler:psi"))
|
||||
implementation(project(":compiler:cli"))
|
||||
api(project(":compiler:cli-base"))
|
||||
api(project(":analysis:analysis-api"))
|
||||
api(project(":analysis:analysis-api-providers"))
|
||||
api(project(":analysis:project-structure"))
|
||||
|
||||
@@ -10,7 +10,6 @@ kotlin {
|
||||
dependencies {
|
||||
implementation(intellijCore())
|
||||
implementation(project(":compiler:psi"))
|
||||
implementation(project(":compiler:cli"))
|
||||
api(project(":analysis:analysis-api"))
|
||||
api(project(":analysis:analysis-api-providers"))
|
||||
api(project(":analysis:project-structure"))
|
||||
|
||||
+2
-1
@@ -183,7 +183,6 @@ val fe10CompilerModules = arrayOf(
|
||||
":compiler:serialization",
|
||||
":compiler:frontend",
|
||||
":compiler:container",
|
||||
":compiler:cli-common",
|
||||
":core:deserialization",
|
||||
":compiler:frontend:cfg",
|
||||
":compiler:ir.psi2ir",
|
||||
@@ -200,6 +199,8 @@ val fe10CompilerModules = arrayOf(
|
||||
":compiler:backend",
|
||||
":compiler:plugin-api",
|
||||
":compiler:javac-wrapper",
|
||||
":compiler:cli-common",
|
||||
":compiler:cli-base",
|
||||
":compiler:cli",
|
||||
":compiler:cli-js",
|
||||
":compiler:incremental-compilation-impl",
|
||||
|
||||
@@ -5,22 +5,14 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
api(project(":compiler:util"))
|
||||
api(project(":compiler:cli-common"))
|
||||
api(project(":compiler:cli-base"))
|
||||
api(project(":compiler:frontend"))
|
||||
api(project(":compiler:frontend.java"))
|
||||
api(project(":compiler:frontend:cfg"))
|
||||
api(project(":compiler:backend-common"))
|
||||
api(project(":compiler:backend"))
|
||||
api(project(":compiler:backend.jvm"))
|
||||
implementation(project(":compiler:backend.jvm.entrypoint"))
|
||||
api(project(":compiler:ir.backend.common"))
|
||||
api(project(":compiler:light-classes"))
|
||||
api(project(":compiler:serialization"))
|
||||
api(project(":compiler:plugin-api"))
|
||||
api(project(":compiler:javac-wrapper"))
|
||||
api(project(":js:js.translator"))
|
||||
api(project(":native:frontend.native"))
|
||||
api(project(":wasm:wasm.frontend"))
|
||||
api(commonDependency("org.fusesource.jansi", "jansi"))
|
||||
api(project(":compiler:fir:raw-fir:psi2fir"))
|
||||
api(project(":compiler:fir:resolve"))
|
||||
@@ -35,7 +27,6 @@ dependencies {
|
||||
api(project(":compiler:fir:checkers:checkers.js"))
|
||||
api(project(":compiler:fir:checkers:checkers.native"))
|
||||
api(project(":compiler:fir:fir-serialization"))
|
||||
api(project(":kotlin-util-klib"))
|
||||
api(project(":kotlin-util-io"))
|
||||
|
||||
compileOnly(toolsJarApi())
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":compiler:cli-common"))
|
||||
api(project(":compiler:resolution.common"))
|
||||
api(project(":compiler:frontend.java"))
|
||||
api(project(":compiler:frontend:cfg"))
|
||||
api(project(":compiler:ir.backend.common"))
|
||||
api(project(":compiler:backend.jvm"))
|
||||
api(project(":compiler:light-classes"))
|
||||
api(project(":compiler:javac-wrapper"))
|
||||
api(project(":compiler:ir.serialization.jvm"))
|
||||
api(project(":js:js.translator"))
|
||||
api(project(":native:frontend.native"))
|
||||
api(project(":wasm:wasm.frontend"))
|
||||
api(project(":kotlin-util-klib"))
|
||||
api(project(":kotlin-util-klib-metadata"))
|
||||
|
||||
compileOnly(toolsJarApi())
|
||||
compileOnly(intellijCore())
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:trove4j"))
|
||||
compileOnly(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" {
|
||||
projectDefault()
|
||||
}
|
||||
"test" { none() }
|
||||
}
|
||||
|
||||
allprojects {
|
||||
optInToExperimentalCompilerApi()
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
kotlinOptions {
|
||||
languageVersion = "1.4"
|
||||
apiVersion = "1.4"
|
||||
freeCompilerArgs = freeCompilerArgs - "-progressive" + listOf(
|
||||
"-Xskip-prerelease-check", "-Xsuppress-version-warnings", "-Xuse-mixed-named-arguments"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
testsJar {}
|
||||
|
||||
projectTest {
|
||||
workingDir = rootDir
|
||||
}
|
||||
+1
-1
@@ -89,7 +89,7 @@ class CliLightClassGenerationSupport(
|
||||
return ultraLightSupport
|
||||
}
|
||||
|
||||
internal val context: LightClassConstructionContext
|
||||
val context: LightClassConstructionContext
|
||||
get() = LightClassConstructionContext(
|
||||
traceHolder.bindingContext,
|
||||
traceHolder.module,
|
||||
+1
-1
@@ -81,4 +81,4 @@ class KotlinCoreApplicationEnvironment private constructor(
|
||||
registerVersionSpecificAppExtensionPoints(ApplicationManager.getApplication().extensionArea)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -117,7 +117,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
) :
|
||||
KotlinCoreProjectEnvironment(disposable, applicationEnvironment) {
|
||||
|
||||
internal val jarFileSystem: VirtualFileSystem
|
||||
val jarFileSystem: VirtualFileSystem
|
||||
|
||||
init {
|
||||
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
@@ -339,7 +339,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
val project: Project
|
||||
get() = projectEnvironment.project
|
||||
|
||||
internal fun countLinesOfCode(sourceFiles: List<KtFile>): Int =
|
||||
fun countLinesOfCode(sourceFiles: List<KtFile>): Int =
|
||||
sourceFiles.sumBy { sourceFile ->
|
||||
val text = sourceFile.text
|
||||
StringUtil.getLineBreakCount(text) + (if (StringUtil.endsWithLineBreak(text)) 0 else 1)
|
||||
@@ -384,7 +384,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
throw IllegalStateException("Unexpected root: $root")
|
||||
}
|
||||
|
||||
internal fun findLocalFile(path: String): VirtualFile? =
|
||||
fun findLocalFile(path: String): VirtualFile? =
|
||||
applicationEnvironment.localFileSystem.findFileByPath(path)
|
||||
|
||||
private fun findExistingRoot(root: JvmContentRoot, rootDescription: String): VirtualFile? {
|
||||
+1
-1
@@ -46,4 +46,4 @@ class CtSymClassVirtualFile(
|
||||
override fun getFileType(): FileType = JavaClassFileType.INSTANCE
|
||||
|
||||
override fun getModificationStamp(): Long = file.modificationStamp
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -82,4 +82,4 @@ class CtSymDirectoryContainer(
|
||||
override fun refresh(p0: Boolean, p1: Boolean, p2: Runnable?) {}
|
||||
|
||||
override fun getInputStream(): InputStream? = error("not supported")
|
||||
}
|
||||
}
|
||||
@@ -148,6 +148,7 @@ dependencies {
|
||||
compilerApi project(":compiler:util")
|
||||
compilerApi project(":native:frontend.native")
|
||||
compilerApi project(":compiler:cli-common")
|
||||
compilerApi project(":compiler:cli-base")
|
||||
compilerApi project(":compiler:cli")
|
||||
compilerApi project(":kotlin-util-klib")
|
||||
compilerApi project(":kotlin-util-klib-metadata")
|
||||
|
||||
@@ -6614,6 +6614,7 @@ dependencies {
|
||||
nopPluginApi project(":compiler:util")
|
||||
nopPluginApi project(":native:frontend.native")
|
||||
nopPluginApi project(":compiler:cli-common")
|
||||
nopPluginApi project(":compiler:cli-base")
|
||||
nopPluginApi project(":compiler:cli")
|
||||
nopPluginApi project(":kotlin-util-klib")
|
||||
nopPluginApi project(":kotlin-util-klib-metadata")
|
||||
|
||||
+3
-1
@@ -56,7 +56,6 @@ include ":benchmarks",
|
||||
":compiler:frontend:cfg",
|
||||
":kotlin-compiler-runner-unshaded",
|
||||
":kotlin-compiler-runner",
|
||||
":compiler:cli-common",
|
||||
":compiler:ir.tree",
|
||||
":compiler:ir.tree:tree-generator",
|
||||
":compiler:ir.psi2ir",
|
||||
@@ -77,6 +76,8 @@ include ":benchmarks",
|
||||
":compiler:plugin-api",
|
||||
":compiler:light-classes",
|
||||
":compiler:javac-wrapper",
|
||||
":compiler:cli-common",
|
||||
":compiler:cli-base",
|
||||
":compiler:cli",
|
||||
":compiler:cli-js",
|
||||
":compiler:incremental-compilation-impl",
|
||||
@@ -623,6 +624,7 @@ project(':kotlin-compiler-client-embeddable').projectDir = "$rootDir/prepare/com
|
||||
project(':kotlin-preloader').projectDir = "$rootDir/compiler/preloader" as File
|
||||
project(':kotlin-build-common').projectDir = "$rootDir/build-common" as File
|
||||
project(':compiler:cli-common').projectDir = "$rootDir/compiler/cli/cli-common" as File
|
||||
project(':compiler:cli-base').projectDir = "$rootDir/compiler/cli/cli-base" as File
|
||||
project(':compiler:cli-js').projectDir = "$rootDir/compiler/cli/cli-js" as File
|
||||
project(':kotlin-runner').projectDir = "$rootDir/compiler/cli/cli-runner" as File
|
||||
project(':kotlin-daemon').projectDir = "$rootDir/compiler/daemon" as File
|
||||
|
||||
Reference in New Issue
Block a user