Extract building JSR-305 settings to separate function
This commit is contained in:
+3
-2
@@ -46,8 +46,9 @@ open class JvmForeignAnnotationsConfigurator(testServices: TestServices) : Envir
|
|||||||
get() = listOf(ForeignAnnotationsDirectives)
|
get() = listOf(ForeignAnnotationsDirectives)
|
||||||
|
|
||||||
override fun provideAdditionalAnalysisFlags(directives: RegisteredDirectives): Map<AnalysisFlag<*>, Any?> {
|
override fun provideAdditionalAnalysisFlags(directives: RegisteredDirectives): Map<AnalysisFlag<*>, Any?> {
|
||||||
val globalState = directives.singleOrZeroValue(JSR305_GLOBAL_REPORT) ?: ReportLevel.WARN
|
val defaultJsr305Settings = Jsr305Settings.DEFAULT
|
||||||
val migrationState = directives.singleOrZeroValue(JSR305_MIGRATION_REPORT)
|
val globalState = directives.singleOrZeroValue(JSR305_GLOBAL_REPORT) ?: defaultJsr305Settings.globalLevel
|
||||||
|
val migrationState = directives.singleOrZeroValue(JSR305_MIGRATION_REPORT) ?: defaultJsr305Settings.migrationLevel
|
||||||
val userAnnotationsState = directives[JSR305_SPECIAL_REPORT].mapNotNull {
|
val userAnnotationsState = directives[JSR305_SPECIAL_REPORT].mapNotNull {
|
||||||
val (name, stateDescription) = it.split(":").takeIf { it.size == 2 } ?: return@mapNotNull null
|
val (name, stateDescription) = it.split(":").takeIf { it.size == 2 } ?: return@mapNotNull null
|
||||||
val state = ReportLevel.findByDescription(stateDescription) ?: return@mapNotNull null
|
val state = ReportLevel.findByDescription(stateDescription) ?: return@mapNotNull null
|
||||||
|
|||||||
+11
-1
@@ -39,11 +39,21 @@ val nullabilityAnnotationSettings = mapOf(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
val jsr305Settings = JavaNullabilityAnnotationsStatus(
|
private val jsr305Settings = JavaNullabilityAnnotationsStatus(
|
||||||
reportLevelBefore = ReportLevel.WARN,
|
reportLevelBefore = ReportLevel.WARN,
|
||||||
sinceVersion = null
|
sinceVersion = null
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun getDefaultJsr305Settings(): Jsr305Settings {
|
||||||
|
val globalReportLevel = if (jsr305Settings.sinceVersion != null && jsr305Settings.sinceVersion <= KotlinVersion.CURRENT) {
|
||||||
|
jsr305Settings.reportLevelAfter
|
||||||
|
} else {
|
||||||
|
jsr305Settings.reportLevelBefore
|
||||||
|
}
|
||||||
|
val migrationLevel = if (globalReportLevel == ReportLevel.WARN) null else globalReportLevel
|
||||||
|
return Jsr305Settings(globalReportLevel, migrationLevel)
|
||||||
|
}
|
||||||
|
|
||||||
fun getDefaultReportLevelForAnnotation(annotationFqName: FqName) = getReportLevelForAnnotation(annotationFqName, emptyMap())
|
fun getDefaultReportLevelForAnnotation(annotationFqName: FqName) = getReportLevelForAnnotation(annotationFqName, emptyMap())
|
||||||
|
|
||||||
fun getReportLevelForAnnotation(annotation: FqName, configuredReportLevels: Map<FqName, ReportLevel>): ReportLevel {
|
fun getReportLevelForAnnotation(annotation: FqName, configuredReportLevels: Map<FqName, ReportLevel>): ReportLevel {
|
||||||
|
|||||||
@@ -13,13 +13,7 @@ data class Jsr305Settings(
|
|||||||
val userDefinedLevelForSpecificAnnotation: Map<FqName, ReportLevel> = emptyMap()
|
val userDefinedLevelForSpecificAnnotation: Map<FqName, ReportLevel> = emptyMap()
|
||||||
) {
|
) {
|
||||||
companion object {
|
companion object {
|
||||||
val DEFAULT by lazy {
|
val DEFAULT = getDefaultJsr305Settings()
|
||||||
val reportLevelBefore = if (jsr305Settings.sinceVersion != null && jsr305Settings.sinceVersion <= KotlinVersion.CURRENT) {
|
|
||||||
jsr305Settings.reportLevelBefore
|
|
||||||
} else jsr305Settings.reportLevelAfter
|
|
||||||
|
|
||||||
Jsr305Settings(reportLevelBefore, if (reportLevelBefore == ReportLevel.WARN) null else reportLevelBefore)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
|
|||||||
Reference in New Issue
Block a user