-
Notifications
You must be signed in to change notification settings - Fork 356
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
Fix RenameVariable for variables referenced through type casts #4082
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Thanks for this @renegrob ! I've refactored your code a bit from this commit to what it is now, and added a unit test based on the example you shared. Would you mind giving it a look over before we merge? |
timtebeek
reviewed
Mar 7, 2024
timtebeek
approved these changes
Mar 7, 2024
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.
Thanks a lot!
motu55
pushed a commit
to motu55/rewrite
that referenced
this pull request
Mar 14, 2024
…ewrite#4082) * Fix RenameVariable for variables referenced through type casts * Add unit test * Be explicit about null handling and types --------- Co-authored-by: Tim te Beek <[email protected]>
sambsnyd
added a commit
that referenced
this pull request
Apr 1, 2024
…ti module maven projects (#4074) * fix find maven dependencies for multi module maven projects * revert to see if build is succesfull * Defensive copy in addClasspathEntry so that it won't attempt to add an element to a read-only list * Make `JavaParser.Builder#addClasspathEntry()` public * Basic JSP support (#4075) * Improve `UsesField` * Improve `UsesField` a bit more * Fix RenameVariable for variables referenced through type casts (#4082) * Fix RenameVariable for variables referenced through type casts * Add unit test * Be explicit about null handling and types --------- Co-authored-by: Tim te Beek <[email protected]> * Java version equality should not be based on id. Plugins create a JavaVersion per source set, but if they have the same fields excluding id they should be considered equal. * `MethodMatcher`: Improve construction time performance Avoid expensive regular expressions for simple and common cases. * `MethodMatcher`: Optimize performance of common argument matching * `XPathMatcher`: Implement attribute value conditions like `/a[@b='c']` (#4084) Fixes: #4083 * Fix class cast exception in MarkIndividualDependency * Add table and version matcher to Maven FindProperties (#4085) The valuePattern allows use as DevCenter measurement, while the table enables custom visualizations. Target use is the `<jenkins.version>` used in Jenkins plugins. * ensuring connection timeouts get wrapped by MavenDownloadingException (#4081) * ensuring connection timeouts get wrapped by MavenDownloadingException * polish * removed a condition which I believe no longer made sense, and was causing tests to fail with latest changes * Apply suggestions from code review * adjusting so that IOExceptions can get caught and wrapped into MavenDownloadingException * clarifying checked exception types for `sendRequest` and related methods --------- Co-authored-by: Tim te Beek <[email protected]> * HasMiniumJavaVersion * Remove explicit `Properties.File#getContent()` method While indeed the LST should not be modified by modifying a `List` returned by a getter, it is also not right for a getter to return a new list every time (e.g. by wrapping an internal field using `Collections.unmodifiableList()`. This commit removes the explicit getter and wither and instead has these generated by Lombok. Further, the initial contents, as populated by the parser, are now wrapped using `Collections.unmodifiableList()` to avoid any situations, where the contents are directly modified. * Add dependency now works with empty maven projects (#4006) * Printable Recipe Datatables (#4087) * Added method to export datatable information as csv to RecipeRun class * Wrapped column value in quotes to escape commas in value * Refactored streams to iterative loops. Log exceptions through Execution Context error handler * Added formatCsv method. Added logic to ensure directories exist before creating files * Refactored export logic to be more testable. Added test for csv printing logic * Failing test cases for Quarkus version matching using `metadataPattern`s * Add another test case. * Get the new tests passing * License headers * Optimize `JavaParser.Builder#addClasspathEntry()` * Allow null argument to CommitMessage.message() * Fix precondition application in UpgradeDependencyVersion. I'm a bit confused as to how this recipe succeeded before I made this change. The whole visitor, not just the precondition, was wrapped in Preconditions.or(). * Refresh resolved dependencies if possible --------- Co-authored-by: U808771 <[email protected]> Co-authored-by: Sam Snyder <[email protected]> Co-authored-by: Knut Wannheden <[email protected]> Co-authored-by: Jonathan Schnéider <[email protected]> Co-authored-by: René Grob <[email protected]> Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Nick McKinney <[email protected]> Co-authored-by: Adriano Machado <[email protected]> Co-authored-by: Ryan Hudson <[email protected]>
sambsnyd
added a commit
that referenced
this pull request
Apr 29, 2024
…ti module maven projects (#4074) * fix find maven dependencies for multi module maven projects * revert to see if build is succesfull * Defensive copy in addClasspathEntry so that it won't attempt to add an element to a read-only list * Make `JavaParser.Builder#addClasspathEntry()` public * Basic JSP support (#4075) * Improve `UsesField` * Improve `UsesField` a bit more * Fix RenameVariable for variables referenced through type casts (#4082) * Fix RenameVariable for variables referenced through type casts * Add unit test * Be explicit about null handling and types --------- Co-authored-by: Tim te Beek <[email protected]> * Java version equality should not be based on id. Plugins create a JavaVersion per source set, but if they have the same fields excluding id they should be considered equal. * `MethodMatcher`: Improve construction time performance Avoid expensive regular expressions for simple and common cases. * `MethodMatcher`: Optimize performance of common argument matching * `XPathMatcher`: Implement attribute value conditions like `/a[@b='c']` (#4084) Fixes: #4083 * Fix class cast exception in MarkIndividualDependency * Add table and version matcher to Maven FindProperties (#4085) The valuePattern allows use as DevCenter measurement, while the table enables custom visualizations. Target use is the `<jenkins.version>` used in Jenkins plugins. * ensuring connection timeouts get wrapped by MavenDownloadingException (#4081) * ensuring connection timeouts get wrapped by MavenDownloadingException * polish * removed a condition which I believe no longer made sense, and was causing tests to fail with latest changes * Apply suggestions from code review * adjusting so that IOExceptions can get caught and wrapped into MavenDownloadingException * clarifying checked exception types for `sendRequest` and related methods --------- Co-authored-by: Tim te Beek <[email protected]> * HasMiniumJavaVersion * Remove explicit `Properties.File#getContent()` method While indeed the LST should not be modified by modifying a `List` returned by a getter, it is also not right for a getter to return a new list every time (e.g. by wrapping an internal field using `Collections.unmodifiableList()`. This commit removes the explicit getter and wither and instead has these generated by Lombok. Further, the initial contents, as populated by the parser, are now wrapped using `Collections.unmodifiableList()` to avoid any situations, where the contents are directly modified. * Add dependency now works with empty maven projects (#4006) * Printable Recipe Datatables (#4087) * Added method to export datatable information as csv to RecipeRun class * Wrapped column value in quotes to escape commas in value * Refactored streams to iterative loops. Log exceptions through Execution Context error handler * Added formatCsv method. Added logic to ensure directories exist before creating files * Refactored export logic to be more testable. Added test for csv printing logic * Failing test cases for Quarkus version matching using `metadataPattern`s * Add another test case. * Get the new tests passing * License headers * Optimize `JavaParser.Builder#addClasspathEntry()` * Allow null argument to CommitMessage.message() * Fix precondition application in UpgradeDependencyVersion. I'm a bit confused as to how this recipe succeeded before I made this change. The whole visitor, not just the precondition, was wrapped in Preconditions.or(). * Refresh resolved dependencies if possible --------- Co-authored-by: U808771 <[email protected]> Co-authored-by: Sam Snyder <[email protected]> Co-authored-by: Knut Wannheden <[email protected]> Co-authored-by: Jonathan Schnéider <[email protected]> Co-authored-by: René Grob <[email protected]> Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Nick McKinney <[email protected]> Co-authored-by: Adriano Machado <[email protected]> Co-authored-by: Ryan Hudson <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's changed?
TypeCasts and nested FiedAccess are now supported when renaming variables
What's your motivation?
Fix issue #4059
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
@timtebeek
Have you considered any alternatives or workarounds?
Any additional context
Checklist