Add 'DeprecationLevel' parameter to 'Deprecated'
This commit is contained in:
@@ -32,13 +32,17 @@ private annotation class data
|
||||
|
||||
/**
|
||||
* Marks the annotated class, function, property, variable or parameter as deprecated.
|
||||
* @property value the message explaining the deprecation and recommending an alternative API to use.
|
||||
* @property message the message explaining the deprecation and recommending an alternative API to use.
|
||||
* @property replaceWith if present, specifies a code fragment which should be used as a replacement for
|
||||
* the deprecated API usage.
|
||||
*/
|
||||
@Target(CLASS, FUNCTION, PROPERTY, ANNOTATION_CLASS, CONSTRUCTOR, PROPERTY_SETTER, PROPERTY_GETTER)
|
||||
@MustBeDocumented
|
||||
public annotation class Deprecated(val value: String, val replaceWith: ReplaceWith = ReplaceWith(""))
|
||||
public annotation class Deprecated(
|
||||
val message: String,
|
||||
val replaceWith: ReplaceWith = ReplaceWith(""),
|
||||
val level: DeprecationLevel = DeprecationLevel.WARNING
|
||||
)
|
||||
|
||||
/**
|
||||
* Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such
|
||||
@@ -58,6 +62,18 @@ public annotation class Deprecated(val value: String, val replaceWith: ReplaceWi
|
||||
@MustBeDocumented
|
||||
public annotation class ReplaceWith(val expression: String, vararg val imports: String)
|
||||
|
||||
/**
|
||||
* Contains levels for deprecation levels.
|
||||
*/
|
||||
public enum class DeprecationLevel {
|
||||
/** Usage of the deprecated element will be marked as a warning. */
|
||||
WARNING,
|
||||
/** Usage of the deprecated element will be marked as an error. */
|
||||
ERROR,
|
||||
/** Deprecated element will not be accessible from code. */
|
||||
HIDDEN
|
||||
}
|
||||
|
||||
/**
|
||||
* Signifies that the annotated functional type represents an extension function.
|
||||
*/
|
||||
|
||||
@@ -52,6 +52,7 @@ public final class JvmAnnotationNames {
|
||||
public static final String DATA_FIELD_NAME = "data";
|
||||
public static final String STRINGS_FIELD_NAME = "strings";
|
||||
public static final Name DEFAULT_ANNOTATION_MEMBER_NAME = Name.identifier("value");
|
||||
public static final Name DEPRECATED_ANNOTATION_MESSAGE = Name.identifier("message");
|
||||
public static final Name TARGET_ANNOTATION_MEMBER_NAME = Name.identifier("allowedTargets");
|
||||
|
||||
public static final FqName TARGET_ANNOTATION = new FqName("java.lang.annotation.Target");
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ class JavaDeprecatedAnnotationDescriptor(
|
||||
|
||||
private val valueArguments = c.storageManager.createLazyValue {
|
||||
val parameterDescriptor = valueParameters.firstOrNull {
|
||||
it.name == JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME
|
||||
it.name == JvmAnnotationNames.DEPRECATED_ANNOTATION_MESSAGE
|
||||
}
|
||||
parameterDescriptor?.let { mapOf(it to ConstantValueFactory(c.module.builtIns).createConstantValue("Deprecated in Java")) } ?: emptyMap()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user