-
Notifications
You must be signed in to change notification settings - Fork 365
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
Tentative fix for missing "//" operator on XPathMatcher
#3707
Conversation
@@ -78,6 +88,33 @@ public boolean matches(Cursor cursor) { | |||
Collections.reverse(path); | |||
String[] parts = expression.substring(1).split("/"); | |||
|
|||
// Deal with the two forward slashes in the expression; works, but I'm not proud of it. |
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.
Missed chance at using our @SelfLoathing(name= "...")
annotation.
@@ -78,6 +88,31 @@ public boolean matches(Cursor cursor) { | |||
Collections.reverse(path); | |||
String[] parts = expression.substring(1).split("/"); | |||
|
|||
// Deal with the two forward slashes in the expression; works, but I'm not proud of it. | |||
if (expression.contains("//") && Arrays.stream(parts).anyMatch(StringUtils::isBlank)) { |
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.
What's the second part of the conditional meant to match? Since it seems as though we only reach here when Arrays.stream(parts).anyMatch(StringUtils::isBlank)
would be true, given that the expression contains //
, does not start with /
, and is then split on /
. Is it to skip cases that end in //
which would not produce empty elements?
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.
Not quite sure what else you'd want to test still; approved as is, and ready to merge if you are.
Decided to merge as is to not keep this open; since we specifically look at cases where the expression contains |
Following on from openrewrite/rewrite#3707 Fixes #353
* Update maven-compiler-plugin in pluginManagement Following on from openrewrite/rewrite#3707 Fixes #353 * Simplify test case to not use property
What's changed?
Changes
XPathMatcher
to allow//
syntax.What's your motivation?
openrewrite/rewrite-migrate-java#353
Anything in particular you'd like reviewers to focus on?
This is just enough to fix the before mentioned issue, definitely needs more testing and a better implementation.
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist
./gradlew licenseFormat