Preserve leading comments when converting functions to computed propetries #3236#3238
Preserve leading comments when converting functions to computed propetries #3236#3238vishakha1411 wants to merge 3 commits intoswiftlang:mainfrom
Conversation
|
I have added test cases and checked them without my change as suggested. I ran them both with and without my changes, and they passed in both cases. |
ahoppen
left a comment
There was a problem hiding this comment.
Could you please format your source code using swift-format as described in CONTRIBUTING.md?
| ) | ||
|
|
||
| let bindingSpecifier = syntax.funcKeyword.detached.with(\.tokenKind, .keyword(.var)) | ||
| let bindingSpecifier = syntax.funcKeyword.detached.with(\.tokenKind, .keyword(.var)).with(\.leadingTrivia, syntax.funcKeyword.leadingTrivia).with(\.trailingTrivia, syntax.funcKeyword.trailingTrivia) |
There was a problem hiding this comment.
Actually, I would expect just changing the token kind to retain the trivia? Could you double-check if the new tests already pass without your changes, in which case the issue already behaves correctly and I just saw the bug due to an old checkout of swift-syntax?
There was a problem hiding this comment.
Yes the new tests pass on current main even without my changes so the issue already behaves correctly. I can remove the unnecessary code is preferred.
Fixes #3236.
Fixes an issue where documentation comments were dropped when converting zero-parameter functions to computed properties. The refactor now preserves leading comments during conversion. Tested locally. Please let me know if any changes needed or test cases need to be added.