-
Notifications
You must be signed in to change notification settings - Fork 439
adjust Indentation Of Freestanding Macro #2493
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
adjust Indentation Of Freestanding Macro #2493
Conversation
7c19b5b
to
32c6662
Compare
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 for fixing this @vinu-vanjari!
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.
Nice. Thanks for adding the comment.
@swift-ci Please test |
@swift-ci Please test |
Head branch was pushed to by a user without write access
@ahoppen, sorry I missed formatting in my latest commit. Just fixed it now. 🙏🏼 |
No worries, let’s try again. @swift-ci Please test |
Kindly help, I am not able to understand root cause of the CI failure. As per console logs,
but i am not sure if my changes affected |
The CI error is not related to your changes. It should be fix after merging this PR: swiftlang/swift-package-manager#7349 |
swiftlang/swift-package-manager#7350 instead of swiftlang/swift-package-manager#7349 should've fixed CI issues, as it clearly fixes the test build error for me locally. I'm currently investigating why the error persists on CI, as I hope we can avoid merging the revert and get this fixed properly. |
Oh, sorry for the misleading info, didn't go throw the new conversation in the PR since yesterday |
@swift-ci clean test |
Resolves #2473
Summary:
added private function
adjustIndentationOfFreestandingMacro
which extracts the same indentation logic as before, plus removes first line indentation if macro is in middle of any line. This is required as line indentation does not make sense if macro is not present at the beginning of the line.print(#function)
used to produceprint( "f(a:_:c:)")
with extra indentation after(
. Now it should produceprint("f(a:_:c:)")
corrected existing unit tests + added similar tests for multi line macro expansion so that we make sure indentation is correct on large macros as well even if they are used in middle of the line
Update:
adjustIndentationOfFreestandingMacro
adds appropriate indentation to expanded code. Then removes indentation of first line of expanded code (if any). Then adds exact same trivia as # macro, including it's original indentation.