-
Notifications
You must be signed in to change notification settings - Fork 454
Fixed wildcard matching for elements with type information. #5833
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- rewrite-java/src/main/java/org/openrewrite/java/internal/grammar/MethodSignatureParser.java
- lines 1059-1059
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- rewrite-java/src/main/java/org/openrewrite/java/internal/grammar/MethodSignatureParser.java
- lines 1059-1059
rewrite-java-test/src/test/java/org/openrewrite/java/MethodMatcherTest.java
Show resolved
Hide resolved
rewrite-java-test/src/test/java/org/openrewrite/java/MethodMatcherTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions could not be made:
- rewrite-java/src/main/java/org/openrewrite/java/internal/grammar/MethodSignatureParser.java
- lines 1059-1059
@timtebeek Do I add this one to the list of core changes? As MethodMatcher is quite broadly used. The tests are quite good though, so not sure. |
Yes please add to the list of core issues to review! 🙏🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved from my side already; added another test to show the difference pointed out in PR comments when type information for Foo.bar()
is present, but for Assert.assertTrue
likely still absent.
Let's wait for that final review before we merge.
What's changed?
Updated the antlr code to allow for wildcard parameters similarly to dot_dot.
What's your motivation?
Before, the existing test used to work due to the following:
*
gets regexed by theStringUtils.aspectjNameToPattern("*")
to[^.]+
.<unknown>
does not contain a.
so the matcher works.The current code behavior: see the
<unknown>
and[^.]+
Changing the test adding type information
See how that regex would no longer match?
Anyone you would like to review specifically?
@greg-at-moderne
Have you considered any alternatives or workarounds?
We could alter the
getRegex
onFormalType
to avoid changes to anltr code but that's not correct according the semantics of the code.Checklist