GradleParser correct Class/Method Type association for Kotlin
For Recipes like RemoveBuildPlugin we can use MethodMatcher patterns like:
-
RewriteGradleProject plugins(..) -
PluginSpec id(..) - ...
To match e.g. plugins
But for build.gradle.kts the J.MethodInvocation.methodType is simply null.
So recipes like RemoveBuildPlugin does not work for Kotlin DSL in build.gradle.kts
It would be great if we could tell the KotlinParser the "class-scope" of a build.gradle.kts, just like it is done via
https://github.com/openrewrite/rewrite/blob/c102595ed3b8897acf70552ca9466b914ed4f06b/rewrite-gradle/src/main/java/org/openrewrite/gradle/GradleParser.java#L58
For the GroovyParser
But I guess since the GroovyParser has a completely different implementation than KotlinParser this is not so straight-forward?
hi @PhilKes ; thanks yes indeed it's been a bit of a challenge to build out .kts support for Gradle, and support that through recipes because of the missing type information. @shanman190 has been instrumental in getting our current support out, but the nature of .kts files and their incremental compilation, combined with some APIs not exposed in Gradle mean we for now have to deal with missing type information.
That said, perhaps there's ways still to improve things since (looking at Gradle 9.x and beyond), or synthesize some semblance of type information beyond just null. We can keep this issue open for potential improvements here.