Skip to content

Scan other files for uses of System Rules fields before migrating them - #1310

Merged
timtebeek merged 1 commit into
mainfrom
system-rules-subclasses-other-files
Nov 17, 2026
Merged

timtebeek merged 1 commit into
mainfrom
system-rules-subclasses-other-files

Conversation

@timtebeek

Copy link
Copy Markdown
Member

What changed

SystemRulesToSystemStubs and SystemPropertyRulesToPioneer decided whether a rule field "may be used elsewhere" only from the owner being abstract or the file being in main. A concrete BaseTest whose out rule is read by a SubTest in another file was retyped (System Stubs) or removed (Pioneer), and SubTest stopped compiling.

Both recipes are now ScanningRecipes. The scanner records, per owner#field, the source files that reference the field. A non-private rule field referenced from a file other than its declaring file is treated as used elsewhere, so System Stubs adds the existing TODO Migrate by hand comment and Pioneer leaves the rule alone.

Why a scan rather than only the TODO

Scanning is feasible here: it is a cheap identifier pass, and it avoids flagging every concrete class. The abstract/main heuristics stay as the fallback for subclasses outside the repository. ExpectedSystemExitToCatchSystemExit shares SystemRules.mayBeUsedElsewhere and keeps its previous behaviour through an overload; it is not part of this item.

Tests

Regression tests with a base class and a subclass in separate files, for each recipe; both fail without the change.

Fixes item B6 of #1211.

…temStubs` and `SystemPropertyRulesToPioneer`
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Nov 17, 2026
@timtebeek
timtebeek enabled auto-merge (squash) November 17, 2026 21:15
@timtebeek
timtebeek merged commit ceafdd9 into main Nov 17, 2026
1 check passed
@timtebeek
timtebeek deleted the system-rules-subclasses-other-files branch November 17, 2026 21:19
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Nov 17, 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