Add -Xsupport-compatqual-checker-framework-annotations flag
It's implemented through Jsr305State while it's not related to jsr-305 becasue currently it's the most convenient way to introduce the flag. Probably, it's worth renaming Jsr305State to something more abstract like NullabilityAnnotationsConfiguration #KT-21982 Fixed
This commit is contained in:
+20
-2
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.utils.Jsr305State
|
||||
import org.jetbrains.kotlin.utils.ReportLevel
|
||||
|
||||
class Jsr305Parser(private val collector: MessageCollector) {
|
||||
fun parse(value: Array<String>?): Jsr305State {
|
||||
fun parse(value: Array<String>?, supportCompatqualCheckerFrameworkAnnotations: String?): Jsr305State {
|
||||
var global: ReportLevel? = null
|
||||
var migration: ReportLevel? = null
|
||||
val userDefined = mutableMapOf<String, ReportLevel>()
|
||||
@@ -70,7 +70,25 @@ class Jsr305Parser(private val collector: MessageCollector) {
|
||||
}
|
||||
}
|
||||
|
||||
val state = Jsr305State(global ?: ReportLevel.WARN, migration, userDefined)
|
||||
val enableCompatqualCheckerFrameworkAnnotations = when (supportCompatqualCheckerFrameworkAnnotations) {
|
||||
"enable" -> true
|
||||
"disable" -> false
|
||||
null -> null
|
||||
else -> {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"Unrecognized -Xsupport-compatqual-checker-framework-annotations option: $supportCompatqualCheckerFrameworkAnnotations. Possible values are 'enable'/'disable'"
|
||||
)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
val state = Jsr305State(
|
||||
global ?: ReportLevel.WARN, migration, userDefined,
|
||||
enableCompatqualCheckerFrameworkAnnotations =
|
||||
enableCompatqualCheckerFrameworkAnnotations
|
||||
?: Jsr305State.COMPATQUAL_CHECKER_FRAMEWORK_ANNOTATIONS_SUPPORT_DEFAULT_VALUE
|
||||
)
|
||||
return if (state == Jsr305State.DISABLED) Jsr305State.DISABLED else state
|
||||
}
|
||||
|
||||
|
||||
+15
-4
@@ -16,13 +16,10 @@
|
||||
|
||||
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.JVMConstructorCallNormalizationMode
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.utils.Jsr305State
|
||||
import org.jetbrains.kotlin.utils.ReportLevel
|
||||
|
||||
class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
companion object {
|
||||
@@ -191,6 +188,17 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var jsr305: Array<String>? by FreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xsupport-compatqual-checker-framework-annotations",
|
||||
valueDescription = "enable|disable",
|
||||
description =
|
||||
"""
|
||||
Specify behavior for Checker Framework compatqual annotations (NullableDecl/NonNullDecl).
|
||||
Default value is 'enable'
|
||||
"""
|
||||
)
|
||||
var supportCompatqualCheckerFrameworkAnnotations: String? by FreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xno-exception-on-explicit-equals-for-boxed-null",
|
||||
description = "Do not throw NPE on explicit 'equals' call for null receiver of platform boxed primitive type"
|
||||
@@ -202,7 +210,10 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
|
||||
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
val result = super.configureAnalysisFlags(collector)
|
||||
result[AnalysisFlag.jsr305] = Jsr305Parser(collector).parse(jsr305)
|
||||
result[AnalysisFlag.jsr305] = Jsr305Parser(collector).parse(
|
||||
jsr305,
|
||||
supportCompatqualCheckerFrameworkAnnotations
|
||||
)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user