openrewrite / openrewrite/rewrite
Allow Traits visitors to schedule after visitors
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 571
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What problem are you trying to solve?
Traits are great to simplify development, but can not be used when changes to imports are needed, as the required hooks to register a doAfterVisitor are not exposed.
Describe the solution you'd like
Allow traits to call doAfterVisit, or similar, to register imports to be added/removed for wider applicability.
Have you considered any alternatives or workarounds?
Use the Traits visitor only within another visitor, but this is awkward and might even be more confusing.
Additional context
As seen on the AssertEqualsToAssertThat example, where the imports make it impossible to switch to a Trait.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the Traits visitor API and the AssertEqualsToAssertThat example at src/main/java/com/yourorg/AssertEqualsToAssertThat.java, especially its import handling. Determine how a Trait could register after-visit behavior; done means the example can be expressed as a Trait while adding or removing its required imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100