Skip to content

Support adding static imports for method invocations#140

Merged
timtebeek merged 4 commits intomainfrom
support-static-imports
May 3, 2025
Merged

Support adding static imports for method invocations#140
timtebeek merged 4 commits intomainfrom
support-static-imports

Conversation

@timtebeek
Copy link
Copy Markdown
Member

What's your motivation?

Follow the instructions defined on rules to replace qualified method invocations with static imports.

Anything in particular you'd like reviewers to focus on?

I've limited this to top level J.MethodInvocation only, to cover a common case with as little complexity as possible.
I've also optimistically assumed the goal is to always use static imports when the annotation is used, as per
https://github.com/search?q=repo%3APicnicSupermarket%2Ferror-prone-support+%22%40UseImportPolicy%28%22&type=code

Have you considered any alternatives or workarounds?

Handling annotation arguments is slightly awkward with assignments, and possible static imports, and not needed for now.
Handling anything beyond direct method invocations comes with a performance penalty as well, that I'd wanted to avoid.

Any additional context

@timtebeek timtebeek added the enhancement New feature or request label May 3, 2025
@timtebeek timtebeek requested a review from knutwannheden May 3, 2025 18:26
@timtebeek timtebeek self-assigned this May 3, 2025
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite May 3, 2025
@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite May 3, 2025
@timtebeek
Copy link
Copy Markdown
Member Author

Building on top of this work, and can't imagine there would be heavy criticism of this change, so merging already.

@timtebeek timtebeek merged commit 5365c6b into main May 3, 2025
2 checks passed
@timtebeek timtebeek deleted the support-static-imports branch May 3, 2025 19:16
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant