Introduce CompilerConfiguration#getNotNull and getBoolean
To reduce boilerplate at call sites
This commit is contained in:
@@ -248,11 +248,9 @@ open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
}
|
||||
|
||||
fun reportPerf(configuration: CompilerConfiguration, message: String) {
|
||||
if (!configuration.get(CLIConfigurationKeys.REPORT_PERF, false)) {
|
||||
return
|
||||
}
|
||||
if (!configuration.getBoolean(CLIConfigurationKeys.REPORT_PERF)) return
|
||||
|
||||
val collector = configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]!!
|
||||
val collector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION)
|
||||
}
|
||||
|
||||
|
||||
@@ -244,8 +244,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
fun getSourceFiles(): List<KtFile> = sourceFiles
|
||||
|
||||
private fun report(severity: CompilerMessageSeverity, message: String) {
|
||||
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
?: throw CompileEnvironmentException(message)
|
||||
val messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
messageCollector.report(severity, message, CompilerMessageLocation.NO_LOCATION)
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -417,7 +417,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
|
||||
private fun checkKotlinPackageUsage(environment: KotlinCoreEnvironment, files: Collection<KtFile>): Boolean {
|
||||
if (environment.configuration.get(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE) == true) {
|
||||
if (environment.configuration.getBoolean(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE)) {
|
||||
return true
|
||||
}
|
||||
val messageCollector = environment.configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
|
||||
@@ -434,8 +434,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
|
||||
private val KotlinCoreEnvironment.messageCollector: MessageCollector
|
||||
get() = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
?: error("Message collector not specified in compiler configuration")
|
||||
get() = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
|
||||
private fun reportRuntimeConflicts(messageCollector: MessageCollector, jvmClasspathRoots: List<File>) {
|
||||
fun String.removeIdeaVersionSuffix(): String {
|
||||
|
||||
Reference in New Issue
Block a user