From a236400785e3a304fa4a4042aeef80d9fedc1a6c Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 25 May 2017 20:26:49 +0300 Subject: [PATCH] CLI: drop CommonCompilerArguments.createDefaultInstance Move the corresponding default value initializers to the field declarations --- .../cli/common/arguments/CommonCompilerArguments.java | 7 ------- .../cli/common/arguments/K2JSCompilerArguments.java | 11 +---------- .../cli/common/arguments/K2JVMCompilerArguments.java | 10 +--------- .../configuration/BaseKotlinCompilerSettings.kt | 9 +++++---- .../configuration/Kotlin2JsCompilerArgumentsHolder.kt | 4 +++- .../Kotlin2JvmCompilerArgumentsHolder.kt | 5 +++-- .../KotlinCommonCompilerArgumentsHolder.kt | 4 +++- 7 files changed, 16 insertions(+), 34 deletions(-) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java index baee38efbf7..7ec4c000bcf 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java @@ -16,8 +16,6 @@ package org.jetbrains.kotlin.cli.common.arguments; -import org.jetbrains.annotations.NotNull; - public abstract class CommonCompilerArguments extends CommonToolArguments { public static final long serialVersionUID = 0L; @@ -87,11 +85,6 @@ public abstract class CommonCompilerArguments extends CommonToolArguments { ) public String coroutinesState = WARN; - @NotNull - public static CommonCompilerArguments createDefaultInstance() { - return new DummyImpl(); - } - public static final String WARN = "warn"; public static final String ERROR = "error"; public static final String ENABLE = "enable"; diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.java index c761c35f07f..d8e0f5d0828 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.java @@ -16,8 +16,6 @@ package org.jetbrains.kotlin.cli.common.arguments; -import org.jetbrains.annotations.NotNull; - import static org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL; import static org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL; @@ -57,7 +55,7 @@ public class K2JSCompilerArguments extends CommonCompilerArguments { valueDescription = "{ plain, amd, commonjs, umd }", description = "Kind of a module generated by compiler" ) - public String moduleKind; + public String moduleKind = K2JsArgumentConstants.MODULE_PLAIN; @GradleOption(DefaultValues.JsMain.class) @Argument(value = "-main", valueDescription = "{" + CALL + "," + NO_CALL + "}", description = "Whether a main function should be called") @@ -93,11 +91,4 @@ public class K2JSCompilerArguments extends CommonCompilerArguments { description = "Paths to friend modules" ) public String friendModules; - - @NotNull - public static K2JSCompilerArguments createDefaultInstance() { - K2JSCompilerArguments arguments = new K2JSCompilerArguments(); - arguments.moduleKind = K2JsArgumentConstants.MODULE_PLAIN; - return arguments; - } } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java index 58e02f37993..f6c66fbbb73 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java @@ -16,7 +16,6 @@ package org.jetbrains.kotlin.cli.common.arguments; -import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.config.JvmTarget; public class K2JVMCompilerArguments extends CommonCompilerArguments { @@ -81,7 +80,7 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments { valueDescription = "", description = "Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6" ) - public String jvmTarget; + public String jvmTarget = JvmTarget.DEFAULT.getDescription(); @GradleOption(DefaultValues.BooleanFalseDefault.class) @Argument(value = "-java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters") @@ -149,11 +148,4 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments { // Paths to output directories for friend modules. public String[] friendPaths; - - @NotNull - public static K2JVMCompilerArguments createDefaultInstance() { - K2JVMCompilerArguments arguments = new K2JVMCompilerArguments(); - arguments.jvmTarget = JvmTarget.DEFAULT.getDescription(); - return arguments; - } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/BaseKotlinCompilerSettings.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/BaseKotlinCompilerSettings.kt index 97dde831af5..5759b09ac4e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/BaseKotlinCompilerSettings.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/BaseKotlinCompilerSettings.kt @@ -21,7 +21,8 @@ import com.intellij.openapi.components.StoragePathMacros.PROJECT_CONFIG_DIR import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters import com.intellij.util.xmlb.XmlSerializer import org.jdom.Element -import org.jetbrains.kotlin.cli.common.arguments.* +import org.jetbrains.kotlin.cli.common.arguments.collectFieldsToCopy +import org.jetbrains.kotlin.cli.common.arguments.copyBean import org.jetbrains.kotlin.config.SettingConstants abstract class BaseKotlinCompilerSettings protected constructor() : PersistentStateComponent, Cloneable { @@ -66,9 +67,9 @@ abstract class BaseKotlinCompilerSettings protected constructor() : Per const val KOTLIN_COMPILER_SETTINGS_PATH = PROJECT_CONFIG_DIR + "/" + SettingConstants.KOTLIN_COMPILER_SETTINGS_FILE private val SKIP_DEFAULT_VALUES = SkipDefaultValuesSerializationFilters( - CommonCompilerArguments.createDefaultInstance(), - K2JVMCompilerArguments.createDefaultInstance(), - K2JSCompilerArguments.createDefaultInstance() + KotlinCommonCompilerArgumentsHolder.createDefaultArguments(), + Kotlin2JvmCompilerArgumentsHolder.createDefaultArguments(), + Kotlin2JsCompilerArgumentsHolder.createDefaultArguments() ) } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/Kotlin2JsCompilerArgumentsHolder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/Kotlin2JsCompilerArgumentsHolder.kt index 65e78dddac8..b61c68287b0 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/Kotlin2JsCompilerArgumentsHolder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/Kotlin2JsCompilerArgumentsHolder.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.idea.compiler.configuration.BaseKotlinCompilerSettin storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE), Storage(file = KOTLIN_COMPILER_SETTINGS_PATH, scheme = StorageScheme.DIRECTORY_BASED))) class Kotlin2JsCompilerArgumentsHolder : BaseKotlinCompilerSettings() { - override fun createSettings() = K2JSCompilerArguments.createDefaultInstance() + override fun createSettings() = createDefaultArguments() override fun validateNewSettings(settings: K2JSCompilerArguments) { validateInheritedFieldsUnchanged(settings) @@ -34,5 +34,7 @@ class Kotlin2JsCompilerArgumentsHolder : BaseKotlinCompilerSettings() { - override fun createSettings() = K2JVMCompilerArguments.createDefaultInstance() + override fun createSettings() = createDefaultArguments() override fun validateNewSettings(settings: K2JVMCompilerArguments) { validateInheritedFieldsUnchanged(settings) @@ -35,5 +34,7 @@ class Kotlin2JvmCompilerArgumentsHolder : BaseKotlinCompilerSettings(project, KotlinCommonCompilerArgumentsHolder::class.java)!! + + fun createDefaultArguments(): CommonCompilerArguments = CommonCompilerArguments.DummyImpl() } }