[AA] KtCallableReceiverRenderer: add annotations renderer

^KT-54417
This commit is contained in:
Dmitrii Gridin
2022-11-17 07:55:22 +01:00
committed by Space Team
parent 5ab07c2c00
commit a0f4c674f5
6 changed files with 18 additions and 8 deletions
@@ -35,8 +35,9 @@ public interface KtAnnotationUseSiteTargetRenderer {
public object WITH_NON_DEFAULT_USE_SITE : KtAnnotationUseSiteTargetRenderer {
context(KtAnalysisSession, KtAnnotationRenderer)
override fun renderUseSiteTarget(annotation: KtAnnotationApplication, owner: KtAnnotated, printer: PrettyPrinter) {
if (owner !is KtCallableSymbol) return
val print = when (owner) {
is KtReceiverParameterSymbol -> true
!is KtCallableSymbol -> return
is KtAnonymousFunctionSymbol -> true
is KtConstructorSymbol -> true
is KtFunctionSymbol -> true
@@ -52,7 +53,9 @@ public interface KtAnnotationUseSiteTargetRenderer {
is KtLocalVariableSymbol -> true
is KtKotlinPropertySymbol -> annotation.useSiteTarget != AnnotationUseSiteTarget.PROPERTY
is KtSyntheticJavaPropertySymbol -> annotation.useSiteTarget != AnnotationUseSiteTarget.PROPERTY
else -> return
}
if (print) {
WITH_USES_SITE.renderUseSiteTarget(annotation, owner, printer)
}
@@ -17,9 +17,16 @@ public interface KtCallableReceiverRenderer {
public object AS_TYPE_WITH_IN_APPROXIMATION : KtCallableReceiverRenderer {
context(KtAnalysisSession, KtDeclarationRenderer)
override fun renderReceiver(symbol: KtReceiverParameterSymbol, printer: PrettyPrinter) {
val receiverType = declarationTypeApproximator.approximateType(symbol.type, Variance.IN_VARIANCE)
typeRenderer.renderType(receiverType, printer)
override fun renderReceiver(symbol: KtReceiverParameterSymbol, printer: PrettyPrinter): Unit = printer {
" ".separated(
{
annotationRenderer.renderAnnotations(symbol, printer)
},
{
val receiverType = declarationTypeApproximator.approximateType(symbol.type, Variance.IN_VARIANCE)
typeRenderer.renderType(receiverType, printer)
},
)
}
}
}
@@ -1 +1 @@
fun @ReceiverTypeAnnotation kotlin.Int.foo()
fun @receiver:ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Int.foo()
@@ -1,2 +1,2 @@
val @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean
val @receiver:ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean
get()
@@ -1 +1 @@
fun @ReceiverTypeAnnotation kotlin.Int.foo()
fun @receiver:ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Int.foo()
@@ -1,2 +1,2 @@
val @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean
val @receiver:ReceiverAnnotation @ReceiverTypeAnnotation kotlin.Long.prop: kotlin.Boolean
get()