Avoid catching exceptions from workers in GradleKotlinCompilerRunner
Exceptions were catched in `KotlinCompilerRunner.runCompiler`.
When the method from superclass is not used in
`GradleKotlinCompilerRunner`, the superclass does not make much sense
anymore, so I turned it into util object.
Original commit: a41c2d759a
This commit is contained in:
@@ -21,6 +21,7 @@ import org.jetbrains.jps.api.GlobalOptions
|
|||||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||||
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
import org.jetbrains.kotlin.cli.common.KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil
|
||||||
import org.jetbrains.kotlin.config.CompilerSettings
|
import org.jetbrains.kotlin.config.CompilerSettings
|
||||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||||
import org.jetbrains.kotlin.config.additionalArgumentsAsList
|
import org.jetbrains.kotlin.config.additionalArgumentsAsList
|
||||||
@@ -32,8 +33,8 @@ import java.io.ByteArrayOutputStream
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.PrintStream
|
import java.io.PrintStream
|
||||||
|
|
||||||
class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
class JpsKotlinCompilerRunner {
|
||||||
override val log: KotlinLogger = JpsKotlinLogger(KotlinBuilder.LOG)
|
private val log: KotlinLogger = JpsKotlinLogger(KotlinBuilder.LOG)
|
||||||
|
|
||||||
private var compilerSettings: CompilerSettings? = null
|
private var compilerSettings: CompilerSettings? = null
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun compileWithDaemonOrFallback(
|
private fun compileWithDaemonOrFallback(
|
||||||
compilerClassName: String,
|
compilerClassName: String,
|
||||||
compilerArgs: CommonCompilerArguments,
|
compilerArgs: CommonCompilerArguments,
|
||||||
environment: JpsCompilerEnvironment
|
environment: JpsCompilerEnvironment
|
||||||
@@ -166,6 +167,15 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun runCompiler(compilerClassName: String, compilerArgs: CommonCompilerArguments, environment: JpsCompilerEnvironment) {
|
||||||
|
try {
|
||||||
|
compileWithDaemonOrFallback(compilerClassName, compilerArgs, environment)
|
||||||
|
} catch (e: Throwable) {
|
||||||
|
MessageCollectorUtil.reportException(environment.messageCollector, e)
|
||||||
|
reportInternalCompilerError(environment.messageCollector)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun compileWithDaemon(
|
private fun compileWithDaemon(
|
||||||
compilerClassName: String,
|
compilerClassName: String,
|
||||||
compilerArgs: CommonCompilerArguments,
|
compilerArgs: CommonCompilerArguments,
|
||||||
@@ -311,7 +321,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getReturnCodeFromObject(rc: Any?): String = when {
|
private fun getReturnCodeFromObject(rc: Any?): String = when {
|
||||||
rc == null -> INTERNAL_ERROR
|
rc == null -> ExitCode.INTERNAL_ERROR.toString()
|
||||||
ExitCode::class.java.name == rc::class.java.name -> rc.toString()
|
ExitCode::class.java.name == rc::class.java.name -> rc.toString()
|
||||||
else -> throw IllegalStateException("Unexpected return: " + rc)
|
else -> throw IllegalStateException("Unexpected return: " + rc)
|
||||||
}
|
}
|
||||||
@@ -333,7 +343,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
|
|||||||
|
|
||||||
environment.withProgressReporter { progress ->
|
environment.withProgressReporter { progress ->
|
||||||
progress.progress("connecting to daemon")
|
progress.progress("connecting to daemon")
|
||||||
newDaemonConnection(
|
KotlinCompilerRunnerUtils.newDaemonConnection(
|
||||||
compilerId,
|
compilerId,
|
||||||
clientFlagFile,
|
clientFlagFile,
|
||||||
sessionFlagFile,
|
sessionFlagFile,
|
||||||
|
|||||||
Reference in New Issue
Block a user