diff --git a/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/annotations/annotationsUtils.kt b/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/annotations/annotationsUtils.kt index 1a795e66533..4921ce2b2a5 100644 --- a/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/annotations/annotationsUtils.kt +++ b/analysis/symbol-light-classes/src/org/jetbrains/kotlin/light/classes/symbol/annotations/annotationsUtils.kt @@ -41,7 +41,7 @@ internal fun isHiddenByDeprecation( annotationUseSiteTarget: AnnotationUseSiteTarget? = null ): Boolean { return project.analyzeWithSymbolAsContext(symbol) { - symbol.deprecationStatus?.level == DeprecationLevelValue.HIDDEN + symbol.getDeprecationStatus(annotationUseSiteTarget)?.level == DeprecationLevelValue.HIDDEN } } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolInfoProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolInfoProvider.kt index 57300e7b037..ff5e172ab54 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolInfoProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtSymbolInfoProvider.kt @@ -6,11 +6,13 @@ package org.jetbrains.kotlin.idea.frontend.api.components import org.jetbrains.kotlin.descriptors.Deprecation +import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.idea.frontend.api.symbols.KtPropertySymbol import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol public abstract class KtSymbolInfoProvider : KtAnalysisSessionComponent() { public abstract fun getDeprecation(symbol: KtSymbol): Deprecation? + public abstract fun getDeprecation(symbol: KtSymbol, annotationUseSiteTarget: AnnotationUseSiteTarget?): Deprecation? public abstract fun getGetterDeprecation(symbol: KtPropertySymbol): Deprecation? public abstract fun getSetterDeprecation(symbol: KtPropertySymbol): Deprecation? } @@ -21,6 +23,12 @@ public interface KtSymbolInfoProviderMixIn : KtAnalysisSessionMixIn { */ public val KtSymbol.deprecationStatus: Deprecation? get() = analysisSession.symbolInfoProvider.getDeprecation(this) + /** + * Gets the deprecation status of the given symbol. Returns null if the symbol it not deprecated. + */ + public fun KtSymbol.getDeprecationStatus(annotationUseSiteTarget: AnnotationUseSiteTarget?): Deprecation? = + analysisSession.symbolInfoProvider.getDeprecation(this) + /** * Gets the deprecation status of the getter of this property symbol. Returns null if the getter it not deprecated. */ diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolInfoProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolInfoProvider.kt index fc6c5e788de..40bbabdce1b 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolInfoProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirSymbolInfoProvider.kt @@ -35,6 +35,17 @@ internal class KtFirSymbolInfoProvider( } } + override fun getDeprecation(symbol: KtSymbol, annotationUseSiteTarget: AnnotationUseSiteTarget?): Deprecation? { + require(symbol is KtFirSymbol<*>) + return symbol.firRef.withFir { firDeclaration -> + if (annotationUseSiteTarget != null) { + firDeclaration.symbol.getDeprecationForCallSite(annotationUseSiteTarget) + } else { + firDeclaration.symbol.getDeprecationForCallSite() + } + } + } + override fun getGetterDeprecation(symbol: KtPropertySymbol): Deprecation? { require(symbol is KtFirSymbol<*>) return symbol.firRef.withFir {