Restore -Xjsr305-annotations flag as a deprecated
This commit is contained in:
+2
-1
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.common.arguments
|
package org.jetbrains.kotlin.cli.common.arguments
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.config.AnalysisFlag
|
import org.jetbrains.kotlin.config.AnalysisFlag
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -105,7 +106,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
)
|
)
|
||||||
var coroutinesState: String? by FreezableVar(WARN)
|
var coroutinesState: String? by FreezableVar(WARN)
|
||||||
|
|
||||||
open fun configureAnalysisFlags(): MutableMap<AnalysisFlag<*>, Any> {
|
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||||
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
put(AnalysisFlag.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||||
put(AnalysisFlag.multiPlatformDoNotCheckImpl, noCheckImpl)
|
put(AnalysisFlag.multiPlatformDoNotCheckImpl, noCheckImpl)
|
||||||
|
|||||||
+18
-4
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.common.arguments
|
package org.jetbrains.kotlin.cli.common.arguments
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.config.AnalysisFlag
|
import org.jetbrains.kotlin.config.AnalysisFlag
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
import org.jetbrains.kotlin.utils.Jsr305State
|
import org.jetbrains.kotlin.utils.Jsr305State
|
||||||
@@ -162,6 +164,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
|
|
||||||
@Argument(
|
@Argument(
|
||||||
value = "-Xjsr305",
|
value = "-Xjsr305",
|
||||||
|
deprecatedName = "-Xjsr305-annotations",
|
||||||
valueDescription = "{ignore|strict|warn}",
|
valueDescription = "{ignore|strict|warn}",
|
||||||
description = "Specify global behavior for JSR-305 nullability annotations: ignore, treat as other supported nullability annotations, or report a warning"
|
description = "Specify global behavior for JSR-305 nullability annotations: ignore, treat as other supported nullability annotations, or report a warning"
|
||||||
)
|
)
|
||||||
@@ -176,11 +179,22 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
// Paths to output directories for friend modules.
|
// Paths to output directories for friend modules.
|
||||||
var friendPaths: Array<String>? by FreezableVar(null)
|
var friendPaths: Array<String>? by FreezableVar(null)
|
||||||
|
|
||||||
override fun configureAnalysisFlags(): MutableMap<AnalysisFlag<*>, Any> {
|
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||||
val result = super.configureAnalysisFlags()
|
val result = super.configureAnalysisFlags(collector)
|
||||||
Jsr305State.findByDescription(jsr305)?.let {
|
|
||||||
result.put(AnalysisFlag.jsr305, it)
|
if (jsr305 == "enable") {
|
||||||
|
collector.report(
|
||||||
|
CompilerMessageSeverity.STRONG_WARNING,
|
||||||
|
"Option 'enable' for -Xjsr305 flag is deprecated. Please use 'strict' instead"
|
||||||
|
)
|
||||||
|
result.put(AnalysisFlag.jsr305, Jsr305State.STRICT)
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Jsr305State.findByDescription(jsr305)?.let {
|
||||||
|
result.put(AnalysisFlag.jsr305, it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
|
|||||||
CommonConfigurationKeysKt.setLanguageVersionSettings(configuration, new LanguageVersionSettingsImpl(
|
CommonConfigurationKeysKt.setLanguageVersionSettings(configuration, new LanguageVersionSettingsImpl(
|
||||||
languageVersion,
|
languageVersion,
|
||||||
ApiVersion.createByLanguageVersion(apiVersion),
|
ApiVersion.createByLanguageVersion(apiVersion),
|
||||||
arguments.configureAnalysisFlags(),
|
arguments.configureAnalysisFlags(configuration.getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)),
|
||||||
extraLanguageFeatures
|
extraLanguageFeatures
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-Xjsr305-annotations=enable
|
||||||
|
$TESTDATA_DIR$/jsr305Usage.kt
|
||||||
|
$TESTDATA_DIR$/jsr305
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
warning: argument -Xjsr305-annotations is deprecated. Please use -Xjsr305 instead
|
||||||
|
warning: option 'enable' for -Xjsr305 flag is deprecated. Please use 'strict' instead
|
||||||
|
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: error: null can not be a value of a non-null type String
|
||||||
|
a.foo(null)
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-Xjsr305-annotations=ignore
|
||||||
|
$TESTDATA_DIR$/jsr305Usage.kt
|
||||||
|
$TESTDATA_DIR$/jsr305
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
warning: argument -Xjsr305-annotations is deprecated. Please use -Xjsr305 instead
|
||||||
|
OK
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-Xjsr305-annotations=warn
|
||||||
|
$TESTDATA_DIR$/jsr305Usage.kt
|
||||||
|
$TESTDATA_DIR$/jsr305
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
warning: argument -Xjsr305-annotations is deprecated. Please use -Xjsr305 instead
|
||||||
|
compiler/testData/cli/jvm/jsr305Usage.kt:2:11: warning: expected type does not accept nulls in Java, but the value may be null in Kotlin
|
||||||
|
a.foo(null)
|
||||||
|
^
|
||||||
|
OK
|
||||||
@@ -218,6 +218,24 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305DeprecatedEnable.args")
|
||||||
|
public void testJsr305DeprecatedEnable() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DeprecatedEnable.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305DeprecatedIgnore.args")
|
||||||
|
public void testJsr305DeprecatedIgnore() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DeprecatedIgnore.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("jsr305DeprecatedWarn.args")
|
||||||
|
public void testJsr305DeprecatedWarn() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305DeprecatedWarn.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("jsr305Ignore.args")
|
@TestMetadata("jsr305Ignore.args")
|
||||||
public void testJsr305Ignore() throws Exception {
|
public void testJsr305Ignore() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305Ignore.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/jsr305Ignore.args");
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import com.intellij.openapi.roots.ProjectFileIndex
|
|||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.Argument
|
import org.jetbrains.kotlin.cli.common.arguments.Argument
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.config.*
|
import org.jetbrains.kotlin.config.*
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JvmCompilerArgumentsHolder
|
import org.jetbrains.kotlin.idea.compiler.configuration.Kotlin2JvmCompilerArgumentsHolder
|
||||||
@@ -90,7 +91,7 @@ fun Project.getLanguageVersionSettings(contextModule: Module? = null,
|
|||||||
null
|
null
|
||||||
)
|
)
|
||||||
return LanguageVersionSettingsImpl(languageVersion, apiVersion,
|
return LanguageVersionSettingsImpl(languageVersion, apiVersion,
|
||||||
arguments.configureAnalysisFlags() + extraAnalysisFlags,
|
arguments.configureAnalysisFlags(MessageCollector.NONE) + extraAnalysisFlags,
|
||||||
extraLanguageFeatures)
|
extraLanguageFeatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,7 +114,7 @@ val Module.languageVersionSettings: LanguageVersionSettings
|
|||||||
return LanguageVersionSettingsImpl(
|
return LanguageVersionSettingsImpl(
|
||||||
languageVersion,
|
languageVersion,
|
||||||
ApiVersion.createByLanguageVersion(apiVersion),
|
ApiVersion.createByLanguageVersion(apiVersion),
|
||||||
facetSettings.mergedCompilerArguments?.configureAnalysisFlags().orEmpty(),
|
facetSettings.mergedCompilerArguments?.configureAnalysisFlags(MessageCollector.NONE).orEmpty(),
|
||||||
extraLanguageFeatures
|
extraLanguageFeatures
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user