Remove experimental implementation of Kotlin Compiler Daemon

#KT-50846 Fixed
This commit is contained in:
Andrey Uskov
2022-01-26 23:34:30 +04:00
committed by teamcity
parent 94f690a10e
commit c9e0100214
72 changed files with 0 additions and 7812 deletions
@@ -31,8 +31,3 @@ enum class CompilationResultCategory(val code: Int) {
VERBOSE_BUILD_REPORT_LINES(2),
BUILD_METRICS(3)
}
interface CompilationResultsAsync {
suspend fun add(compilationResultCategory: Int, value: Serializable)
val clientSide: CompilationResultsAsync
}
@@ -1,36 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import kotlinx.coroutines.runBlocking
import java.io.Serializable
class CompilationResultsAsyncWrapper(val rmiImpl: CompilationResults) : CompilationResultsAsync {
override val clientSide: CompilationResultsAsync
get() = this
override suspend fun add(compilationResultCategory: Int, value: Serializable) {
rmiImpl.add(compilationResultCategory, value)
}
}
class CompilationResultsRMIWrapper(val clientSide: CompilationResultsAsync) : CompilationResults, Serializable {
override fun add(compilationResultCategory: Int, value: Serializable) = runBlocking {
clientSide.add(compilationResultCategory, value)
}
}
fun CompilationResults.toClient() =
if (this is CompilationResultsRMIWrapper) this.clientSide
else CompilationResultsAsyncWrapper(this)
fun CompilationResultsAsync.toRMI() =
if (this is CompilationResultsAsyncWrapper) this.rmiImpl
else CompilationResultsRMIWrapper(this)
@@ -1,81 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
import org.jetbrains.kotlin.cli.common.repl.ReplCodeLine
import org.jetbrains.kotlin.cli.common.repl.ReplCompileResult
import java.io.File
interface CompileServiceAsync {
suspend fun checkCompilerId(expectedCompilerId: CompilerId): Boolean
suspend fun getUsedMemory(): CompileService.CallResult<Long>
suspend fun getDaemonOptions(): CompileService.CallResult<DaemonOptions>
suspend fun getDaemonInfo(): CompileService.CallResult<String>
suspend fun getKotlinVersion(): CompileService.CallResult<String>
suspend fun getDaemonJVMOptions(): CompileService.CallResult<DaemonJVMOptions>
suspend fun registerClient(aliveFlagPath: String?): CompileService.CallResult<Nothing>
// TODO: (-old-) consider adding another client alive checking mechanism, e.g. socket/socketPort
suspend fun getClients(): CompileService.CallResult<List<String>>
suspend fun leaseCompileSession(aliveFlagPath: String?): CompileService.CallResult<Int>
suspend fun releaseCompileSession(sessionId: Int): CompileService.CallResult<Nothing>
suspend fun shutdown(): CompileService.CallResult<Nothing>
suspend fun scheduleShutdown(graceful: Boolean): CompileService.CallResult<Boolean>
suspend fun compile(
sessionId: Int,
compilerArguments: Array<out String>,
compilationOptions: CompilationOptions,
servicesFacade: CompilerServicesFacadeBaseAsync,
compilationResults: CompilationResultsAsync?
): CompileService.CallResult<Int>
suspend fun clearJarCache()
suspend fun releaseReplSession(sessionId: Int): CompileService.CallResult<Nothing>
suspend fun leaseReplSession(
aliveFlagPath: String?,
compilerArguments: Array<out String>,
compilationOptions: CompilationOptions,
servicesFacade: CompilerServicesFacadeBaseAsync,
templateClasspath: List<java.io.File>,
templateClassName: String
): CompileService.CallResult<Int>
suspend fun replCreateState(sessionId: Int): CompileService.CallResult<ReplStateFacadeAsync>
suspend fun replCheck(
sessionId: Int,
replStateId: Int,
codeLine: ReplCodeLine
): CompileService.CallResult<ReplCheckResult>
suspend fun replCompile(
sessionId: Int,
replStateId: Int,
codeLine: ReplCodeLine
): CompileService.CallResult<ReplCompileResult>
suspend fun classesFqNamesByFiles(sessionId: Int, sourceFiles: Set<File>): CompileService.CallResult<Set<String>>
val serverPort: Int
get() = 0
}
@@ -1,111 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import org.jetbrains.kotlin.cli.common.repl.ReplCodeLine
import java.io.File
class CompileServiceAsyncWrapper(
val rmiCompileService: CompileService
) : CompileServiceAsync {
override suspend fun classesFqNamesByFiles(sessionId: Int, sourceFiles: Set<File>) =
rmiCompileService.classesFqNamesByFiles(sessionId, sourceFiles)
override suspend fun compile(
sessionId: Int,
compilerArguments: Array<out String>,
compilationOptions: CompilationOptions,
servicesFacade: CompilerServicesFacadeBaseAsync,
compilationResults: CompilationResultsAsync?
) = rmiCompileService.compile(
sessionId,
compilerArguments,
compilationOptions,
servicesFacade.toRMI(),
compilationResults?.toRMI()
)
override suspend fun leaseReplSession(
aliveFlagPath: String?,
compilerArguments: Array<out String>,
compilationOptions: CompilationOptions,
servicesFacade: CompilerServicesFacadeBaseAsync,
templateClasspath: List<File>,
templateClassName: String
) = rmiCompileService.leaseReplSession(
aliveFlagPath,
compilerArguments,
compilationOptions,
servicesFacade.toRMI(),
templateClasspath,
templateClassName
)
override suspend fun replCreateState(sessionId: Int) =
rmiCompileService.replCreateState(sessionId).toClient()
override suspend fun getUsedMemory() =
rmiCompileService.getUsedMemory()
override suspend fun getDaemonOptions() =
rmiCompileService.getDaemonOptions()
override suspend fun getDaemonInfo() =
rmiCompileService.getDaemonInfo()
override suspend fun getKotlinVersion() =
rmiCompileService.getKotlinVersion()
override suspend fun getDaemonJVMOptions() =
rmiCompileService.getDaemonJVMOptions()
override suspend fun registerClient(aliveFlagPath: String?) =
rmiCompileService.registerClient(aliveFlagPath)
override suspend fun getClients() =
rmiCompileService.getClients()
override suspend fun leaseCompileSession(aliveFlagPath: String?) =
rmiCompileService.leaseCompileSession(aliveFlagPath)
override suspend fun releaseCompileSession(sessionId: Int) =
rmiCompileService.releaseCompileSession(sessionId)
override suspend fun shutdown() =
rmiCompileService.shutdown()
override suspend fun scheduleShutdown(graceful: Boolean) =
rmiCompileService.scheduleShutdown(graceful)
override suspend fun clearJarCache() =
rmiCompileService.clearJarCache()
override suspend fun releaseReplSession(sessionId: Int) =
rmiCompileService.releaseReplSession(sessionId)
override suspend fun replCheck(sessionId: Int, replStateId: Int, codeLine: ReplCodeLine) =
rmiCompileService.replCheck(sessionId, replStateId, codeLine)
override suspend fun replCompile(
sessionId: Int,
replStateId: Int,
codeLine: ReplCodeLine
) = rmiCompileService.replCompile(sessionId, replStateId, codeLine)
override suspend fun checkCompilerId(expectedCompilerId: CompilerId) =
rmiCompileService.checkCompilerId(expectedCompilerId)
}
fun CompileService.toClient() = CompileServiceAsyncWrapper(this)
@@ -1,214 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.cli.common.repl.ReplCheckResult
import org.jetbrains.kotlin.cli.common.repl.ReplCodeLine
import org.jetbrains.kotlin.cli.common.repl.ReplCompileResult
import org.jetbrains.kotlin.cli.common.repl.ReplEvalResult
import java.io.File
class CompileServiceClientRMIWrapper(
val asyncCompileService: CompileServiceAsync
) : CompileService {
override fun classesFqNamesByFiles(sessionId: Int, sourceFiles: Set<File>) = runBlocking {
asyncCompileService.classesFqNamesByFiles(sessionId, sourceFiles)
}
private fun reportNotImplemented(): Nothing = throw IllegalStateException("Unexpected call to deprecated method")
// deprecated methods :
@Suppress("OverridingDeprecatedMember", "DEPRECATION", "OVERRIDE_DEPRECATION")
override fun remoteCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
args: Array<out String>,
servicesFacade: CompilerCallbackServicesFacade,
compilerOutputStream: RemoteOutputStream,
outputFormat: CompileService.OutputFormat,
serviceOutputStream: RemoteOutputStream,
operationsTracer: RemoteOperationsTracer?
): CompileService.CallResult<Int> {
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION", "OVERRIDE_DEPRECATION")
override fun remoteIncrementalCompile(
sessionId: Int,
targetPlatform: CompileService.TargetPlatform,
args: Array<out String>,
servicesFacade: CompilerCallbackServicesFacade,
compilerOutputStream: RemoteOutputStream,
compilerOutputFormat: CompileService.OutputFormat,
serviceOutputStream: RemoteOutputStream,
operationsTracer: RemoteOperationsTracer?
): CompileService.CallResult<Int> {
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember", "DEPRECATION", "OVERRIDE_DEPRECATION")
override fun leaseReplSession(
aliveFlagPath: String?,
targetPlatform: CompileService.TargetPlatform,
servicesFacade: CompilerCallbackServicesFacade,
templateClasspath: List<File>,
templateClassName: String,
scriptArgs: Array<out Any?>?,
scriptArgsTypes: Array<out Class<out Any>>?,
compilerMessagesOutputStream: RemoteOutputStream,
evalOutputStream: RemoteOutputStream?,
evalErrorStream: RemoteOutputStream?,
evalInputStream: RemoteInputStream?,
operationsTracer: RemoteOperationsTracer?
): CompileService.CallResult<Int> {
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember", "OVERRIDE_DEPRECATION")
override fun remoteReplLineCheck(sessionId: Int, codeLine: ReplCodeLine): CompileService.CallResult<ReplCheckResult> {
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember", "OVERRIDE_DEPRECATION")
override fun remoteReplLineCompile(
sessionId: Int,
codeLine: ReplCodeLine,
history: List<ReplCodeLine>?
): CompileService.CallResult<ReplCompileResult> {
reportNotImplemented()
}
@Suppress("OverridingDeprecatedMember", "OVERRIDE_DEPRECATION")
override fun remoteReplLineEval(
sessionId: Int,
codeLine: ReplCodeLine,
history: List<ReplCodeLine>?
): CompileService.CallResult<ReplEvalResult> {
reportNotImplemented()
}
// normal methods:
override fun compile(
sessionId: Int,
compilerArguments: Array<out String>,
compilationOptions: CompilationOptions,
servicesFacade: CompilerServicesFacadeBase,
compilationResults: CompilationResults?
) = runBlocking {
asyncCompileService.compile(
sessionId,
compilerArguments,
compilationOptions,
servicesFacade.toClient(),
compilationResults?.toClient() // TODO
)
}
override fun leaseReplSession(
aliveFlagPath: String?,
compilerArguments: Array<out String>,
compilationOptions: CompilationOptions,
servicesFacade: CompilerServicesFacadeBase,
templateClasspath: List<File>,
templateClassName: String
) = runBlocking {
asyncCompileService.leaseReplSession(
aliveFlagPath,
compilerArguments,
compilationOptions,
servicesFacade.toClient(),
templateClasspath,
templateClassName
)
}
override fun replCreateState(sessionId: Int) = runBlocking {
asyncCompileService.replCreateState(sessionId)
}.toRMI()
override fun getUsedMemory() = runBlocking {
asyncCompileService.getUsedMemory()
}
override fun getDaemonOptions() = runBlocking {
asyncCompileService.getDaemonOptions()
}
override fun getDaemonInfo() = runBlocking {
asyncCompileService.getDaemonInfo()
}
override fun getKotlinVersion() = runBlocking {
asyncCompileService.getKotlinVersion()
}
override fun getDaemonJVMOptions() = runBlocking {
asyncCompileService.getDaemonJVMOptions()
}
override fun registerClient(aliveFlagPath: String?) = runBlocking {
asyncCompileService.registerClient(aliveFlagPath)
}
override fun getClients() = runBlocking {
asyncCompileService.getClients()
}
override fun leaseCompileSession(aliveFlagPath: String?) = runBlocking {
asyncCompileService.leaseCompileSession(aliveFlagPath)
}
override fun releaseCompileSession(sessionId: Int) = runBlocking {
asyncCompileService.releaseCompileSession(sessionId)
}
override fun shutdown() = runBlocking {
asyncCompileService.shutdown()
}
override fun scheduleShutdown(graceful: Boolean) = runBlocking {
asyncCompileService.scheduleShutdown(graceful)
}
override fun clearJarCache() = runBlocking {
asyncCompileService.clearJarCache()
}
override fun releaseReplSession(sessionId: Int) = runBlocking {
asyncCompileService.releaseReplSession(sessionId)
}
override fun replCheck(sessionId: Int, replStateId: Int, codeLine: ReplCodeLine) = runBlocking {
asyncCompileService.replCheck(sessionId, replStateId, codeLine)
}
override fun replCompile(
sessionId: Int,
replStateId: Int,
codeLine: ReplCodeLine
) = runBlocking {
asyncCompileService.replCompile(sessionId, replStateId, codeLine)
}
override fun checkCompilerId(expectedCompilerId: CompilerId) = runBlocking {
asyncCompileService.checkCompilerId(expectedCompilerId)
}
}
fun CompileServiceAsync.toRMI() = when (this) {
is CompileServiceAsyncWrapper -> this.rmiCompileService
else -> CompileServiceClientRMIWrapper(this)
}
@@ -1,49 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import org.jetbrains.kotlin.incremental.components.LookupInfo
import org.jetbrains.kotlin.load.kotlin.incremental.components.JvmPackagePartProto
import org.jetbrains.kotlin.modules.TargetId
interface CompilerCallbackServicesFacadeAsync : CompilerServicesFacadeBaseAsync {
suspend fun hasIncrementalCaches(): Boolean
suspend fun hasLookupTracker(): Boolean
suspend fun hasCompilationCanceledStatus(): Boolean
// ----------------------------------------------------
// IncrementalCache
suspend fun incrementalCache_getObsoletePackageParts(target: TargetId): Collection<String>
suspend fun incrementalCache_getObsoleteMultifileClassFacades(target: TargetId): Collection<String>
suspend fun incrementalCache_getPackagePartData(target: TargetId, partInternalName: String): JvmPackagePartProto?
suspend fun incrementalCache_getModuleMappingData(target: TargetId): ByteArray?
suspend fun incrementalCache_registerInline(target: TargetId, fromPath: String, jvmSignature: String, toPath: String)
suspend fun incrementalCache_getClassFilePath(target: TargetId, internalClassName: String): String
suspend fun incrementalCache_close(target: TargetId)
suspend fun incrementalCache_getMultifileFacadeParts(target: TargetId, internalName: String): Collection<String>?
// ----------------------------------------------------
// LookupTracker
suspend fun lookupTracker_requiresPosition(): Boolean
fun lookupTracker_record(lookups: Collection<LookupInfo>)
suspend fun lookupTracker_isDoNothing(): Boolean
// ----------------------------------------------------
// CompilationCanceledStatus
suspend fun compilationCanceledStatus_checkCanceled(): Void?
}
@@ -1,25 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import java.io.Serializable
interface CompilerServicesFacadeBaseAsync {
/**
* Reports different kind of diagnostic messages from compile daemon to compile daemon clients (jps, gradle, ...)
*/
suspend fun report(category: Int, severity: Int, message: String?, attachment: Serializable?)
}
suspend fun CompilerServicesFacadeBaseAsync.report(
category: ReportCategory,
severity: ReportSeverity,
message: String? = null,
attachment: Serializable? = null
) {
report(category.code, severity.code, message, attachment)
}
@@ -1,22 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import java.io.Serializable
class CompilerServicesFacadeBaseAsyncWrapper(
val rmiImpl: CompilerServicesFacadeBase
) : CompilerServicesFacadeBaseAsync {
override suspend fun report(category: Int, severity: Int, message: String?, attachment: Serializable?) =
rmiImpl.report(category, severity, message, attachment)
}
fun CompilerServicesFacadeBase.toClient() =
if (this is CompilerServicesFacadeBaseRMIWrapper) this.clientSide
else CompilerServicesFacadeBaseAsyncWrapper(this)
@@ -1,21 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import kotlinx.coroutines.runBlocking
import java.io.Serializable
class CompilerServicesFacadeBaseRMIWrapper(val clientSide: CompilerServicesFacadeBaseAsync) : CompilerServicesFacadeBase, Serializable {
override fun report(category: Int, severity: Int, message: String?, attachment: Serializable?) = runBlocking {
clientSide.report(category, severity, message, attachment)
}
}
fun CompilerServicesFacadeBaseAsync.toRMI() =
if (this is CompilerServicesFacadeBaseAsyncWrapper) this.rmiImpl
else CompilerServicesFacadeBaseRMIWrapper(this)
@@ -1,10 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
enum class DaemonProtocolVariant {
RMI, SOCKETS
}
@@ -1,9 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
interface IncrementalCompilerServicesFacadeAsync : CompilerServicesFacadeBaseAsync
@@ -1,20 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import org.jetbrains.kotlin.cli.common.repl.ILineId
interface ReplStateFacadeAsync {
suspend fun getId(): Int
suspend fun getHistorySize(): Int
suspend fun historyGet(index: Int): ILineId
suspend fun historyReset(): List<ILineId>
suspend fun historyResetTo(id: ILineId): List<ILineId>
}
@@ -1,30 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import org.jetbrains.kotlin.cli.common.repl.ILineId
class ReplStateFacadeAsyncWrapper(val rmiReplStateFacade: ReplStateFacade) : ReplStateFacadeAsync {
override suspend fun getId() = rmiReplStateFacade.getId()
override suspend fun getHistorySize() = rmiReplStateFacade.getHistorySize()
override suspend fun historyGet(index: Int) = rmiReplStateFacade.historyGet(index)
override suspend fun historyReset() = rmiReplStateFacade.historyReset()
override suspend fun historyResetTo(id: ILineId) = rmiReplStateFacade.historyResetTo(id)
}
fun ReplStateFacade.toClient() = ReplStateFacadeAsyncWrapper(this)
fun CompileService.CallResult<ReplStateFacade>.toClient() = when (this) {
is CompileService.CallResult.Good -> CompileService.CallResult.Good(this.result.toClient())
is CompileService.CallResult.Dying -> this
is CompileService.CallResult.Error -> this
is CompileService.CallResult.Ok -> this
}
@@ -1,32 +0,0 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.cli.common.repl.ILineId
import java.io.Serializable
class ReplStateFacadeRMIWrapper(val clientSide: ReplStateFacadeAsync) : ReplStateFacade, Serializable {
override fun getId() = runBlocking { clientSide.getId() }
override fun getHistorySize() = runBlocking { clientSide.getHistorySize() }
override fun historyGet(index: Int) = runBlocking { clientSide.historyGet(index) }
override fun historyReset() = runBlocking { clientSide.historyReset() }
override fun historyResetTo(id: ILineId) = runBlocking { clientSide.historyResetTo(id) }
}
fun ReplStateFacadeAsync.toRMI() = ReplStateFacadeRMIWrapper(this)
fun CompileService.CallResult<ReplStateFacadeAsync>.toRMI() = when (this) {
is CompileService.CallResult.Good -> CompileService.CallResult.Good(this.result.toRMI())
is CompileService.CallResult.Dying -> this
is CompileService.CallResult.Error -> this
is CompileService.CallResult.Ok -> this
}
@@ -1,10 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.daemon.common
import kotlinx.coroutines.runBlocking
fun <R> Profiler.withMeasureBlocking(obj: Any?, body: suspend () -> R): R = runBlocking { withMeasure<R>(obj) { body() } }