fix: plugin block matching for Gradle refactoring#66
Conversation
0facf39 to
dc1b886
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes Gradle plugin block matching in the refactoring logic to handle edge cases where plugin definitions are added after plugin. tokens and when version strings contain nested braces (e.g., ${foo-version}).
Key changes:
- Modified the ANTLR grammar to accept the plugin block rule instead of just the plugins token, and added support for nested braces within plugin blocks
- Updated the listener to match on
RULE_plugininstead ofPLUGINStoken - Added test coverage for the refactoring with nested braces in version strings
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main/antlr/com/canonical/devpackspring/build/grammar/GradlePlugin.g4 | Updated grammar rules to handle nested braces in plugin blocks and changed plugin_block definition |
| src/main/java/com/canonical/devpackspring/build/gradle/FindPluginListener.java | Changed rule matching from PLUGINS token to RULE_plugin |
| src/main/java/com/canonical/devpackspring/build/gradle/Refactoring.java | Added error listener suppression for cleaner output |
| src/test/java/com/canonical/devpackspring/build/gradle/RefactoringTests.java | Added test case for refactoring with nested braces in version strings |
| test-data/projects/gradle-kotlin/build.gradle.kts | Added test fixture with plugins.withType block |
| gradle.properties | Bumped version from 0.12.0 to 0.12.2 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/antlr/com/canonical/devpackspring/build/grammar/GradlePlugin.g4
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/test/java/com/canonical/devpackspring/build/gradle/RefactoringTests.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/canonical/devpackspring/build/gradle/Refactoring.java
Outdated
Show resolved
Hide resolved
src/main/antlr/com/canonical/devpackspring/build/grammar/GradlePlugin.g4
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
Fix refactoring for gradle builds:
plugin.foo.bar:foo:${foo-version}