J2K: CommonToolArguments and inheritors

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