-
Notifications
You must be signed in to change notification settings - Fork 7
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
Always emit fully qualified code from TemplateProcessor
#55
Conversation
`TemplateProcessor` now always emits fully qualified type, field and method references regardless of what the input Java code looks like. The idea being that then a `ShortenFullyQualifiedTypeReferences` will remove unnecessary full qualifications.
@timtebeek Whether we actually want this needs to be discussed. But this is in any case how I had imagined this to be working. Note that we no longer generate any I also haven't verified if this actually works correctly and whether the fully qualified references get shortened as expected. |
I like how you've pulled out Nice improvement not to have to use imports on templates, although I've not yet looked at the effect on the replacements we end up doing. I have a slight concern for cases like |
What worries me about templates that rely on imports (and static imports) is that we don't have anything to deal with conflict resolution. At the moment it would indeed be better to make the code generating the full I can amend this PR with that. |
@timtebeek I've refactored it to the point now, where a full |
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.
Looks good to me; thanks for doing this!
The |
Sounds good to me, although such a change in RefasterTemplateProcessor would also affect the TemplateProcessor right? As that currently operates on rewrite-templating/src/main/java/org/openrewrite/java/template/processor/TemplateProcessor.java Line 76 in 7516697
|
I don't think it would affect |
I can try to create a PR and then you can maybe tell me how I can easily test that against the error-prone-support code to make sure it still works correctly. |
Sure; the flow isn't very advanced, as we use Gradle whereas they use Maven, so what I ended up with is:
All in all that takes ~2 minutes or so; not too bad. |
TemplateProcessor
now always emits fully qualified type, field and method references regardless of what the input Java code looks like. The idea being that then aShortenFullyQualifiedTypeReferences
will remove unnecessary full qualifications.