diff --git a/build-common/src/org/jetbrains/kotlin/compilerRunner/ArgumentUtils.java b/build-common/src/org/jetbrains/kotlin/compilerRunner/ArgumentUtils.java index 2beef3faae1..7e1cb66b7a9 100644 --- a/build-common/src/org/jetbrains/kotlin/compilerRunner/ArgumentUtils.java +++ b/build-common/src/org/jetbrains/kotlin/compilerRunner/ArgumentUtils.java @@ -36,7 +36,7 @@ public class ArgumentUtils { throws InstantiationException, IllegalAccessException { List result = new ArrayList<>(); convertArgumentsToStringList(arguments, arguments.getClass().newInstance(), arguments.getClass(), result); - result.addAll(arguments.freeArgs); + result.addAll(arguments.getFreeArgs()); return result; } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 36981369d49..c7f74fa0a2a 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -14,50 +14,53 @@ * limitations under the License. */ -package org.jetbrains.kotlin.cli.common.arguments; +package org.jetbrains.kotlin.cli.common.arguments -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.config.AnalysisFlag; - -import java.util.HashMap; -import java.util.Map; +import org.jetbrains.kotlin.config.AnalysisFlag +import java.util.* @SuppressWarnings("WeakerAccess") -public abstract class CommonCompilerArguments extends CommonToolArguments { - public static final long serialVersionUID = 0L; +abstract class CommonCompilerArguments : CommonToolArguments() { + companion object { + @JvmStatic private val serialVersionUID = 0L - public static final String PLUGIN_OPTION_FORMAT = "plugin::="; + const val PLUGIN_OPTION_FORMAT = "plugin::=" - @GradleOption(DefaultValues.LanguageVersions.class) + const val WARN = "warn" + const val ERROR = "error" + const val ENABLE = "enable" + } + + @GradleOption(DefaultValues.LanguageVersions::class) @Argument( value = "-language-version", valueDescription = "", description = "Provide source compatibility with specified language version" ) - public String languageVersion; + var languageVersion: String? = null - @GradleOption(DefaultValues.LanguageVersions.class) + @GradleOption(DefaultValues.LanguageVersions::class) @Argument( value = "-api-version", valueDescription = "", description = "Allow to use declarations only from the specified version of bundled libraries" ) - public String apiVersion; + var apiVersion: String? = null @Argument( value = "-kotlin-home", valueDescription = "", description = "Path to Kotlin compiler home directory, used for runtime libraries discovery" ) - public String kotlinHome; + var kotlinHome: String? = null @Argument(value = "-P", valueDescription = PLUGIN_OPTION_FORMAT, description = "Pass an option to a plugin") - public String[] pluginOptions; + var pluginOptions: Array? = null // Advanced options @Argument(value = "-Xno-inline", description = "Disable method inlining") - public boolean noInline; + var noInline: Boolean = false // TODO Remove in 1.0 @Argument( @@ -65,52 +68,50 @@ public abstract class CommonCompilerArguments extends CommonToolArguments { valueDescription = "", description = "Repeat compilation (for performance analysis)" ) - public String repeat; + var repeat: String? = null - @Argument(value = "-Xskip-metadata-version-check", description = "Load classes with bad metadata version anyway (incl. pre-release classes)") - public boolean skipMetadataVersionCheck; + @Argument( + value = "-Xskip-metadata-version-check", + description = "Load classes with bad metadata version anyway (incl. pre-release classes)" + ) + var skipMetadataVersionCheck: Boolean = false @Argument(value = "-Xallow-kotlin-package", description = "Allow compiling code in package 'kotlin'") - public boolean allowKotlinPackage; + var allowKotlinPackage: Boolean = false @Argument(value = "-Xreport-output-files", description = "Report source to output files mapping") - public boolean reportOutputFiles; + var reportOutputFiles: Boolean = false @Argument(value = "-Xplugin", valueDescription = "", description = "Load plugins from the given classpath") - public String[] pluginClasspaths; + var pluginClasspaths: Array? = null @Argument(value = "-Xmulti-platform", description = "Enable experimental language support for multi-platform projects") - public boolean multiPlatform; + var multiPlatform: Boolean = false @Argument(value = "-Xno-check-impl", description = "Do not check presence of 'impl' modifier in multi-platform projects") - public boolean noCheckImpl; + var noCheckImpl: Boolean = false @Argument( value = "-Xintellij-plugin-root", valueDescription = "", description = "Path to the kotlin-compiler.jar or directory where IntelliJ configuration files can be found" ) - public String intellijPluginRoot; + var intellijPluginRoot: String? = null @Argument( value = "-Xcoroutines", valueDescription = "{enable|warn|error}", description = "Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier" ) - public String coroutinesState = WARN; + var coroutinesState: String? = WARN - public static final String WARN = "warn"; - public static final String ERROR = "error"; - public static final String ENABLE = "enable"; - - @NotNull - public Map, Object> configureAnalysisFlags() { - Map, Object> result = new HashMap<>(); - result.put(AnalysisFlag.getSkipMetadataVersionCheck(), skipMetadataVersionCheck); - result.put(AnalysisFlag.getMultiPlatformDoNotCheckImpl(), noCheckImpl); - return result; + open fun configureAnalysisFlags(): MutableMap, Any> { + return HashMap, Any>().apply { + put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck) + put(AnalysisFlag.multiPlatformDoNotCheckImpl, noCheckImpl) + } } // Used only for serialize and deserialize settings. Don't use in other places! - public static final class DummyImpl extends CommonCompilerArguments {} + class DummyImpl : CommonCompilerArguments() } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt index 93df6ebb1e9..a12c000f712 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonToolArguments.kt @@ -14,34 +14,34 @@ * limitations under the License. */ -package org.jetbrains.kotlin.cli.common.arguments; +package org.jetbrains.kotlin.cli.common.arguments -import org.jetbrains.kotlin.utils.SmartList; +import org.jetbrains.kotlin.utils.SmartList +import java.io.Serializable -import java.io.Serializable; -import java.util.List; +abstract class CommonToolArguments : Serializable { + companion object { + @JvmStatic private val serialVersionUID = 0L + } -public abstract class CommonToolArguments implements Serializable { - private static final long serialVersionUID = 0L; + var freeArgs: MutableList = SmartList() - public List freeArgs = new SmartList<>(); - - public transient ArgumentParseErrors errors = new ArgumentParseErrors(); + @Transient var errors: ArgumentParseErrors = ArgumentParseErrors() @Argument(value = "-help", shortName = "-h", description = "Print a synopsis of standard options") - public boolean help; + var help: Boolean = false @Argument(value = "-X", description = "Print a synopsis of advanced options") - public boolean extraHelp; + var extraHelp: Boolean = false @Argument(value = "-version", description = "Display compiler version") - public boolean version; + var version: Boolean = false - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-verbose", description = "Enable verbose logging output") - public boolean verbose; + var verbose: Boolean = false - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-nowarn", description = "Generate no warnings") - public boolean suppressWarnings; + var suppressWarnings: Boolean = false } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index d05939b9d7f..7e96346cf86 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -14,100 +14,102 @@ * limitations under the License. */ -package org.jetbrains.kotlin.cli.common.arguments; +package org.jetbrains.kotlin.cli.common.arguments -import static org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL; -import static org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL; +import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.CALL +import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants.NO_CALL -public class K2JSCompilerArguments extends CommonCompilerArguments { - public static final long serialVersionUID = 0L; +class K2JSCompilerArguments : CommonCompilerArguments() { + companion object { + @JvmStatic private val serialVersionUID = 0L + } - @GradleOption(DefaultValues.StringNullDefault.class) + @GradleOption(DefaultValues.StringNullDefault::class) @Argument(value = "-output", valueDescription = "", description = "Output file path") - public String outputFile; + var outputFile: String? = null - @GradleOption(DefaultValues.BooleanTrueDefault.class) + @GradleOption(DefaultValues.BooleanTrueDefault::class) @Argument(value = "-no-stdlib", description = "Don't use bundled Kotlin stdlib") - public boolean noStdlib; + var noStdlib: Boolean = false @Argument( value = "-libraries", valueDescription = "", description = "Paths to Kotlin libraries with .meta.js and .kjsm files, separated by system path separator" ) - public String libraries; + var libraries: String? = null - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-source-map", description = "Generate source map") - public boolean sourceMap; + var sourceMap: Boolean = false - @GradleOption(DefaultValues.StringNullDefault.class) + @GradleOption(DefaultValues.StringNullDefault::class) @Argument(value = "-source-map-prefix", description = "Prefix for paths in a source map") - public String sourceMapPrefix; + var sourceMapPrefix: String? = null @Argument( value = "-source-map-source-roots", valueDescription = "", description = "Base directories which are used to calculate relative paths to source files in source map" ) - public String sourceMapSourceRoots; + var sourceMapSourceRoots: String? = null - @GradleOption(DefaultValues.JsSourceMapContentModes.class) + @GradleOption(DefaultValues.JsSourceMapContentModes::class) @Argument( value = "-source-map-embed-sources", valueDescription = "{ always, never, inlining }", description = "Embed source files into source map" ) - public String sourceMapEmbedSources; + var sourceMapEmbedSources: String? = null - @GradleOption(DefaultValues.BooleanTrueDefault.class) + @GradleOption(DefaultValues.BooleanTrueDefault::class) @Argument(value = "-meta-info", description = "Generate .meta.js and .kjsm files with metadata. Use to create a library") - public boolean metaInfo; + var metaInfo: Boolean = false - @GradleOption(DefaultValues.JsEcmaVersions.class) + @GradleOption(DefaultValues.JsEcmaVersions::class) @Argument(value = "-target", valueDescription = "{ v5 }", description = "Generate JS files for specific ECMA version") - public String target; + var target: String? = null - @GradleOption(DefaultValues.JsModuleKinds.class) + @GradleOption(DefaultValues.JsModuleKinds::class) @Argument( value = "-module-kind", valueDescription = "{ plain, amd, commonjs, umd }", description = "Kind of a module generated by compiler" ) - public String moduleKind = K2JsArgumentConstants.MODULE_PLAIN; + var moduleKind: String? = K2JsArgumentConstants.MODULE_PLAIN - @GradleOption(DefaultValues.JsMain.class) - @Argument(value = "-main", valueDescription = "{" + CALL + "," + NO_CALL + "}", description = "Whether a main function should be called") - public String main; + @GradleOption(DefaultValues.JsMain::class) + @Argument(value = "-main", valueDescription = "{$CALL,$NO_CALL}", description = "Whether a main function should be called") + var main: String? = null @Argument( value = "-output-prefix", valueDescription = "", description = "Path to file which will be added to the beginning of output file" ) - public String outputPrefix; + var outputPrefix: String? = null @Argument( value = "-output-postfix", valueDescription = "", description = "Path to file which will be added to the end of output file" ) - public String outputPostfix; + var outputPostfix: String? = null // Advanced options - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-Xtyped-arrays", description = "Translate primitive arrays to JS typed arrays") - public boolean typedArrays; + var typedArrays: Boolean = false - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-Xfriend-modules-disabled", description = "Disable internal declaration export") - public boolean friendModulesDisabled; + var friendModulesDisabled: Boolean = false @Argument( value = "-Xfriend-modules", valueDescription = "", description = "Paths to friend modules" ) - public String friendModules; + var friendModules: String? = null } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArguments.kt index d55bd3dc816..285aa29a4cc 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSDceArguments.kt @@ -14,28 +14,30 @@ * limitations under the License. */ -package org.jetbrains.kotlin.cli.common.arguments; +package org.jetbrains.kotlin.cli.common.arguments -public class K2JSDceArguments extends CommonToolArguments { - private static final long serialVersionUID = 0; +class K2JSDceArguments : CommonToolArguments() { + companion object { + @JvmStatic private val serialVersionUID = 0L + } @Argument( value = "-output-dir", valueDescription = "", description = "Output directory" ) - public String outputDirectory; + var outputDirectory: String? = null @Argument( value = "-keep", valueDescription = "", description = "List of fully-qualified names of declarations that shouldn't be eliminated" ) - public String[] declarationsToKeep; + var declarationsToKeep: Array? = null @Argument( value = "-Xprint-reachability-info", description = "Print declarations marked as reachable" ) - public boolean printReachabilityInfo; + var printReachabilityInfo: Boolean = false } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt index 46126a49cfa..07bf9bcdcb8 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JVMCompilerArguments.kt @@ -14,78 +14,76 @@ * limitations under the License. */ -package org.jetbrains.kotlin.cli.common.arguments; +package org.jetbrains.kotlin.cli.common.arguments -import org.jetbrains.annotations.NotNull; -import org.jetbrains.kotlin.config.AnalysisFlag; -import org.jetbrains.kotlin.config.Jsr305State; -import org.jetbrains.kotlin.config.JvmTarget; +import org.jetbrains.kotlin.config.AnalysisFlag +import org.jetbrains.kotlin.config.Jsr305State +import org.jetbrains.kotlin.config.JvmTarget -import java.util.Map; - -@SuppressWarnings("WeakerAccess") -public class K2JVMCompilerArguments extends CommonCompilerArguments { - public static final long serialVersionUID = 0L; +class K2JVMCompilerArguments : CommonCompilerArguments() { + companion object { + @JvmStatic private val serialVersionUID = 0L + } @Argument(value = "-d", valueDescription = "", description = "Destination for generated class files") - public String destination; + var destination: String? = null @Argument(value = "-classpath", shortName = "-cp", valueDescription = "", description = "Paths where to find user class files") - public String classpath; + var classpath: String? = null - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-include-runtime", description = "Include Kotlin runtime in to resulting .jar") - public boolean includeRuntime; + var includeRuntime: Boolean = false - @GradleOption(DefaultValues.StringNullDefault.class) + @GradleOption(DefaultValues.StringNullDefault::class) @Argument( value = "-jdk-home", valueDescription = "", description = "Path to JDK home directory to include into classpath, if differs from default JAVA_HOME" ) - public String jdkHome; + var jdkHome: String? = null - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-no-jdk", description = "Don't include Java runtime into classpath") - public boolean noJdk; + var noJdk: Boolean = false - @GradleOption(DefaultValues.BooleanTrueDefault.class) + @GradleOption(DefaultValues.BooleanTrueDefault::class) @Argument(value = "-no-stdlib", description = "Don't include Kotlin runtime into classpath") - public boolean noStdlib; + var noStdlib: Boolean = false - @GradleOption(DefaultValues.BooleanTrueDefault.class) + @GradleOption(DefaultValues.BooleanTrueDefault::class) @Argument(value = "-no-reflect", description = "Don't include Kotlin reflection implementation into classpath") - public boolean noReflect; + var noReflect: Boolean = false @Argument(value = "-script", description = "Evaluate the script file") - public boolean script; + var script: Boolean = false @Argument( value = "-script-templates", valueDescription = "", description = "Script definition template classes" ) - public String[] scriptTemplates; + var scriptTemplates: Array? = null @Argument(value = "-module-name", description = "Module name") - public String moduleName; + var moduleName: String? = null - @GradleOption(DefaultValues.JvmTargetVersions.class) + @GradleOption(DefaultValues.JvmTargetVersions::class) @Argument( value = "-jvm-target", valueDescription = "", description = "Target version of the generated JVM bytecode (1.6 or 1.8), default is 1.6" ) - public String jvmTarget = JvmTarget.DEFAULT.getDescription(); + var jvmTarget: String? = JvmTarget.DEFAULT.description - @GradleOption(DefaultValues.BooleanFalseDefault.class) + @GradleOption(DefaultValues.BooleanFalseDefault::class) @Argument(value = "-java-parameters", description = "Generate metadata for Java 1.8 reflection on method parameters") - public boolean javaParameters; + var javaParameters: Boolean = false // Advanced options @Argument(value = "-Xmodule-path", valueDescription = "", description = "Paths where to find Java 9+ modules") - public String javaModulePath; + var javaModulePath: String? = null @Argument( value = "-Xadd-modules", @@ -93,89 +91,84 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments { description = "Root modules to resolve in addition to the initial modules,\n" + "or all modules on the module path if is ALL-MODULE-PATH" ) - public String[] additionalJavaModules; + var additionalJavaModules: Array? = null @Argument(value = "-Xno-call-assertions", description = "Don't generate not-null assertion after each invocation of method returning not-null") - public boolean noCallAssertions; + var noCallAssertions: Boolean = false @Argument(value = "-Xno-param-assertions", description = "Don't generate not-null assertions on parameters of methods accessible from Java") - public boolean noParamAssertions; + var noParamAssertions: Boolean = false @Argument(value = "-Xno-optimize", description = "Disable optimizations") - public boolean noOptimize; + var noOptimize: Boolean = false @Argument(value = "-Xreport-perf", description = "Report detailed performance statistics") - public boolean reportPerf; + var reportPerf: Boolean = false @Argument(value = "-Xbuild-file", deprecatedName = "-module", valueDescription = "", description = "Path to the .xml build file to compile") - public String buildFile; + var buildFile: String? = null @Argument(value = "-Xmultifile-parts-inherit", description = "Compile multifile classes as a hierarchy of parts and facade") - public boolean inheritMultifileParts; + var inheritMultifileParts: Boolean = false @Argument(value = "-Xskip-runtime-version-check", description = "Allow Kotlin runtime libraries of incompatible versions in the classpath") - public boolean skipRuntimeVersionCheck; + var skipRuntimeVersionCheck: Boolean = false @Argument( value = "-Xuse-old-class-files-reading", description = "Use old class files reading implementation " + "(may slow down the build and should be used in case of problems with the new implementation)" ) - public boolean useOldClassFilesReading; + var useOldClassFilesReading: Boolean = false @Argument( value = "-Xdump-declarations-to", valueDescription = "", description = "Path to JSON file to dump Java to Kotlin declaration mappings" ) - public String declarationsOutputPath; + var declarationsOutputPath: String? = null @Argument(value = "-Xsingle-module", description = "Combine modules for source files and binary dependencies into a single module") - public boolean singleModule; + var singleModule: Boolean = false @Argument(value = "-Xadd-compiler-builtins", description = "Add definitions of built-in declarations to the compilation classpath (useful with -no-stdlib)") - public boolean addCompilerBuiltIns; + var addCompilerBuiltIns: Boolean = false @Argument(value = "-Xload-builtins-from-dependencies", description = "Load definitions of built-in declarations from module dependencies, instead of from the compiler") - public boolean loadBuiltInsFromDependencies; + var loadBuiltInsFromDependencies: Boolean = false @Argument( value = "-Xscript-resolver-environment", valueDescription = "", description = "Script resolver environment in key-value pairs (the value could be quoted and escaped)" ) - public String[] scriptResolverEnvironment; + var scriptResolverEnvironment: Array? = null // Javac options @Argument(value = "-Xuse-javac", description = "Use javac for Java source and class files analysis") - public boolean useJavac; + var useJavac: Boolean = false @Argument( value = "-Xjavac-arguments", valueDescription = "", description = "Java compiler arguments") - public String[] javacArguments; + var javacArguments: Array? = null @Argument( value = "-Xjsr305-annotations", valueDescription = "{ignore|enable}", description = "Specify global behavior for JSR-305 nullability annotations: ignore, or treat as other supported nullability annotations" ) - public String jsr305GlobalReportLevel = Jsr305State.DEFAULT.getDescription(); + var jsr305GlobalReportLevel: String? = Jsr305State.DEFAULT.description // Paths to output directories for friend modules. - public String[] friendPaths; + var friendPaths: Array? = null - @Override - @NotNull - public Map, Object> configureAnalysisFlags() { - Map, Object> result = super.configureAnalysisFlags(); - for (Jsr305State state : Jsr305State.values()) { - if (state.getDescription().equals(jsr305GlobalReportLevel)) { - result.put(AnalysisFlag.getLoadJsr305Annotations(), state); - break; - } + override fun configureAnalysisFlags(): MutableMap, Any> { + val result = super.configureAnalysisFlags() + Jsr305State.values().firstOrNull { it.description == jsr305GlobalReportLevel }?.let { + result.put(AnalysisFlag.loadJsr305Annotations, it) } - return result; + return result } } diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArguments.kt index 3583f38078b..19d0c43e6b2 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2MetadataCompilerArguments.kt @@ -14,13 +14,15 @@ * limitations under the License. */ -package org.jetbrains.kotlin.cli.common.arguments; +package org.jetbrains.kotlin.cli.common.arguments -public class K2MetadataCompilerArguments extends CommonCompilerArguments { - public static final long serialVersionUID = 0L; +class K2MetadataCompilerArguments : CommonCompilerArguments() { + companion object { + @JvmStatic private val serialVersionUID = 0L + } @Argument(value = "-d", valueDescription = "", description = "Destination for generated .kotlin_metadata files") - public String destination; + var destination: String? = null @Argument( value = "-classpath", @@ -28,5 +30,5 @@ public class K2MetadataCompilerArguments extends CommonCompilerArguments { valueDescription = "", description = "Paths where to find library .kotlin_metadata files" ) - public String classpath; + var classpath: String? = null } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java index eb39806bd2c..503a57be778 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLICompiler.java @@ -81,9 +81,10 @@ public abstract class CLICompiler extends CLI ExitCode exitCode = OK; int repeatCount = 1; - if (arguments.repeat != null) { + String repeat = arguments.getRepeat(); + if (repeat != null) { try { - repeatCount = Integer.parseInt(arguments.repeat); + repeatCount = Integer.parseInt(repeat); } catch (NumberFormatException ignored) { } @@ -134,13 +135,13 @@ public abstract class CLICompiler extends CLI private void setupCommonArgumentsAndServices( @NotNull CompilerConfiguration configuration, @NotNull A arguments, @NotNull Services services ) { - if (arguments.noInline) { + if (arguments.getNoInline()) { configuration.put(CommonConfigurationKeys.DISABLE_INLINE, true); } - if (arguments.intellijPluginRoot != null) { - configuration.put(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot); + if (arguments.getIntellijPluginRoot()!= null) { + configuration.put(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.getIntellijPluginRoot()); } - if (arguments.reportOutputFiles) { + if (arguments.getReportOutputFiles()) { configuration.put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, true); } @SuppressWarnings("deprecation") @@ -153,8 +154,8 @@ public abstract class CLICompiler extends CLI } private void setupLanguageVersionSettings(@NotNull CompilerConfiguration configuration, @NotNull A arguments) { - LanguageVersion languageVersion = parseVersion(configuration, arguments.languageVersion, "language"); - LanguageVersion apiVersion = parseVersion(configuration, arguments.apiVersion, "API"); + LanguageVersion languageVersion = parseVersion(configuration, arguments.getLanguageVersion(), "language"); + LanguageVersion apiVersion = parseVersion(configuration, arguments.getApiVersion(), "API"); if (languageVersion == null) { // If only "-api-version" is specified, language version is assumed to be the latest stable @@ -189,7 +190,7 @@ public abstract class CLICompiler extends CLI } Map extraLanguageFeatures = new HashMap<>(0); - if (arguments.multiPlatform) { + if (arguments.getMultiPlatform()) { extraLanguageFeatures.put(LanguageFeature.MultiPlatformProjects, LanguageFeature.State.ENABLED); } @@ -209,8 +210,8 @@ public abstract class CLICompiler extends CLI @Nullable private static KotlinPaths computeKotlinPaths(@NotNull MessageCollector messageCollector, @NotNull CommonCompilerArguments arguments) { KotlinPaths paths; - if (arguments.kotlinHome != null) { - File kotlinHome = new File(arguments.kotlinHome); + if (arguments.getKotlinHome() != null) { + File kotlinHome = new File(arguments.getKotlinHome()); if (kotlinHome.isDirectory()) { paths = new KotlinPathsFromHomeDir(kotlinHome); } @@ -256,7 +257,7 @@ public abstract class CLICompiler extends CLI @NotNull CompilerConfiguration configuration, @NotNull CommonCompilerArguments arguments ) { - switch (arguments.coroutinesState) { + switch (arguments.getCoroutinesState()) { case CommonCompilerArguments.ERROR: return LanguageFeature.State.ENABLED_WITH_ERROR; case CommonCompilerArguments.ENABLE: @@ -264,7 +265,7 @@ public abstract class CLICompiler extends CLI case CommonCompilerArguments.WARN: return null; default: - String message = "Invalid value of -Xcoroutines (should be: enable, warn or error): " + arguments.coroutinesState; + String message = "Invalid value of -Xcoroutines (should be: enable, warn or error): " + arguments.getCoroutinesState(); configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(ERROR, message, null); return null; } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/Usage.java b/compiler/cli/src/org/jetbrains/kotlin/cli/common/Usage.java index 6a901736721..95f98d300e5 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/Usage.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/Usage.java @@ -32,14 +32,14 @@ public class Usage { public static String render(@NotNull CLITool tool, @NotNull A arguments) { StringBuilder sb = new StringBuilder(); appendln(sb, "Usage: " + tool.executableScriptFileName() + " "); - appendln(sb, "where " + (arguments.extraHelp ? "advanced" : "possible") + " options include:"); + appendln(sb, "where " + (arguments.getExtraHelp() ? "advanced" : "possible") + " options include:"); for (Class clazz = arguments.getClass(); clazz != null; clazz = clazz.getSuperclass()) { for (Field field : clazz.getDeclaredFields()) { - fieldUsage(sb, field, arguments.extraHelp); + fieldUsage(sb, field, arguments.getExtraHelp()); } } - if (arguments.extraHelp) { + if (arguments.getExtraHelp()) { appendln(sb, ""); appendln(sb, "Advanced options are non-standard and may be changed or removed without any notice."); } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java b/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java index 7c72e70bc6a..cd9519c909e 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/js/K2JSCompiler.java @@ -109,8 +109,8 @@ public class K2JSCompiler extends CLICompiler { ) { MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); - if (arguments.freeArgs.isEmpty()) { - if (arguments.version) { + if (arguments.getFreeArgs().isEmpty()) { + if (arguments.getVersion()) { return OK; } messageCollector.report(ERROR, "Specify at least one source file or directory", null); @@ -119,18 +119,18 @@ public class K2JSCompiler extends CLICompiler { configuration.put(JSConfigurationKeys.LIBRARIES, configureLibraries(arguments, paths, messageCollector)); - ContentRootsKt.addKotlinSourceRoots(configuration, arguments.freeArgs); + ContentRootsKt.addKotlinSourceRoots(configuration, arguments.getFreeArgs()); KotlinCoreEnvironment environmentForJS = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES); Project project = environmentForJS.getProject(); List sourcesFiles = environmentForJS.getSourceFiles(); - environmentForJS.getConfiguration().put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage); + environmentForJS.getConfiguration().put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.getAllowKotlinPackage()); if (!checkKotlinPackageUsage(environmentForJS, sourcesFiles)) return ExitCode.COMPILATION_ERROR; - if (arguments.outputFile == null) { + if (arguments.getOutputFile() == null) { messageCollector.report(ERROR, "Specify output file via -output", null); return ExitCode.COMPILATION_ERROR; } @@ -144,11 +144,11 @@ public class K2JSCompiler extends CLICompiler { return COMPILATION_ERROR; } - if (arguments.verbose) { + if (arguments.getVerbose()) { reportCompiledSourcesList(messageCollector, sourcesFiles); } - File outputFile = new File(arguments.outputFile); + File outputFile = new File(arguments.getOutputFile()); configuration.put(CommonConfigurationKeys.MODULE_NAME, FileUtil.getNameWithoutExtension(outputFile)); @@ -181,19 +181,19 @@ public class K2JSCompiler extends CLICompiler { JsAnalysisResult jsAnalysisResult = (JsAnalysisResult) analysisResult; File outputPrefixFile = null; - if (arguments.outputPrefix != null) { - outputPrefixFile = new File(arguments.outputPrefix); + if (arguments.getOutputPrefix() != null) { + outputPrefixFile = new File(arguments.getOutputPrefix()); if (!outputPrefixFile.exists()) { - messageCollector.report(ERROR, "Output prefix file '" + arguments.outputPrefix + "' not found", null); + messageCollector.report(ERROR, "Output prefix file '" + arguments.getOutputPrefix() + "' not found", null); return ExitCode.COMPILATION_ERROR; } } File outputPostfixFile = null; - if (arguments.outputPostfix != null) { - outputPostfixFile = new File(arguments.outputPostfix); + if (arguments.getOutputPrefix() != null) { + outputPostfixFile = new File(arguments.getOutputPrefix()); if (!outputPostfixFile.exists()) { - messageCollector.report(ERROR, "Output postfix file '" + arguments.outputPostfix + "' not found", null); + messageCollector.report(ERROR, "Output postfix file '" + arguments.getOutputPostfix() + "' not found", null); return ExitCode.COMPILATION_ERROR; } } @@ -202,7 +202,7 @@ public class K2JSCompiler extends CLICompiler { checkDuplicateSourceFileNames(messageCollector, sourcesFiles, config.getSourceMapRoots()); } - MainCallParameters mainCallParameters = createMainCallParameters(arguments.main); + MainCallParameters mainCallParameters = createMainCallParameters(arguments.getMain()); TranslationResult translationResult; K2JSTranslator translator = new K2JSTranslator(config); @@ -294,47 +294,47 @@ public class K2JSCompiler extends CLICompiler { ) { MessageCollector messageCollector = configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY); - if (arguments.target != null) { - assert arguments.target == "v5" : "Unsupported ECMA version: " + arguments.target; + if (arguments.getTarget() != null) { + assert arguments.getTarget() == "v5" : "Unsupported ECMA version: " + arguments.getTarget(); } configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.defaultVersion()); - if (arguments.sourceMap) { + if (arguments.getSourceMap()) { configuration.put(JSConfigurationKeys.SOURCE_MAP, true); - if (arguments.sourceMapPrefix != null) { - configuration.put(JSConfigurationKeys.SOURCE_MAP_PREFIX, arguments.sourceMapPrefix); + if (arguments.getSourceMapPrefix() != null) { + configuration.put(JSConfigurationKeys.SOURCE_MAP_PREFIX, arguments.getSourceMapPrefix()); } - String sourceMapSourceRoots = arguments.sourceMapSourceRoots != null ? - arguments.sourceMapSourceRoots : + String sourceMapSourceRoots = arguments.getSourceMapSourceRoots() != null ? + arguments.getSourceMapSourceRoots() : calculateSourceMapSourceRoot(messageCollector, arguments); List sourceMapSourceRootList = StringUtil.split(sourceMapSourceRoots, File.pathSeparator); configuration.put(JSConfigurationKeys.SOURCE_MAP_SOURCE_ROOTS, sourceMapSourceRootList); } else { - if (arguments.sourceMapPrefix != null) { + if (arguments.getSourceMapPrefix() != null) { messageCollector.report(WARNING, "source-map-prefix argument has no effect without source map", null); } - if (arguments.sourceMapSourceRoots != null) { + if (arguments.getSourceMapSourceRoots() != null) { messageCollector.report(WARNING, "source-map-source-root argument has no effect without source map", null); } } - if (arguments.metaInfo) { + if (arguments.getMetaInfo()) { configuration.put(JSConfigurationKeys.META_INFO, true); } - if (arguments.typedArrays) { + if (arguments.getTypedArrays()) { configuration.put(JSConfigurationKeys.TYPED_ARRAYS_ENABLED, true); } - configuration.put(JSConfigurationKeys.FRIEND_PATHS_DISABLED, arguments.friendModulesDisabled); + configuration.put(JSConfigurationKeys.FRIEND_PATHS_DISABLED, arguments.getFriendModulesDisabled()); - if (!arguments.friendModulesDisabled && arguments.friendModules != null) { - List friendPaths = ArraysKt.filterNot(arguments.friendModules.split(File.pathSeparator), String::isEmpty); + if (!arguments.getFriendModulesDisabled() && arguments.getFriendModules() != null) { + List friendPaths = ArraysKt.filterNot(arguments.getFriendModules().split(File.pathSeparator), String::isEmpty); configuration.put(JSConfigurationKeys.FRIEND_PATHS, friendPaths); } - String moduleKindName = arguments.moduleKind; + String moduleKindName = arguments.getModuleKind(); ModuleKind moduleKind = moduleKindName != null ? moduleKindMap.get(moduleKindName) : ModuleKind.PLAIN; if (moduleKind == null) { messageCollector.report( @@ -344,7 +344,7 @@ public class K2JSCompiler extends CLICompiler { } configuration.put(JSConfigurationKeys.MODULE_KIND, moduleKind); - String sourceMapEmbedContentString = arguments.sourceMapEmbedSources; + String sourceMapEmbedContentString = arguments.getSourceMapEmbedSources(); SourceMapSourceEmbedding sourceMapContentEmbedding = sourceMapEmbedContentString != null ? sourceMapContentEmbeddingMap.get(sourceMapEmbedContentString) : SourceMapSourceEmbedding.INLINING; @@ -356,7 +356,7 @@ public class K2JSCompiler extends CLICompiler { } configuration.put(JSConfigurationKeys.SOURCE_MAP_EMBED_SOURCES, sourceMapContentEmbedding); - if (!arguments.sourceMap && sourceMapEmbedContentString != null) { + if (!arguments.getSourceMap() && sourceMapEmbedContentString != null) { messageCollector.report(WARNING, "source-map-embed-sources argument has no effect without source map", null); } } @@ -368,7 +368,7 @@ public class K2JSCompiler extends CLICompiler { @NotNull MessageCollector messageCollector ) { List libraries = new SmartList<>(); - if (!arguments.noStdlib) { + if (!arguments.getNoStdlib()) { File stdlibJar = getLibraryFromHome( paths, KotlinPaths::getJsStdLibJarPath, PathUtil.JS_LIB_JAR_NAME, messageCollector, "'-no-stdlib'"); if (stdlibJar != null) { @@ -376,8 +376,8 @@ public class K2JSCompiler extends CLICompiler { } } - if (arguments.libraries != null) { - libraries.addAll(ArraysKt.filterNot(arguments.libraries.split(File.pathSeparator), String::isEmpty)); + if (arguments.getLibraries() != null) { + libraries.addAll(ArraysKt.filterNot(arguments.getLibraries().split(File.pathSeparator), String::isEmpty)); } return libraries; } @@ -392,7 +392,7 @@ public class K2JSCompiler extends CLICompiler { Map pathToRootIndexes = new HashMap<>(); try { - for (String path : arguments.freeArgs) { + for (String path : arguments.getFreeArgs()) { File file = new File(path).getCanonicalFile(); if (commonPath == null) { commonPath = file; 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 9c8743d0d00..770ef32faaa 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/K2JVMCompiler.kt @@ -122,7 +122,7 @@ class K2JVMCompiler : CLICompiler() { } if (arguments.jvmTarget != null) { - val jvmTarget = JvmTarget.fromString(arguments.jvmTarget) + val jvmTarget = JvmTarget.fromString(arguments.jvmTarget!!) if (jvmTarget != null) { configuration.put(JVMConfigurationKeys.JVM_TARGET, jvmTarget) } @@ -487,7 +487,7 @@ class K2JVMCompiler : CLICompiler() { val envParseRe = """(\w+)=(?:"([^"\\]*(\\.[^"\\]*)*)"|([^\s]*))""".toRegex() val unescapeRe = """\\(["\\])""".toRegex() if (arguments.scriptResolverEnvironment != null) { - for (envParam in arguments.scriptResolverEnvironment) { + for (envParam in arguments.scriptResolverEnvironment!!) { val match = envParseRe.matchEntire(envParam) if (match == null || match.groupValues.size < 4 || match.groupValues[1].isBlank()) { messageCollector.report(ERROR, "Unable to parse script-resolver-environment argument $envParam") diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/K2MetadataCompiler.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/K2MetadataCompiler.kt index d9bc8f06051..38838c261bd 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/K2MetadataCompiler.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/metadata/K2MetadataCompiler.kt @@ -57,7 +57,7 @@ class K2MetadataCompiler : CLICompiler() { configuration.addKotlinSourceRoot(arg) } if (arguments.classpath != null) { - configuration.addJvmClasspathRoots(arguments.classpath.split(File.pathSeparatorChar).map(::File)) + configuration.addJvmClasspathRoots(arguments.classpath!!.split(File.pathSeparatorChar).map(::File)) } configuration.put(CommonConfigurationKeys.MODULE_NAME, JvmAbi.DEFAULT_MODULE_NAME) diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt index dbdcef00f5a..1625dcb16b4 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt @@ -426,7 +426,7 @@ class CompileServiceImpl( val bytesOut = ByteArrayOutputStream() val printStream = PrintStream(bytesOut) val mc = PrintingMessageCollector(printStream, MessageRenderer.PLAIN_FULL_PATHS, false) - val parsedModule = ModuleXmlParser.parseModuleScript(k2jvmArgs.buildFile, mc) + val parsedModule = ModuleXmlParser.parseModuleScript(k2jvmArgs.buildFile!!, mc) if (mc.hasErrors()) { daemonMessageReporter.report(ReportSeverity.ERROR, bytesOut.toString("UTF8")) } diff --git a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt index 7865041e551..d6ac3752148 100644 --- a/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt +++ b/compiler/incremental-compilation-impl/src/org/jetbrains/kotlin/incremental/IncrementalJvmCompilerRunner.kt @@ -104,7 +104,7 @@ class IncrementalJvmCompilerRunner( messageCollector: MessageCollector, getChangedFiles: (IncrementalCachesManager)->ChangedFiles ): ExitCode { - val targetId = TargetId(name = args.moduleName, type = "java-production") + val targetId = TargetId(name = args.moduleName!!, type = "java-production") var caches = IncrementalCachesManager(targetId, cacheDirectory, File(args.destination), reporter) fun onError(e: Exception): ExitCode { @@ -411,7 +411,7 @@ class IncrementalJvmCompilerRunner( val compiler = K2JVMCompiler() val outputDir = args.destinationAsFile val classpath = args.classpathAsList - val moduleFile = makeModuleFile(args.moduleName, + val moduleFile = makeModuleFile(args.moduleName!!, isTest = false, outputDir = outputDir, sourcesToCompile = sourcesToCompile, @@ -472,5 +472,5 @@ var K2JVMCompilerArguments.destinationAsFile: File set(value) { destination = value.path } var K2JVMCompilerArguments.classpathAsList: List - get() = classpath.split(File.pathSeparator).map(::File) + get() = classpath!!.split(File.pathSeparator).map(::File) set(value) { classpath = value.joinToString(separator = File.pathSeparator, transform = { it.path }) } diff --git a/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt b/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt index 4f501b55bd4..785d264022c 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/cli/FriendPathsTest.kt @@ -56,7 +56,7 @@ class FriendPathsTest : TestCaseWithTmpdir() { return K2JVMCompiler().exec(ThrowingMessageCollector(), Services.EMPTY, K2JVMCompilerArguments().apply { destination = tmpdir.path classpath = libraryPath - freeArgs = listOf(File(getTestDataDirectory(), "usage.kt").path) + freeArgs = arrayListOf(File(getTestDataDirectory(), "usage.kt").path) friendPaths = arrayOf(libraryPath) }) diff --git a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt index ae75fa519bd..fc597ec0ea6 100644 --- a/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt +++ b/idea/idea-jps-common/src/org/jetbrains/kotlin/config/facetSerialization.kt @@ -137,7 +137,7 @@ fun deserializeFacetSettings(element: Element): KotlinFacetSettings { } fun CommonCompilerArguments.convertPathsToSystemIndependent() { - pluginClasspaths?.forEachIndexed { index, s -> pluginClasspaths[index] = PathUtil.toSystemIndependentName(s) } + pluginClasspaths?.forEachIndexed { index, s -> pluginClasspaths!![index] = PathUtil.toSystemIndependentName(s) } when (this) { is K2JVMCompilerArguments -> { @@ -145,7 +145,7 @@ fun CommonCompilerArguments.convertPathsToSystemIndependent() { classpath = PathUtil.toSystemIndependentName(classpath) jdkHome = PathUtil.toSystemIndependentName(jdkHome) kotlinHome = PathUtil.toSystemIndependentName(kotlinHome) - friendPaths?.forEachIndexed { index, s -> friendPaths[index] = PathUtil.toSystemIndependentName(s) } + friendPaths?.forEachIndexed { index, s -> friendPaths!![index] = PathUtil.toSystemIndependentName(s) } declarationsOutputPath = PathUtil.toSystemIndependentName(declarationsOutputPath) } diff --git a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt index 88f1b817c68..91bad0dad19 100644 --- a/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt +++ b/idea/idea-maven/test/org/jetbrains/kotlin/idea/maven/KotlinMavenImporterTest.kt @@ -1348,7 +1348,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() { "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.transaction.annotation.Transactional", "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.scheduling.annotation.Async", "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.cache.annotation.Cacheable"), - compilerArguments!!.pluginOptions.toList() + compilerArguments!!.pluginOptions!!.toList() ) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java index d3a524aae18..e10b7fa3ae3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java +++ b/idea/src/org/jetbrains/kotlin/idea/compiler/configuration/KotlinCompilerConfigurableTab.java @@ -428,9 +428,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co @Override public boolean isModified() { - return ComparingUtils.isModified(reportWarningsCheckBox, !commonCompilerArguments.suppressWarnings) || - !getSelectedLanguageVersion().equals(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion)) || - !getSelectedAPIVersion().equals(getApiVersionOrDefault(commonCompilerArguments.apiVersion)) || + return ComparingUtils.isModified(reportWarningsCheckBox, !commonCompilerArguments.getSuppressWarnings()) || + !getSelectedLanguageVersion().equals(getLanguageVersionOrDefault(commonCompilerArguments.getLanguageVersion())) || + !getSelectedAPIVersion().equals(getApiVersionOrDefault(commonCompilerArguments.getApiVersion())) || !coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments)) || ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.additionalArguments) || ComparingUtils.isModified(scriptTemplatesField, compilerSettings.scriptTemplates) || @@ -442,14 +442,14 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co (ComparingUtils.isModified(enablePreciseIncrementalCheckBox, compilerWorkspaceSettings.getPreciseIncrementalEnabled()) || ComparingUtils.isModified(keepAliveCheckBox, compilerWorkspaceSettings.getEnableDaemon()))) || - ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) || - ComparingUtils.isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) || - ComparingUtils.isModified(outputPostfixFile, k2jsCompilerArguments.outputPostfix) || - !getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind)) || - ComparingUtils.isModified(sourceMapPrefix, k2jsCompilerArguments.sourceMapPrefix) || + ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.getSourceMap()) || + ComparingUtils.isModified(outputPrefixFile, k2jsCompilerArguments.getOutputPrefix()) || + ComparingUtils.isModified(outputPostfixFile, k2jsCompilerArguments.getOutputPostfix()) || + !getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())) || + ComparingUtils.isModified(sourceMapPrefix, k2jsCompilerArguments.getSourceMapPrefix()) || !getSelectedSourceMapSourceEmbedding().equals( - getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.sourceMapEmbedSources)) || - !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget)); + getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())) || + !getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); } @NotNull @@ -486,8 +486,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co ) throws ConfigurationException { if (isProjectSettings) { boolean shouldInvalidateCaches = - commonCompilerArguments.languageVersion != getSelectedLanguageVersion().getVersionString() || - commonCompilerArguments.apiVersion != getSelectedAPIVersion().getVersionString() || + commonCompilerArguments.getLanguageVersion() != getSelectedLanguageVersion().getVersionString() || + commonCompilerArguments.getApiVersion() != getSelectedAPIVersion().getVersionString() || !coroutineSupportComboBox.getSelectedItem().equals(CoroutineSupport.byCompilerArguments(commonCompilerArguments)); if (shouldInvalidateCaches) { @@ -503,20 +503,20 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co } } - commonCompilerArguments.suppressWarnings = !reportWarningsCheckBox.isSelected(); - commonCompilerArguments.languageVersion = getSelectedLanguageVersion().getVersionString(); - commonCompilerArguments.apiVersion = getSelectedAPIVersion().getVersionString(); + commonCompilerArguments.setSuppressWarnings(!reportWarningsCheckBox.isSelected()); + commonCompilerArguments.setLanguageVersion(getSelectedLanguageVersion().getVersionString()); + commonCompilerArguments.setApiVersion(getSelectedAPIVersion().getVersionString()); switch ((LanguageFeature.State) coroutineSupportComboBox.getSelectedItem()) { case ENABLED: - commonCompilerArguments.coroutinesState = CommonCompilerArguments.ENABLE; + commonCompilerArguments.setCoroutinesState(CommonCompilerArguments.ENABLE); break; case ENABLED_WITH_WARNING: - commonCompilerArguments.coroutinesState = CommonCompilerArguments.WARN; + commonCompilerArguments.setCoroutinesState(CommonCompilerArguments.WARN); break; case ENABLED_WITH_ERROR: case DISABLED: - commonCompilerArguments.coroutinesState = CommonCompilerArguments.ERROR; + commonCompilerArguments.setCoroutinesState(CommonCompilerArguments.ERROR); break; } @@ -536,15 +536,15 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co } } - k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected(); - k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true); - k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true); - k2jsCompilerArguments.moduleKind = getSelectedModuleKind(); + k2jsCompilerArguments.setSourceMap(generateSourceMapsCheckBox.isSelected()); + k2jsCompilerArguments.setOutputPrefix(StringUtil.nullize(outputPrefixFile.getText(), true)); + k2jsCompilerArguments.setOutputPostfix(StringUtil.nullize(outputPostfixFile.getText(), true)); + k2jsCompilerArguments.setModuleKind(getSelectedModuleKind()); - k2jsCompilerArguments.sourceMapPrefix = sourceMapPrefix.getText(); - k2jsCompilerArguments.sourceMapEmbedSources = getSelectedSourceMapSourceEmbedding(); + k2jsCompilerArguments.setSourceMapPrefix(sourceMapPrefix.getText()); + k2jsCompilerArguments.setSourceMapEmbedSources(getSelectedSourceMapSourceEmbedding()); - k2jvmCompilerArguments.jvmTarget = getSelectedJvmVersion(); + k2jvmCompilerArguments.setJvmTarget(getSelectedJvmVersion()); if (isProjectSettings) { KotlinCommonCompilerArgumentsHolder.Companion.getInstance(project).setSettings(commonCompilerArguments); @@ -563,9 +563,9 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co @Override public void reset() { - reportWarningsCheckBox.setSelected(!commonCompilerArguments.suppressWarnings); - languageVersionComboBox.setSelectedItem(getLanguageVersionOrDefault(commonCompilerArguments.languageVersion)); - apiVersionComboBox.setSelectedItem(getApiVersionOrDefault(commonCompilerArguments.apiVersion)); + reportWarningsCheckBox.setSelected(!commonCompilerArguments.getSuppressWarnings()); + languageVersionComboBox.setSelectedItem(getLanguageVersionOrDefault(commonCompilerArguments.getLanguageVersion())); + apiVersionComboBox.setSelectedItem(getApiVersionOrDefault(commonCompilerArguments.getApiVersion())); restrictAPIVersions(getSelectedLanguageVersion()); coroutineSupportComboBox.setSelectedItem(CoroutineSupport.byCompilerArguments(commonCompilerArguments)); additionalArgsOptionsField.setText(compilerSettings.additionalArguments); @@ -579,16 +579,16 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co keepAliveCheckBox.setSelected(compilerWorkspaceSettings.getEnableDaemon()); } - generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourceMap); - outputPrefixFile.setText(k2jsCompilerArguments.outputPrefix); - outputPostfixFile.setText(k2jsCompilerArguments.outputPostfix); + generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.getSourceMap()); + outputPrefixFile.setText(k2jsCompilerArguments.getOutputPrefix()); + outputPostfixFile.setText(k2jsCompilerArguments.getOutputPostfix()); - moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind)); - sourceMapPrefix.setText(k2jsCompilerArguments.sourceMapPrefix); - sourceMapPrefix.setEnabled(k2jsCompilerArguments.sourceMap); - sourceMapEmbedSources.setSelectedItem(getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.sourceMapEmbedSources)); + moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.getModuleKind())); + sourceMapPrefix.setText(k2jsCompilerArguments.getSourceMapPrefix()); + sourceMapPrefix.setEnabled(k2jsCompilerArguments.getSourceMap()); + sourceMapEmbedSources.setSelectedItem(getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.getSourceMapEmbedSources())); - jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget)); + jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.getJvmTarget())); } @Override diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/EnableUnsupportedFeatureFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/EnableUnsupportedFeatureFix.kt index 54d10353080..f92f4f6b7fd 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/EnableUnsupportedFeatureFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/EnableUnsupportedFeatureFix.kt @@ -155,7 +155,7 @@ sealed class EnableUnsupportedFeatureFix( val targetVersion = feature.sinceVersion!! KotlinCommonCompilerArgumentsHolder.getInstance(project).update { - val parsedApiVersion = ApiVersion.parse(apiVersion) + val parsedApiVersion = ApiVersion.parse(apiVersion!!) if (parsedApiVersion != null && feature.sinceApiVersion > parsedApiVersion) { if (!checkUpdateRuntime(project, feature.sinceApiVersion)) return@update apiVersion = feature.sinceApiVersion.versionString diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt index 7a34d79b412..7692c88eeb8 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/gradle/GradleFacetImportTest.kt @@ -866,7 +866,7 @@ compileTestKotlin { "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.transaction.annotation.Transactional", "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.scheduling.annotation.Async", "plugin:org.jetbrains.kotlin.allopen:annotation=org.springframework.cache.annotation.Cacheable"), - compilerArguments!!.pluginOptions.toList() + compilerArguments!!.pluginOptions!!.toList() ) } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java index 83b03be158b..d198f277383 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java +++ b/idea/tests/org/jetbrains/kotlin/idea/configuration/ConfigureKotlinTest.java @@ -169,10 +169,10 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { assertEquals("1.1", settings.getLanguageLevel().getDescription()); assertEquals("1.0", settings.getApiLevel().getDescription()); assertEquals(TargetPlatformKind.Jvm.Companion.get(JvmTarget.JVM_1_8), settings.getTargetPlatformKind()); - assertEquals("1.1", arguments.languageVersion); - assertEquals("1.0", arguments.apiVersion); + assertEquals("1.1", arguments.getLanguageVersion()); + assertEquals("1.0", arguments.getApiVersion()); assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, CoroutineSupport.byCompilerArguments(arguments)); - assertEquals("1.7", arguments.jvmTarget); + assertEquals("1.7", arguments.getJvmTarget()); assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().additionalArguments); } @@ -184,10 +184,10 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { assertEquals("1.1", settings.getLanguageLevel().getDescription()); assertEquals("1.0", settings.getApiLevel().getDescription()); assertEquals(TargetPlatformKind.JavaScript.INSTANCE, settings.getTargetPlatformKind()); - assertEquals("1.1", arguments.languageVersion); - assertEquals("1.0", arguments.apiVersion); + assertEquals("1.1", arguments.getLanguageVersion()); + assertEquals("1.0", arguments.getApiVersion()); assertEquals(LanguageFeature.State.ENABLED_WITH_WARNING, CoroutineSupport.byCompilerArguments(arguments)); - assertEquals("amd", arguments.moduleKind); + assertEquals("amd", arguments.getModuleKind()); assertEquals("-version -meta-info", settings.getCompilerSettings().additionalArguments); } @@ -199,10 +199,10 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { assertEquals("1.1", settings.getLanguageLevel().getDescription()); assertEquals("1.0", settings.getApiLevel().getDescription()); assertEquals(TargetPlatformKind.Jvm.Companion.get(JvmTarget.JVM_1_8), settings.getTargetPlatformKind()); - assertEquals("1.1", arguments.languageVersion); - assertEquals("1.0", arguments.apiVersion); + assertEquals("1.1", arguments.getLanguageVersion()); + assertEquals("1.0", arguments.getApiVersion()); assertEquals(LanguageFeature.State.ENABLED, CoroutineSupport.byCompilerArguments(arguments)); - assertEquals("1.7", arguments.jvmTarget); + assertEquals("1.7", arguments.getJvmTarget()); assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().additionalArguments); } @@ -214,10 +214,10 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { assertEquals("1.1", settings.getLanguageLevel().getDescription()); assertEquals("1.0", settings.getApiLevel().getDescription()); assertEquals(TargetPlatformKind.JavaScript.INSTANCE, settings.getTargetPlatformKind()); - assertEquals("1.1", arguments.languageVersion); - assertEquals("1.0", arguments.apiVersion); + assertEquals("1.1", arguments.getLanguageVersion()); + assertEquals("1.0", arguments.getApiVersion()); assertEquals(LanguageFeature.State.ENABLED_WITH_ERROR, CoroutineSupport.byCompilerArguments(arguments)); - assertEquals("amd", arguments.moduleKind); + assertEquals("amd", arguments.getModuleKind()); assertEquals("-version -meta-info", settings.getCompilerSettings().additionalArguments); } @@ -229,10 +229,10 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { assertEquals("1.1", settings.getLanguageLevel().getDescription()); assertEquals("1.0", settings.getApiLevel().getDescription()); assertEquals(TargetPlatformKind.Jvm.Companion.get(JvmTarget.JVM_1_8), settings.getTargetPlatformKind()); - assertEquals("1.1", arguments.languageVersion); - assertEquals("1.0", arguments.apiVersion); + assertEquals("1.1", arguments.getLanguageVersion()); + assertEquals("1.0", arguments.getApiVersion()); assertEquals(LanguageFeature.State.ENABLED, CoroutineSupport.byCompilerArguments(arguments)); - assertEquals("1.7", arguments.jvmTarget); + assertEquals("1.7", arguments.getJvmTarget()); assertEquals("-version -Xallow-kotlin-package -Xskip-metadata-version-check", settings.getCompilerSettings().additionalArguments); } @@ -249,7 +249,8 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest { modelsProvider ); assertEquals(platformKind, facet.getConfiguration().getSettings().getTargetPlatformKind()); - assertEquals(jvmTarget.getDescription(), ((K2JVMCompilerArguments) facet.getConfiguration().getSettings().getCompilerArguments()).jvmTarget); + assertEquals(jvmTarget.getDescription(), + ((K2JVMCompilerArguments) facet.getConfiguration().getSettings().getCompilerArguments()).getJvmTarget()); } finally { modelsProvider.dispose();