-
Notifications
You must be signed in to change notification settings - Fork 14
Remove regex pattern from ParsingUtils #366
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
base: main
Are you sure you want to change the base?
Remove regex pattern from ParsingUtils #366
Conversation
Signed-off-by: Fynn Juranek <[email protected]>
Signed-off-by: Fynn Juranek <[email protected]>
marcingrzejszczak
left a comment
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.
LGTM!
|
|
||
| public class ParsingUtils { | ||
|
|
||
| private ParsingUtils() { |
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.
I don't think anyone should have created an instance for this but strictly, this is a breaking change. I think we should fix this but maybe in another PR so we can call it out in the release notes?
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.
I mean who would ever want to instantiate this. I think that most IDEs suggest doing the private constructor. We can of course ignore this for the next minor and just not add this constructor.
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.
I think it is probably ok to break this in a minor version. I would just do it in a separate PR so it is easier to call out in the release notes and separate it from an enhancement PR.
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.
Agree. This is resolved with commit: d879fba7.
Do you want me to open a PR for the private Constructor?
| JavaClassSource javaSource = RoasterTestUtils.readJavaClass(ParsingUtilsReadEnumClassNamesTests.class); | ||
| MethodSource<?> methodSource = ((JavaClassSource) javaSource.getNestedType("MyClass")).getMethod("mergeNested"); | ||
| Set<String> result = ParsingUtils.readEnumClassNames(methodSource); | ||
| assertThat(result).containsExactlyInAnyOrder("NestedFooKeyName", "NestedBarKeyName"); |
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.
Is this correct?
I'm questioning every nested class in this test.
Since the class is nested, it's name is not NestedFooKeyName but ParsingUtilsReadEnumClassNamesTests$FooMeterDocumentation$NestedFooKeyName or ParsingUtilsReadEnumClassNamesTests.FooMeterDocumentation.NestedFooKeyName depending on the context.
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.
This is currently correct, as I add only the last part of the nested KeyNames, which happens here: ParsingUtils.java#L119. But I could just get rid of the substringing and add the whole class name, which would probably lead to a clearer description of where the nested KeyName is coming from.
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.
Changed this now with commit: 213d0386. But this still does not take ParsingUtilsReadEnumClassNamesTests into place as we provide only the the nested type "MyClass" as the methodsource which does not contain ParsingUtilsReadEnumClassNamesTests. Because of these two lines: ParsingUtilsReadEnumClassNamesTests.java#L57-L58, I could change this to include the "root" source which would probably need a different jboss method.
Do you want me to change that?
- Remove as this would silently introduce a breaking change Signed-off-by: Fynn Juranek <[email protected]>
Signed-off-by: Fynn Juranek <[email protected]>
The solution involves replacing the regex pattern usage in ParsingUtils with AST parsing, similar to how we retrieve expressions.
The existing functionality remains unchanged and additionally, there is a new test case added to ensure everything works with nested KeyNames.
closes gh-365