[kotlin] k2: fix annotation with arguments presentation

KTIJ-30695

GitOrigin-RevId: 681e7f73c1d1c6a2713599fd26915960e11b145c
This commit is contained in:
Anna Kozlova
2024-07-30 22:35:41 +00:00
committed by intellij-monorepo-bot
parent b27ed90ff3
commit c6fee8bfc9
3 changed files with 4 additions and 3 deletions
@@ -39,7 +39,7 @@ data class ExtractableCodeDescriptor(
get() = if (renderedAnnotations.isEmpty()) {
""
} else {
renderedAnnotations.joinToString(separator = "\n", postfix = "\n")
renderedAnnotations.joinToString(separator = "\n")
}
}
@@ -228,6 +228,7 @@ internal class ExtractionDataAnalyzer(private val extractionData: ExtractionData
printer.append('@')
renderer.annotationUseSiteTargetRenderer.renderUseSiteTarget(useSiteSession, annotation, owner, renderer, printer)
renderer.annotationsQualifiedNameRenderer.renderQualifier(useSiteSession, annotation, owner, renderer, printer)
renderer.annotationArgumentsRenderer.renderAnnotationArguments(useSiteSession, annotation, owner, renderer, printer)
printer.append('\n')
printer.toString()
}
@@ -40,13 +40,13 @@ private class MyComposeExtractFunctionDescriptorModifier : ExtractFunctionDescri
if (sourceFunction is KtAnnotated) {
sourceFunction.findAnnotation(MY_COMPOSABLE_CLASS_ID)?.let {
return descriptor.copy(
renderedAnnotations = descriptor.renderedAnnotations + "@${MY_COMPOSABLE_CLASS_ID.asFqNameString()}"
renderedAnnotations = descriptor.renderedAnnotations + "@${MY_COMPOSABLE_CLASS_ID.asFqNameString()}\n"
)
}
}
val outsideLambda = descriptor.extractionData.commonParent.parentOfType<KtLambdaArgument>(true) ?: return descriptor
return if (outsideLambda.isComposable()) {
descriptor.copy(renderedAnnotations = descriptor.renderedAnnotations + "@${MY_COMPOSABLE_CLASS_ID.asFqNameString()}")
descriptor.copy(renderedAnnotations = descriptor.renderedAnnotations + "@${MY_COMPOSABLE_CLASS_ID.asFqNameString()}\n")
} else {
descriptor
}