Skip to content

Commit a236400

Browse files
committed
CLI: drop CommonCompilerArguments.createDefaultInstance
Move the corresponding default value initializers to the field declarations
1 parent 26e3d2c commit a236400

File tree

7 files changed

+16
-34
lines changed

7 files changed

+16
-34
lines changed

compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.jetbrains.kotlin.cli.common.arguments;
1818

19-
import org.jetbrains.annotations.NotNull;
20-
2119
public abstract class CommonCompilerArguments extends CommonToolArguments {
2220
public static final long serialVersionUID = 0L;
2321

@@ -87,11 +85,6 @@ public abstract class CommonCompilerArguments extends CommonToolArguments {
8785
)
8886
public String coroutinesState = WARN;
8987

90-
@NotNull
91-
public static CommonCompilerArguments createDefaultInstance() {
92-
return new DummyImpl();
93-
}
94-
9588
public static final String WARN = "warn";
9689
public static final String ERROR = "error";
9790
public static final String ENABLE = "enable";

compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
package org.jetbrains.kotlin.cli.common.arguments;
1818

19-
import org.jetbrains.annotations.NotNull;
20-
2119
import static org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL;
2220
import static org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL;
2321

@@ -57,7 +55,7 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
5755
valueDescription = "{ plain, amd, commonjs, umd }",
5856
description = "Kind of a module generated by compiler"
5957
)
60-
public String moduleKind;
58+
public String moduleKind = K2JsArgumentConstants.MODULE_PLAIN;
6159

6260
@GradleOption(DefaultValues.JsMain.class)
6361
@Argument(value = "-main", valueDescription = "{" + CALL + "," + NO_CALL + "}", description = "Whether a main function should be called")
@@ -93,11 +91,4 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
9391
description = "Paths to friend modules"
9492
)
9593
public String friendModules;
96-
97-
@NotNull
98-
public static K2JSCompilerArguments createDefaultInstance() {
99-
K2JSCompilerArguments arguments = new K2JSCompilerArguments();
100-
arguments.moduleKind = K2JsArgumentConstants.MODULE_PLAIN;
101-
return arguments;
102-
}
10394
}

compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
package org.jetbrains.kotlin.cli.common.arguments;
1818

19-
import org.jetbrains.annotations.NotNull;
2019
import org.jetbrains.kotlin.config.JvmTarget;
2120

2221
public class K2JVMCompilerArguments extends CommonCompilerArguments {
@@ -81,7 +80,7 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
8180
valueDescription = "<version>",
8281
description = "Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6"
8382
)
84-
public String jvmTarget;
83+
public String jvmTarget = JvmTarget.DEFAULT.getDescription();
8584

8685
@GradleOption(DefaultValues.BooleanFalseDefault.class)
8786
@Argument(value = "-java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters")
@@ -149,11 +148,4 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
149148

150149
// Paths to output directories for friend modules.
151150
public String[] friendPaths;
152-
153-
@NotNull
154-
public static K2JVMCompilerArguments createDefaultInstance() {
155-
K2JVMCompilerArguments arguments = new K2JVMCompilerArguments();
156-
arguments.jvmTarget = JvmTarget.DEFAULT.getDescription();
157-
return arguments;
158-
}
159151
}

idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/BaseKotlinCompilerSettings.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import com.intellij.openapi.components.StoragePathMacros.PROJECT_CONFIG_DIR
2121
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters
2222
import com.intellij.util.xmlb.XmlSerializer
2323
import org.jdom.Element
24-
import org.jetbrains.kotlin.cli.common.arguments.*
24+
import org.jetbrains.kotlin.cli.common.arguments.collectFieldsToCopy
25+
import org.jetbrains.kotlin.cli.common.arguments.copyBean
2526
import org.jetbrains.kotlin.config.SettingConstants
2627

2728
abstract class BaseKotlinCompilerSettings<T : Any> protected constructor() : PersistentStateComponent<Element>, Cloneable {
@@ -66,9 +67,9 @@ abstract class BaseKotlinCompilerSettings<T : Any> protected constructor() : Per
6667
const val KOTLIN_COMPILER_SETTINGS_PATH = PROJECT_CONFIG_DIR + "/" + SettingConstants.KOTLIN_COMPILER_SETTINGS_FILE
6768

6869
private val SKIP_DEFAULT_VALUES = SkipDefaultValuesSerializationFilters(
69-
CommonCompilerArguments.createDefaultInstance(),
70-
K2JVMCompilerArguments.createDefaultInstance(),
71-
K2JSCompilerArguments.createDefaultInstance()
70+
KotlinCommonCompilerArgumentsHolder.createDefaultArguments(),
71+
Kotlin2JvmCompilerArgumentsHolder.createDefaultArguments(),
72+
Kotlin2JsCompilerArgumentsHolder.createDefaultArguments()
7273
)
7374
}
7475
}

idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/Kotlin2JsCompilerArgumentsHolder.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ import org.jetbrains.kotlin.idea.compiler.configuration.BaseKotlinCompilerSettin
2626
storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE),
2727
Storage(file = KOTLIN_COMPILER_SETTINGS_PATH, scheme = StorageScheme.DIRECTORY_BASED)))
2828
class Kotlin2JsCompilerArgumentsHolder : BaseKotlinCompilerSettings<K2JSCompilerArguments>() {
29-
override fun createSettings() = K2JSCompilerArguments.createDefaultInstance()
29+
override fun createSettings() = createDefaultArguments()
3030

3131
override fun validateNewSettings(settings: K2JSCompilerArguments) {
3232
validateInheritedFieldsUnchanged(settings)
3333
}
3434

3535
companion object {
3636
fun getInstance(project: Project) = ServiceManager.getService(project, Kotlin2JsCompilerArgumentsHolder::class.java)!!
37+
38+
fun createDefaultArguments(): K2JSCompilerArguments = K2JSCompilerArguments()
3739
}
3840
}

idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/Kotlin2JvmCompilerArgumentsHolder.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,22 @@ package org.jetbrains.kotlin.idea.compiler.configuration
1919
import com.intellij.openapi.components.*
2020
import com.intellij.openapi.project.Project
2121
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
22-
2322
import org.jetbrains.kotlin.config.SettingConstants.KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION
2423
import org.jetbrains.kotlin.idea.compiler.configuration.BaseKotlinCompilerSettings.Companion.KOTLIN_COMPILER_SETTINGS_PATH
2524

2625
@State(name = KOTLIN_TO_JVM_COMPILER_ARGUMENTS_SECTION,
2726
storages = arrayOf(Storage(file = StoragePathMacros.PROJECT_FILE),
2827
Storage(file = KOTLIN_COMPILER_SETTINGS_PATH, scheme = StorageScheme.DIRECTORY_BASED)))
2928
class Kotlin2JvmCompilerArgumentsHolder : BaseKotlinCompilerSettings<K2JVMCompilerArguments>() {
30-
override fun createSettings() = K2JVMCompilerArguments.createDefaultInstance()
29+
override fun createSettings() = createDefaultArguments()
3130

3231
override fun validateNewSettings(settings: K2JVMCompilerArguments) {
3332
validateInheritedFieldsUnchanged(settings)
3433
}
3534

3635
companion object {
3736
fun getInstance(project: Project) = ServiceManager.getService(project, Kotlin2JvmCompilerArgumentsHolder::class.java)!!
37+
38+
fun createDefaultArguments(): K2JVMCompilerArguments = K2JVMCompilerArguments()
3839
}
3940
}

idea/idea-analysis/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCommonCompilerArgumentsHolder.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,14 @@ class KotlinCommonCompilerArgumentsHolder : BaseKotlinCompilerSettings<CommonCom
5555
}
5656
}
5757

58-
override fun createSettings() = CommonCompilerArguments.createDefaultInstance()
58+
override fun createSettings() = createDefaultArguments()
5959

6060
companion object {
6161
private val DEFAULT_LANGUAGE_VERSION = LanguageVersion.LATEST_STABLE.versionString
6262

6363
fun getInstance(project: Project) =
6464
ServiceManager.getService<KotlinCommonCompilerArgumentsHolder>(project, KotlinCommonCompilerArgumentsHolder::class.java)!!
65+
66+
fun createDefaultArguments(): CommonCompilerArguments = CommonCompilerArguments.DummyImpl()
6567
}
6668
}

0 commit comments

Comments
 (0)