[AA] KtAnnotationApplicationInfo: add more information to kdoc

^KT-56046
This commit is contained in:
Dmitrii Gridin
2023-02-02 17:13:24 +01:00
committed by Space Team
parent 00eddae867
commit 3e4c6b160a
5 changed files with 23 additions and 4 deletions
@@ -17,6 +17,9 @@ public interface KtAnnotated {
/** /**
* A list of annotations applied. * A list of annotations applied.
* *
* To check if annotation is present, please use [hasAnnotation].
* [annotationInfos] is more preferable if suits your needs because it is lightweight.
*
* @see [KtAnnotationsList.annotations] * @see [KtAnnotationsList.annotations]
*/ */
public val KtAnnotated.annotations: List<KtAnnotationApplicationWithArgumentsInfo> public val KtAnnotated.annotations: List<KtAnnotationApplicationWithArgumentsInfo>
@@ -16,6 +16,9 @@ import org.jetbrains.kotlin.psi.KtCallElement
* - For declarations: `@Deprecated("Should not be used") fun foo(){}` * - For declarations: `@Deprecated("Should not be used") fun foo(){}`
* - For types: `fun foo(x: List<@A Int>){}` * - For types: `fun foo(x: List<@A Int>){}`
* - Inside another annotation (`B` is annotation here): `@A(B()) fun foo(){} * - Inside another annotation (`B` is annotation here): `@A(B()) fun foo(){}
*
* @see KtAnnotationApplicationInfo
* @see KtAnnotationApplicationWithArgumentsInfo
*/ */
public sealed interface KtAnnotationApplication { public sealed interface KtAnnotationApplication {
/** /**
@@ -10,11 +10,19 @@ import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.psi.KtCallElement import org.jetbrains.kotlin.psi.KtCallElement
/** /**
* Info of annotation to some declaration or type. * A lightweight implementation of [KtAnnotationApplication].
* Should be used instead of [KtAnnotationApplicationWithArgumentsInfo] where possible to avoid redundant resolve.
* *
* Some examples: * Example:
* - For declarations: `@Deprecated("Should not be used") fun foo(){}` * ```
* - For types: `fun foo(x: List<@A Int>){}` * @Anno1(1) @Anno2
* class Foo
* ```
* In this case if you don't want to process [KtAnnotationApplicationWithArgumentsInfo.arguments]
* you can call [KtAnnotated.annotationInfos] to get all necessary information.
*
* @see KtAnnotated.annotationInfos
* @see KtAnnotationApplicationWithArgumentsInfo
*/ */
public data class KtAnnotationApplicationInfo( public data class KtAnnotationApplicationInfo(
public override val classId: ClassId?, public override val classId: ClassId?,
@@ -9,6 +9,10 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.psi.KtCallElement import org.jetbrains.kotlin.psi.KtCallElement
/**
* @see KtAnnotated.annotations
* @see KtAnnotationApplicationInfo
*/
public data class KtAnnotationApplicationWithArgumentsInfo( public data class KtAnnotationApplicationWithArgumentsInfo(
override val classId: ClassId?, override val classId: ClassId?,
override val psi: KtCallElement?, override val psi: KtCallElement?,
@@ -18,6 +18,7 @@ public abstract class KtAnnotationsList : KtLifetimeOwner {
* A list of annotations applied. * A list of annotations applied.
* *
* To check if annotation is present, please use [hasAnnotation]. * To check if annotation is present, please use [hasAnnotation].
* [annotationInfos] is more preferable if suits your needs as a lightweight.
* *
* @see KtAnnotationApplication * @see KtAnnotationApplication
*/ */