Extract building JSR-305 settings to separate function
This commit is contained in:
+11
-1
@@ -39,11 +39,21 @@ val nullabilityAnnotationSettings = mapOf(
|
||||
),
|
||||
)
|
||||
|
||||
val jsr305Settings = JavaNullabilityAnnotationsStatus(
|
||||
private val jsr305Settings = JavaNullabilityAnnotationsStatus(
|
||||
reportLevelBefore = ReportLevel.WARN,
|
||||
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 getReportLevelForAnnotation(annotation: FqName, configuredReportLevels: Map<FqName, ReportLevel>): ReportLevel {
|
||||
|
||||
@@ -13,13 +13,7 @@ data class Jsr305Settings(
|
||||
val userDefinedLevelForSpecificAnnotation: Map<FqName, ReportLevel> = emptyMap()
|
||||
) {
|
||||
companion object {
|
||||
val DEFAULT by lazy {
|
||||
val reportLevelBefore = if (jsr305Settings.sinceVersion != null && jsr305Settings.sinceVersion <= KotlinVersion.CURRENT) {
|
||||
jsr305Settings.reportLevelBefore
|
||||
} else jsr305Settings.reportLevelAfter
|
||||
|
||||
Jsr305Settings(reportLevelBefore, if (reportLevelBefore == ReportLevel.WARN) null else reportLevelBefore)
|
||||
}
|
||||
val DEFAULT = getDefaultJsr305Settings()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
|
||||
Reference in New Issue
Block a user