FIR LC: do not ignore useSite target for getting deprecation status

This commit is contained in:
Ilya Kirillov
2021-08-21 14:14:21 +03:00
parent c17a4a5a3b
commit 20f297aaf7
3 changed files with 20 additions and 1 deletions
@@ -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
}
}
@@ -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.
*/
@@ -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 {