Support compiler flag -Xcodeanalysis-annotations
This commit is contained in:
committed by
Victor Petukhov
parent
c734bac676
commit
f3a490ee16
+23
-2
@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.utils.ReportLevel
|
||||
|
||||
class JavaTypeEnhancementStateParser(private val collector: MessageCollector) {
|
||||
fun parse(
|
||||
jsr305Args: Array<String>?, supportCompatqualCheckerFrameworkAnnotations: String?
|
||||
jsr305Args: Array<String>?,
|
||||
supportCompatqualCheckerFrameworkAnnotations: String?,
|
||||
codeAnalysisState: String?
|
||||
): JavaTypeEnhancementState {
|
||||
val jsr305State = parseJsr305State(jsr305Args)
|
||||
|
||||
@@ -40,15 +42,34 @@ class JavaTypeEnhancementStateParser(private val collector: MessageCollector) {
|
||||
}
|
||||
}
|
||||
|
||||
val codeAnalysisReportLevel = parseCodeAnalysisReportLevel(codeAnalysisState)
|
||||
|
||||
val state = JavaTypeEnhancementState(
|
||||
jsr305State.global ?: ReportLevel.WARN, jsr305State.migration, jsr305State.usedDefined,
|
||||
enableCompatqualCheckerFrameworkAnnotations =
|
||||
enableCompatqualCheckerFrameworkAnnotations
|
||||
?: JavaTypeEnhancementState.COMPATQUAL_CHECKER_FRAMEWORK_ANNOTATIONS_SUPPORT_DEFAULT_VALUE
|
||||
?: JavaTypeEnhancementState.COMPATQUAL_CHECKER_FRAMEWORK_ANNOTATIONS_SUPPORT_DEFAULT_VALUE,
|
||||
jspecifyReportLevel = codeAnalysisReportLevel
|
||||
)
|
||||
return if (state == JavaTypeEnhancementState.DISABLED_JSR_305) JavaTypeEnhancementState.DISABLED_JSR_305 else state
|
||||
}
|
||||
|
||||
|
||||
private fun parseCodeAnalysisReportLevel(codeAnalysisState: String?): ReportLevel {
|
||||
if (codeAnalysisState == null) return JavaTypeEnhancementState.DEFAULT_REPORT_LEVEL_FOR_CODE_ANALYSIS
|
||||
val reportLevel = ReportLevel.findByDescription(codeAnalysisState)
|
||||
|
||||
if (reportLevel == null) {
|
||||
collector.report(
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"Unrecognized -Xcodeanalysis-annotations option: $codeAnalysisState. Possible values are 'disable'/'warn'/'strict'"
|
||||
)
|
||||
return JavaTypeEnhancementState.DEFAULT_REPORT_LEVEL_FOR_CODE_ANALYSIS
|
||||
}
|
||||
|
||||
return reportLevel
|
||||
}
|
||||
|
||||
private data class Jsr305State(
|
||||
val global: ReportLevel?,
|
||||
val migration: ReportLevel?,
|
||||
|
||||
+10
-1
@@ -263,6 +263,14 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var supportCompatqualCheckerFrameworkAnnotations: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xjspecify-annotations",
|
||||
valueDescription = "ignore|strict|warn",
|
||||
description = "Specify behavior for jspecify annotations.\n" +
|
||||
"Default value is 'warn'"
|
||||
)
|
||||
var jspecifyAnnotations: 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"
|
||||
@@ -397,7 +405,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
|
||||
result[JvmAnalysisFlags.javaTypeEnhancementState] = JavaTypeEnhancementStateParser(collector).parse(
|
||||
jsr305,
|
||||
supportCompatqualCheckerFrameworkAnnotations
|
||||
supportCompatqualCheckerFrameworkAnnotations,
|
||||
jspecifyAnnotations
|
||||
)
|
||||
result[AnalysisFlags.ignoreDataFlowInAssert] = JVMAssertionsMode.fromString(assertionsMode) != JVMAssertionsMode.LEGACY
|
||||
JvmDefaultMode.fromStringOrNull(jvmDefault)?.let {
|
||||
|
||||
Reference in New Issue
Block a user