openrewrite / openrewrite/rewrite

GradleParser correct Class/Method Type association for Kotlin

Open
#6,312 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement gradle kotlin parser
Dominant language
Java
Stars
3.7k
Forks
570
Avg merge
13h 12m
Merged PRs (30d)
261

Description

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?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with rewrite-gradle/src/main/java/org/openrewrite/gradle/GradleParser.java around the class-scope handling referenced in the issue, then compare that implementation with KotlinParser. Reproduce the missing J.MethodInvocation.methodType for a build.gradle.kts example and verify that RemoveBuildPlugin method matchers work for Kotlin DSL calls.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.