Skip to content

Inline precondition-wrapped nested visitor classes - #1028

Merged
timtebeek merged 1 commit into
mainfrom
tim/inline-nested-visitor-preconditions
Aug 25, 2026
Merged

Inline precondition-wrapped nested visitor classes#1028
timtebeek merged 1 commit into
mainfrom
tim/inline-nested-visitor-preconditions

Conversation

@timtebeek

@timtebeek timtebeek commented Aug 25, 2026

Copy link
Copy Markdown
Member
  • Follow-up to Inline nested visitor classes into getVisitor() #1026 and Inline UseStringReplaceVisitor into getVisitor() #1027, which inlined the nested visitors returned directly from getVisitor(). This does the same for five visitors that are wrapped in Preconditions.check(..), declaring them anonymously in place and hoisting their private static final constants onto the recipe class.

  • The InlineNestedVisitorClass recipe deliberately does not handle the precondition-wrapped shape yet — inlining a large visitor under Preconditions.check(..) can hurt readability — so this phases the pattern out here with a small scope (all five visitors are under 55 lines) while leaving it in place elsewhere for now. RemoveInstanceOfPatternMatch is intentionally untouched: its visitor is 174 lines and carries Javadoc that inlining would drop.

Beyond the class declarations and the hoisted constants the diff is a pure re-indent; ./gradlew build passes.

Declare the visitors anonymously inside the `Preconditions.check(..)`
call rather than as named nested classes.
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Aug 25, 2026
@timtebeek
timtebeek merged commit 6760568 into main Aug 25, 2026
1 check passed
@timtebeek
timtebeek deleted the tim/inline-nested-visitor-preconditions branch August 25, 2026 17:47
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant