Fix record field selector issues for nested record members #726
Fix record field selector issues for nested record members #726TharmiganK wants to merge 4 commits into1.7.xfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@TharmiganK , can you attach the issue that this PR addresses? |
Updated the PR description with the issue |
pasindufernando1
left a comment
There was a problem hiding this comment.
@TharmiganK You can get the latest changes from 1.7.x. The log version bump is already done and merged
Ack, merged with 1.7.x branch |
pasindufernando1
left a comment
There was a problem hiding this comment.
Shall we add test cases to cover the three bugs addressed here?
Description
Fixes: wso2/product-ballerina-integrator#2537
Fixes three bugs in the record field selector when working with nested record types:
refsfrom the source member were not being propagated, causing nested record field selector members to lose their type references.lineRangeon its referenced types, which caused the type update logic to treat them as existing types and skip generating text edits for newly selected nested record members. Introducing theisDependentTypeflag stripslineRangefrom those referenced types so new types are correctly written.resultAlbumOptionalizedTypeinstead of the expectedresultAlbumsType.Summary
This pull request addresses three bugs in the record field selector when processing nested record types:
Core Fixes
Reference Propagation for Nested Members: Modified the type merging logic to preserve references from source members when combining source and target record selector types. This ensures nested record field selector members retain their type references during the merge process.
Type Inference for New Nested Members: Introduced an
isDependentTypeparameter to thegetRecordSelectorTypemethod. When enabled, the parameter drops line-range information from dependent record types by removing location metadata. This prevents the type update logic from incorrectly treating newly selected nested members as existing types and ensures text edits are properly generated for new nested record definitions.Type Name Generation: Fixed the naming logic for generated nested record types to derive names from the field name rather than the referenced type name, producing correct output such as
resultAlbumsTypeinstead ofresultAlbumOptionalizedType.Implementation Changes
TypesManager.javato add theisDependentTypeparameter and implement the fixes for reference propagation and type name derivationCallBuilder.javato pass the appropriate boolean flag when invoking the modifiedgetRecordSelectorTypemethodDependency Updates