From 7dff4ad916b82494ae88e74f0280aab0575c0604 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 2 Sep 2015 17:41:03 +0300 Subject: [PATCH] New built-in annotations: Retention, Repeatable, MustBeDocumented --- .../src/kotlin/annotation/Annotations.kt | 20 +++++++++++++++++++ .../kotlin/builtins/KotlinBuiltIns.java | 18 +++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/core/builtins/src/kotlin/annotation/Annotations.kt b/core/builtins/src/kotlin/annotation/Annotations.kt index ce36db4a700..44e6b9a7ef9 100644 --- a/core/builtins/src/kotlin/annotation/Annotations.kt +++ b/core/builtins/src/kotlin/annotation/Annotations.kt @@ -89,3 +89,23 @@ public annotation(retention = AnnotationRetention.SOURCE, mustBeDocumented = tru val repeatable: Boolean = false, val mustBeDocumented: Boolean = false ) + +/** + * This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true. + * + * @property value necessary annotation retention (RUNTIME, BINARY or SOURCE) + */ +target(AnnotationTarget.ANNOTATION_CLASS) +public annotation class Retention(val value: AnnotationRetention = AnnotationRetention.RUNTIME) + +/** + * This meta-annotation determines that an annotation is applicable twice or more on a single code element + */ +target(AnnotationTarget.ANNOTATION_CLASS) +public annotation class Repeatable + +/** + * This meta-annotation determines that an annotation is a part of public API and therefore must be documented + */ +target(AnnotationTarget.ANNOTATION_CLASS) +public annotation class MustBeDocumented \ No newline at end of file diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index 07f46d4f6b9..725c8101a5b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -180,6 +180,9 @@ public class KotlinBuiltIns { public final FqName annotation = annotationName("annotation"); public final FqName annotationTarget = annotationName("AnnotationTarget"); public final FqName annotationRetention = annotationName("AnnotationRetention"); + public final FqName retention = annotationName("Retention"); + public final FqName repeatable = annotationName("Repeatable"); + public final FqName mustBeDocumented = annotationName("MustBeDocumented"); public final FqName mutableList = fqName("MutableList"); public final FqName mutableSet = fqName("MutableSet"); @@ -393,6 +396,21 @@ public class KotlinBuiltIns { return getAnnotationClassByName(FQ_NAMES.target.shortName()); } + @NotNull + public ClassDescriptor getRetentionAnnotation() { + return getAnnotationClassByName(FQ_NAMES.retention.shortName()); + } + + @NotNull + public ClassDescriptor getRepeatableAnnotation() { + return getAnnotationClassByName(FQ_NAMES.repeatable.shortName()); + } + + @NotNull + public ClassDescriptor getMustBeDocumentedAnnotation() { + return getAnnotationClassByName(FQ_NAMES.mustBeDocumented.shortName()); + } + @NotNull public ClassDescriptor getAnnotationTargetEnum() { return getAnnotationClassByName(FQ_NAMES.annotationTarget.shortName());