openrewrite / rewrite-kotlin

Work-in-progress implementation of Kotlin language support for OpenRewrite.
Apache License 2.0
47 stars 13 forks source link

visitAnnotation method is not called for nested annotation #475

Closed zacscoding closed 11 months ago

zacscoding commented 11 months ago

What version of OpenRewrite are you using?

I am using

What is the smallest, simplest way to reproduce the problem?

import org.junit.jupiter.api.Test;
import org.openrewrite.java.ChangeAnnotationAttributeName;
import org.openrewrite.java.JavaParser;
import org.openrewrite.kotlin.KotlinParser;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.kotlin.Assertions.kotlin;

public class ChangeAnnotationAttributeNameTest implements RewriteTest {

    @Test
    public void run() {
        rewriteRun(
                spec -> spec.recipe(new ChangeAnnotationAttributeName(
                                "org.junit.jupiter.api.Tag",
                                "value",
                                "newValue"
                        ))
                        .parser(KotlinParser.builder().classpath("junit-jupiter-api")),
                kotlin(
                        """
                                package sample

                                 import org.junit.jupiter.api.Tag
                                 import org.junit.jupiter.api.Tags

                                 class SampleTest {

                                     @Tags(
                                         value = [
                                             Tag(value = "Sample01"),
                                             Tag(value = "Sample02"),
                                         ]
                                     )
                                     fun run() {
                                     }
                                 }
                                """,
                        """
                                package sample

                                 import org.junit.jupiter.api.Tag
                                 import org.junit.jupiter.api.Tags

                                 class SampleTest {

                                     @Tags(
                                         value = [
                                             Tag(newValue = "Sample01"),
                                             Tag(newValue = "Sample02"),
                                         ]
                                     )
                                     fun run() {
                                     }
                                 }
                                """
                )
        );
    }
}
traceyyoshima commented 11 months ago

@zacscoding thank you for reporting the issue! I'll take a look :)