Files
Jaebaek Seo b27ed90ff3 Add renderAnnotations to ExtractableCodeDescriptor
The existing `ExtractFunctionDescriptorModifier::modifyDescriptor(..)`
that allows us to update the extraction descriptor returns
`ExtractableCodeDescriptor`. We have some cases like compose editor
of Android Studio that needs to change the behavior of the extraction
by updating the annotation rendering. The current annotation rendering
has a limitation that the rendered annotations must be from the
annotations of the container class. However, in the following example
the lambda argument must have `@Composable` annotation after extraction
even though its container function does not have it:
```
@Composable
fun myWidget(context: @Composable () -> Unit) {}

fun containerFunction() {
    myWidget { // This lambda argument is composable!
        <selection>print(true)</selection>
    }
}
```

Since we cannot handle the above case i.e., adding `@Composable` to the
extracted function for the lambda argument, this commit allows us to
use the rendered annotations instead of class Ids for
`ExtractableCodeDescriptor`.

^KTIJ-30695

Signed-off-by: Anna Kozlova <anna.kozlova@jetbrains.com>

GitOrigin-RevId: e4f2039882092544b67896f4f06a91ffee05d6d8
2024-07-30 22:35:41 +00:00

20 lines
363 B
Plaintext

package com.example
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.TYPE_PARAMETER,
AnnotationTarget.VALUE_PARAMETER)
annotation class MyComposable
@MyComposable
fun myWidget(context: @MyComposable () -> Unit) {}
fun setContent() {
myWidget {
__dummyTestFun__()
}
}
@MyComposable
private fun __dummyTestFun__() {
print(true)
}