From 7cfb91192fe7077812f6dd8cd8db075d46a4001d Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 22 Jun 2015 17:36:14 +0200 Subject: [PATCH] K2JVMCompiler: cleanup after J2K --- .../jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt | 37 +++++-------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt index 6c12f72e02d..0295cbaab10 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -16,8 +16,6 @@ package org.jetbrains.kotlin.cli.jvm -import com.google.common.base.Splitter -import com.google.common.collect.Lists import com.intellij.openapi.Disposable import kotlin.Unit import org.jetbrains.kotlin.cli.common.CLICompiler @@ -71,15 +69,11 @@ public class K2JVMCompiler : CLICompiler() { if (IncrementalCompilation.ENABLED) { val incrementalCacheProvider = services.get(javaClass()) - if (incrementalCacheProvider != null) { - configuration.put(JVMConfigurationKeys.INCREMENTAL_CACHE_PROVIDER, incrementalCacheProvider) - } + configuration.put(JVMConfigurationKeys.INCREMENTAL_CACHE_PROVIDER, incrementalCacheProvider) } val locator = services.get(javaClass()) - if (locator != null) { - configuration.put(JVMConfigurationKeys.COMPILER_JAR_LOCATOR, locator) - } + configuration.put(JVMConfigurationKeys.COMPILER_JAR_LOCATOR, locator) try { if (!arguments.noJdk) { @@ -198,11 +192,7 @@ public class K2JVMCompiler : CLICompiler() { } if (arguments.reportPerf) { - PerformanceCounter.report(object : Function1 { - override fun invoke(s: String): Unit { - reportPerf(environment.configuration, s) - } - }) + PerformanceCounter.report { s -> reportPerf(environment.configuration, s) } } return OK } @@ -224,9 +214,7 @@ public class K2JVMCompiler : CLICompiler() { /** * Allow derived classes to add additional command line arguments */ - override fun createArguments(): K2JVMCompilerArguments { - return K2JVMCompilerArguments() - } + override fun createArguments() = K2JVMCompilerArguments() companion object { @@ -235,9 +223,8 @@ public class K2JVMCompiler : CLICompiler() { } public fun reportPerf(configuration: CompilerConfiguration, message: String) { - val collector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) - assert(collector != null) - collector!!.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION) + val collector = configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]!! + collector.report(CompilerMessageSeverity.INFO, "PERF: " + message, CompilerMessageLocation.NO_LOCATION) } private fun putAdvancedOptions(configuration: CompilerConfiguration, arguments: K2JVMCompilerArguments) { @@ -248,11 +235,9 @@ public class K2JVMCompiler : CLICompiler() { } private fun getClasspath(paths: KotlinPaths, arguments: K2JVMCompilerArguments): List { - val classpath = Lists.newArrayList() + val classpath = arrayListOf() if (arguments.classpath != null) { - for (element in Splitter.on(File.pathSeparatorChar).split(arguments.classpath)) { - classpath.add(File(element)) - } + classpath.addAll(arguments.classpath.split(File.pathSeparatorChar).map { File(it) }) } if (!arguments.noStdlib) { classpath.add(paths.getRuntimePath()) @@ -261,11 +246,9 @@ public class K2JVMCompiler : CLICompiler() { } private fun getAnnotationsPath(paths: KotlinPaths, arguments: K2JVMCompilerArguments): List { - val annotationsPath = Lists.newArrayList() + val annotationsPath = arrayListOf() if (arguments.annotations != null) { - for (element in Splitter.on(File.pathSeparatorChar).split(arguments.annotations)) { - annotationsPath.add(File(element)) - } + annotationsPath.addAll(arguments.annotations.split(File.pathSeparatorChar).map { File(it) }) } if (!arguments.noJdkAnnotations) { annotationsPath.add(paths.getJdkAnnotationsPath())