Issue3365#4956
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #4956 +/- ##
===============================================
+ Coverage 58.574% 58.637% +0.063%
Complexity 2564 2564
===============================================
Files 696 699 +3
Lines 39980 40121 +141
Branches 7274 7314 +40
===============================================
+ Hits 23418 23526 +108
- Misses 13611 13628 +17
- Partials 2951 2967 +16
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or 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
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.
Fixes #3365 .
Problem
When replacing a type name in nested generics like Set<Pair<String, String>>, the LexicalPreservingPrinter fails to apply the change. The original type name remains in the output instead of the new one.
Root Cause
The printer updates the wrong part of the code tree. It regenerates the immediate parent of the changed type, but the formatting information is actually stored at a higher level (the entire variable declaration). This mismatch causes the change to be ignored.
Solution
Before regenerating code, the system now identifies which part of the tree actually owns the formatting information for the changed element. If this owner differs from the immediate parent, it regenerates the owner instead. This ensures changes are properly reflected in the output.
Detail
Implements TokenOwnerDetector to correctly identify which AST node owns
tokens during replacements. Previously, LPP assigned tokens by position,
causing nested types like Set<Pair<String, String>> to fail updates.
Changes:
The fix uses a non-invasive approach: only affects node replacements,
preserves existing behavior for 80% of cases, enables future root cause
fix by serving as specification for correct token assignment.