Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let UsesMethod add its own marker #4035

Merged
merged 6 commits into from
Feb 23, 2024

Conversation

pstreef
Copy link
Contributor

@pstreef pstreef commented Feb 23, 2024

When FindMethods is used on a source file that already has a SearchResult marker on the root node (as e.g. added by HasJavaVersion) then the recipe will not find anything, because its UsesMethod precondition evaluates to false (because the root node already has a SearchResult marker).

To avoid this aliasing issue and also avoid issues if UsesMethod is applied before another recipe / visitor that adds a SearchResult marker, the UsesMethod visitor now uses its own marker type. The marker will only be added if the source file doesn't already have a marker which was created for the same method pattern.

pstreef and others added 6 commits February 23, 2024 10:17
`org.openrewrite.java.search.HasJavaVersion` combined with `org.openrewrite.java.search.FindMethods` fails to find results for FindMethods if that recipe is running after `HasJavaVersion`.
@knutwannheden knutwannheden changed the title HasJavaVersion combined with FindMethods depends on order Let FindMethods add its own marker Feb 23, 2024
@knutwannheden knutwannheden changed the title Let FindMethods add its own marker Let UsesMethod add its own marker Feb 23, 2024
@knutwannheden knutwannheden merged commit 0ee95e4 into main Feb 23, 2024
1 check passed
@knutwannheden knutwannheden deleted the fix/find-java-version-combined-with-find-method branch February 23, 2024 11:17
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.

2 participants