Rename DeprecatedOption into GradleDeprecatedOption

This should make it more explicit

^KT-49011 In Progress
This commit is contained in:
Yahor Berdnikau
2022-01-28 14:37:16 +01:00
parent 118bda675f
commit c019dbce47
3 changed files with 10 additions and 10 deletions
@@ -6,7 +6,7 @@
package org.jetbrains.kotlin.cli.common.arguments
@Retention(AnnotationRetention.RUNTIME)
annotation class DeprecatedOption(
annotation class GradleDeprecatedOption(
val message: String = "This option has no effect and will be removed in a future release.",
val removeAfter: String,
val level: DeprecationLevel
@@ -27,12 +27,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var classpath: String? by NullableStringFreezableVar(null)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleDeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(value = "-include-runtime", description = "Include Kotlin runtime into the resulting JAR")
var includeRuntime: Boolean by FreezableVar(false)
@DeprecatedOption(
@GradleDeprecatedOption(
message = "This option is not working well with Gradle caching and will be removed in the future.",
removeAfter = "1.7",
level = DeprecationLevel.WARNING
@@ -49,7 +49,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-no-jdk", description = "Don't automatically include the Java runtime into the classpath")
var noJdk: Boolean by FreezableVar(false)
@DeprecatedOption(removeAfter = "1.6", level = DeprecationLevel.ERROR)
@GradleDeprecatedOption(removeAfter = "1.6", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanTrueDefault::class)
@Argument(
value = "-no-stdlib",
@@ -57,7 +57,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var noStdlib: Boolean by FreezableVar(false)
@DeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleDeprecatedOption(removeAfter = "1.5", level = DeprecationLevel.ERROR)
@GradleOption(DefaultValues.BooleanTrueDefault::class)
@Argument(value = "-no-reflect", description = "Don't automatically include Kotlin reflection into the classpath")
var noReflect: Boolean by FreezableVar(false)
@@ -97,7 +97,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
// Advanced options
@DeprecatedOption(removeAfter = "1.6", level = DeprecationLevel.HIDDEN)
@GradleDeprecatedOption(removeAfter = "1.6", level = DeprecationLevel.HIDDEN)
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(
value = "-Xuse-ir",
@@ -183,7 +183,7 @@ fun main() {
}
private inline fun <reified T : Any> List<KProperty1<T, *>>.filterToBeDeleted() = filter { prop ->
prop.findAnnotation<DeprecatedOption>()
prop.findAnnotation<GradleDeprecatedOption>()
?.let { LanguageVersion.fromVersionString(it.removeAfter) }
?.let { it >= LanguageVersion.LATEST_STABLE }
?: true
@@ -289,7 +289,7 @@ private fun Printer.generatePropertyDeclaration(property: KProperty1<*, *>, modi
}
private fun Printer.generateOptionDeprecation(property: KProperty1<*, *>) {
property.findAnnotation<DeprecatedOption>()
property.findAnnotation<GradleDeprecatedOption>()
?.let { DeprecatedOptionAnnotator.generateOptionAnnotation(it) }
?.also { println(it) }
}
@@ -320,7 +320,7 @@ private fun generateMarkdown(properties: List<KProperty1<*, *>>) {
for (property in properties) {
val name = property.name
if (name == "includeRuntime") continue // This option has no effect in Gradle builds
val renderName = listOfNotNull("`$name`", property.findAnnotation<DeprecatedOption>()?.let { "__(Deprecated)__" })
val renderName = listOfNotNull("`$name`", property.findAnnotation<GradleDeprecatedOption>()?.let { "__(Deprecated)__" })
.joinToString(" ")
val description = property.findAnnotation<Argument>()!!.description
val possibleValues = property.gradleValues.possibleValues
@@ -363,7 +363,7 @@ private inline fun <reified T> KAnnotatedElement.findAnnotation(): T? =
annotations.filterIsInstance<T>().firstOrNull()
object DeprecatedOptionAnnotator {
fun generateOptionAnnotation(annotation: DeprecatedOption): String {
fun generateOptionAnnotation(annotation: GradleDeprecatedOption): String {
val message = annotation.message.takeIf { it.isNotEmpty() }?.let { "message = \"$it\"" }
val level = "level = DeprecationLevel.${annotation.level.name}"
val arguments = listOfNotNull(message, level).joinToString()