diff --git a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/symbols/descriptorBased/base/Kt1DescUtils.kt b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/symbols/descriptorBased/base/Kt1DescUtils.kt index 2531b57e691..0087aa491af 100644 --- a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/symbols/descriptorBased/base/Kt1DescUtils.kt +++ b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/symbols/descriptorBased/base/Kt1DescUtils.kt @@ -429,18 +429,18 @@ internal tailrec fun KotlinBuiltIns.areSameArrayTypeIgnoringProjections(left: Ko internal fun List>.expandArrayAnnotationValue( containingArrayType: KotlinType, analysisContext: Fe10AnalysisContext, -): List = flatMapIndexed { index: Int, constantValue: ConstantValue<*> -> +): List = flatMap { constantValue: ConstantValue<*> -> val constantType = constantValue.getType(analysisContext.resolveSession.moduleDescriptor) if (analysisContext.builtIns.areSameArrayTypeIgnoringProjections(containingArrayType, constantType)) { // If an element in the array has the same type as the containing array, it's a spread component that needs // to be expanded here. (It should have the array element type instead.) (constantValue as ArrayValue).value.expandArrayAnnotationValue(containingArrayType, analysisContext) } else { - listOf(constantValue.toKtAnnotationValue(analysisContext, index)) + listOf(constantValue.toKtAnnotationValue(analysisContext)) } } -internal fun ConstantValue<*>.toKtAnnotationValue(analysisContext: Fe10AnalysisContext, index: Int): KtAnnotationValue { +internal fun ConstantValue<*>.toKtAnnotationValue(analysisContext: Fe10AnalysisContext): KtAnnotationValue { return when (this) { is ArrayValue -> { val arrayType = getType(analysisContext.resolveSession.moduleDescriptor) @@ -462,7 +462,7 @@ internal fun ConstantValue<*>.toKtAnnotationValue(analysisContext: Fe10AnalysisC psi = null, useSiteTarget = null, arguments = value.getKtNamedAnnotationArguments(analysisContext), - index = index, + index = null, ) ) } @@ -635,7 +635,7 @@ internal val AnnotationDescriptor.useSiteTarget: AnnotationUseSiteTarget? internal fun AnnotationDescriptor.getKtNamedAnnotationArguments(analysisContext: Fe10AnalysisContext): List = allValueArguments.map { (name, value) -> - KtNamedAnnotationValue(name, value.toKtAnnotationValue(analysisContext, index = -1)) + KtNamedAnnotationValue(name, value.toKtAnnotationValue(analysisContext)) } internal fun CallableDescriptor.createContextReceivers( diff --git a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/renderAnnotations.kt b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/renderAnnotations.kt index aab3dc979f6..302f65a837c 100644 --- a/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/renderAnnotations.kt +++ b/analysis/analysis-api-fe10/src/org/jetbrains/kotlin/analysis/api/descriptors/utils/renderAnnotations.kt @@ -41,7 +41,7 @@ internal fun PrettyPrinter.renderFe10Annotations( printCollectionIfNotEmpty(valueArguments, separator = ", ", prefix = "(", postfix = ")") { (name, value) -> append(name.render()) append(" = ") - append(value.toKtAnnotationValue(analysisContext, -1).renderAsSourceCode()) + append(value.toKtAnnotationValue(analysisContext).renderAsSourceCode()) } append(separator) diff --git a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/evaluate/FirAnnotationValueConverter.kt b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/evaluate/FirAnnotationValueConverter.kt index 3930ab420c5..a497ede67c7 100644 --- a/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/evaluate/FirAnnotationValueConverter.kt +++ b/analysis/analysis-api-fir/src/org/jetbrains/kotlin/analysis/api/fir/evaluate/FirAnnotationValueConverter.kt @@ -117,7 +117,7 @@ internal object FirAnnotationValueConverter { psi as? KtCallElement, useSiteTarget = null, toNamedConstantValue(resultMap, session), - index = -1, + index = null, ) ) } else null diff --git a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplication.kt b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplication.kt index 8561888c51b..e26056227e4 100644 --- a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplication.kt +++ b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplication.kt @@ -15,7 +15,7 @@ import org.jetbrains.kotlin.psi.KtCallElement * Some examples: * - For declarations: `@Deprecated("Should not be used") fun foo(){}` * - For types: `fun foo(x: List<@A Int>){}` - * - Inside other annotation (`B` is annotation here): `@A(B()) fun foo(){} + * - Inside another annotation (`B` is annotation here): `@A(B()) fun foo(){} */ public sealed interface KtAnnotationApplication { /** @@ -24,7 +24,7 @@ public sealed interface KtAnnotationApplication { public val classId: ClassId? /** - * PsiElement which was used to apply annotation to declaration/type. + * [com.intellij.psi.PsiElement] which was used to apply annotation to declaration/type. * * Present only for declarations from sources. For declarations from other places (libraries, stdlib) it's `null` */ @@ -33,7 +33,7 @@ public sealed interface KtAnnotationApplication { /** * [AnnotationUseSiteTarget] to which annotation was applied. May be not-null only for annotation applications for declarations. * - * See in more details in [Kotlin Documentation](https://kotlinlang.org/docs/annotations.html#annotation-use-site-targets) for more information about annotation targets. + * See more details in [Kotlin Documentation](https://kotlinlang.org/docs/annotations.html#annotation-use-site-targets) for more information about annotation targets. */ public val useSiteTarget: AnnotationUseSiteTarget? @@ -43,7 +43,7 @@ public sealed interface KtAnnotationApplication { public val isCallWithArguments: Boolean /** - * An index of the annotation in an owner. Can be `-1` in case of annotation arguments + * An index of the annotation in an owner. `null` for annotation arguments */ - public val index: Int + public val index: Int? } diff --git a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationInfo.kt b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationInfo.kt index 46cee4d8539..bef617df826 100644 --- a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationInfo.kt +++ b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationInfo.kt @@ -10,39 +10,16 @@ import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.psi.KtCallElement /** - * Overview of annotation to some declaration or type. + * Info of annotation to some declaration or type. * * Some examples: * - For declarations: `@Deprecated("Should not be used") fun foo(){}` * - For types: `fun foo(x: List<@A Int>){}` */ public data class KtAnnotationApplicationInfo( - /** - * The [ClassId] of applied annotation. [ClassId] is a fully qualified name on annotation class. - */ public override val classId: ClassId?, - - /** - * [com.intellij.psi.PsiElement] which was used to apply annotation to declaration/type. - * - * Present only for declarations from sources. For declarations from other places (libraries, stdlib) it's `null` - */ public override val psi: KtCallElement?, - - /** - * [AnnotationUseSiteTarget] to which annotation was applied. May be not-null only for annotation applications for declarations. - * - * See in more details in [Kotlin Documentation](https://kotlinlang.org/docs/annotations.html#annotation-use-site-targets) for more information about annotation targets. - */ public override val useSiteTarget: AnnotationUseSiteTarget?, - - /** - * **true** if the annotation has any arguments - */ public override val isCallWithArguments: Boolean, - - /** - * An index of the annotation in an owner - */ public override val index: Int, ) : KtAnnotationApplication diff --git a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationWithArgumentsInfo.kt b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationWithArgumentsInfo.kt index ba6192df785..efa535d5700 100644 --- a/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationWithArgumentsInfo.kt +++ b/analysis/analysis-api/src/org/jetbrains/kotlin/analysis/api/annotations/KtAnnotationApplicationWithArgumentsInfo.kt @@ -18,7 +18,7 @@ public data class KtAnnotationApplicationWithArgumentsInfo( * A list of annotation arguments which were applied when constructing annotation. Every argument is [KtAnnotationValue] */ public val arguments: List, - override val index: Int, + override val index: Int?, ) : KtAnnotationApplication { override val isCallWithArguments: Boolean get() = arguments.isNotEmpty() }