-
Notifications
You must be signed in to change notification settings - Fork 54
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
Adjust MethodNameCasing
to work with C#
#397
base: main
Are you sure you want to change the base?
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:
- src/main/java/org/openrewrite/staticanalysis/MethodNameCasing.java
- lines 44-43
src/main/java/org/openrewrite/staticanalysis/nameconvention/CsharpNameConvention.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/staticanalysis/nameconvention/JavaNameConvention.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/staticanalysis/nameconvention/NameConvention.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/staticanalysis/nameconvention/NameConventionFactory.java
Outdated
Show resolved
Hide resolved
src/main/java/org/openrewrite/staticanalysis/nameconvention/NameConventionFactory.java
Outdated
Show resolved
Hide resolved
Possibly we should leverage the service mechanism we have in JavaSourceFile. We should pull that up API to SourceFile anyway one of these days. Just a thought. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
It actually already is, so the generic interface could be called something like |
src/main/java/org/openrewrite/staticanalysis/MethodNameCasing.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
String toName = standardized.toString(); | ||
NamingService service = getCursor().firstEnclosing(SourceFile.class).service(NamingService.class); |
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.
The JavaVisitor
in fact has a service()
method which is much easier to use. We might want to pull that up to TreeVisitor
at some point.
We might also have to cache the services a bit more as "breadcrumbs" along the cursor path, so that the service lookups don't get too expensive for deeply nested elements. But that is also something for another day.
src/main/java/org/openrewrite/staticanalysis/MethodNameCasing.java
Outdated
Show resolved
Hide resolved
MethodNameCasing
to work with C#
Also move checks to NamingService
String toName = service.standardizeMethodName(normalized); | ||
if (!StringUtils.isBlank(toName) && !StringUtils.isNumeric(toName) && | ||
!methodExists(method.getMethodType(), toName)) { |
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.
standardizeMethodName
is not guaranteed to give back a different method name; do we already have a test to check expecting no changes? Or should we add a comparison here between the old and new name?
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 already, but needs a rerun of the tests after this PR is merged:
What's changed?
Introduce interfacing and factory pattern to dynamically retrieve a
NamingConvention
to be applied for given sourcefileWhat's your motivation?
Introduction of C# as a supported language
Anyone you would like to review specifically?
@timtebeek @OlegDokuka @knutwannheden
Checklist