CLI: drop CommonCompilerArguments.createDefaultInstance
Move the corresponding default value initializers to the field declarations
This commit is contained in:
-7
@@ -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";
|
||||
|
||||
+1
-10
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-9
@@ -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 = "<version>",
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-4
@@ -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<T : Any> protected constructor() : PersistentStateComponent<Element>, Cloneable {
|
||||
@@ -66,9 +67,9 @@ abstract class BaseKotlinCompilerSettings<T : Any> 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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -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<K2JSCompilerArguments>() {
|
||||
override fun createSettings() = K2JSCompilerArguments.createDefaultInstance()
|
||||
override fun createSettings() = createDefaultArguments()
|
||||
|
||||
override fun validateNewSettings(settings: K2JSCompilerArguments) {
|
||||
validateInheritedFieldsUnchanged(settings)
|
||||
@@ -34,5 +34,7 @@ class Kotlin2JsCompilerArgumentsHolder : BaseKotlinCompilerSettings<K2JSCompiler
|
||||
|
||||
companion object {
|
||||
fun getInstance(project: Project) = ServiceManager.getService(project, Kotlin2JsCompilerArgumentsHolder::class.java)!!
|
||||
|
||||
fun createDefaultArguments(): K2JSCompilerArguments = K2JSCompilerArguments()
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.compiler.configuration
|
||||
import com.intellij.openapi.components.*
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
|
||||
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.BaseKotlinCompilerSettings.Companion.KOTLIN_COMPILER_SETTINGS_PATH
|
||||
|
||||
@@ -27,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 Kotlin2JvmCompilerArgumentsHolder : BaseKotlinCompilerSettings<K2JVMCompilerArguments>() {
|
||||
override fun createSettings() = K2JVMCompilerArguments.createDefaultInstance()
|
||||
override fun createSettings() = createDefaultArguments()
|
||||
|
||||
override fun validateNewSettings(settings: K2JVMCompilerArguments) {
|
||||
validateInheritedFieldsUnchanged(settings)
|
||||
@@ -35,5 +34,7 @@ class Kotlin2JvmCompilerArgumentsHolder : BaseKotlinCompilerSettings<K2JVMCompil
|
||||
|
||||
companion object {
|
||||
fun getInstance(project: Project) = ServiceManager.getService(project, Kotlin2JvmCompilerArgumentsHolder::class.java)!!
|
||||
|
||||
fun createDefaultArguments(): K2JVMCompilerArguments = K2JVMCompilerArguments()
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -55,12 +55,14 @@ class KotlinCommonCompilerArgumentsHolder : BaseKotlinCompilerSettings<CommonCom
|
||||
}
|
||||
}
|
||||
|
||||
override fun createSettings() = CommonCompilerArguments.createDefaultInstance()
|
||||
override fun createSettings() = createDefaultArguments()
|
||||
|
||||
companion object {
|
||||
private val DEFAULT_LANGUAGE_VERSION = LanguageVersion.LATEST_STABLE.versionString
|
||||
|
||||
fun getInstance(project: Project) =
|
||||
ServiceManager.getService<KotlinCommonCompilerArgumentsHolder>(project, KotlinCommonCompilerArgumentsHolder::class.java)!!
|
||||
|
||||
fun createDefaultArguments(): CommonCompilerArguments = CommonCompilerArguments.DummyImpl()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user