Skip to content

Fix spacing around <, >, *, ! and ? #1164

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

Merged
merged 8 commits into from
Jan 11, 2023
Merged

Conversation

kimdv
Copy link
Contributor

@kimdv kimdv commented Dec 21, 2022

This fixes so we don't get var newLayout: ContiguousArray < RawSyntax ? > ?when doing VariableDecl("var newLayout: ContiguousArray<RawSyntax?>?").

If you can think of other test cases that I nee to add, to ensure we have expected behaviour different places feel free to comment then.

this PR also fixes #853

@kimdv kimdv requested a review from ahoppen as a code owner December 21, 2022 09:22
@kimdv kimdv force-pushed the kimdv/fix-spacing branch from eace5a9 to 2928570 Compare December 21, 2022 09:48
@kimdv
Copy link
Contributor Author

kimdv commented Dec 21, 2022

@swift-ci please test

@kimdv kimdv mentioned this pull request Dec 21, 2022
3 tasks
@kimdv kimdv changed the title Fix spacing around angles Fix spacing around < and >s Dec 25, 2022
@kimdv kimdv changed the title Fix spacing around < and >s Fix spacing around < and > and * Dec 25, 2022
@kimdv kimdv force-pushed the kimdv/fix-spacing branch from 36dc856 to 6656208 Compare December 25, 2022 14:53
@kimdv kimdv changed the title Fix spacing around < and > and * Fix spacing around <, >, *, ! and ? Dec 25, 2022
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve got a few test cases that I think would be interesting and suspect that some of them will break with your changes 😬 Sorry.

  • myOptional!.someProperty
  • lhs < rhs
  • lhs > rhs
  • (lhs1, lhs2) < (rhs1, rhs2)
  • MyGeneric<String>! (an implicitly unwrapped generic type)
  • !(true)

If you want to fix the formatting of < in generics, I think it might need to be explicitly done inside the generic parameter clause. I don’t think we’ve got any precedence for that though.

@kimdv kimdv force-pushed the kimdv/fix-spacing branch from c64b8c7 to 4922721 Compare January 4, 2023 08:09
@kimdv
Copy link
Contributor Author

kimdv commented Jan 4, 2023

Add test cases for

  • myOptional!.someProperty
  • lhs < rhs
  • lhs > rhs
  • (lhs1, lhs2) < (rhs1, rhs2)
  • MyGeneric<String>! (an implicitly unwrapped generic type)
  • !(true)

@kimdv kimdv force-pushed the kimdv/fix-spacing branch from 4922721 to e7abba8 Compare January 4, 2023 20:48
@kimdv
Copy link
Contributor Author

kimdv commented Jan 4, 2023

@ahoppen I've added tests cases with the examples you suggested. It seems to work. 😬
If needed I can try to run code gen with the latest commit, and see what it changes and open a PR so we can see it?

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I’ve got some more thoughts inline. I hope that we can converge on a solution soon.

@kimdv kimdv force-pushed the kimdv/fix-spacing branch 3 times, most recently from 17081bb to 4e025d2 Compare January 6, 2023 17:55
@kimdv kimdv force-pushed the kimdv/fix-spacing branch from 4e025d2 to 8b022d3 Compare January 9, 2023 08:32
Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment that a few of the special cases regarding angle brackets are superfluous now, otherwise LGTM.

@kimdv kimdv force-pushed the kimdv/fix-spacing branch from 8b022d3 to b32e5e2 Compare January 10, 2023 20:53
@kimdv kimdv force-pushed the kimdv/fix-spacing branch from b32e5e2 to a3ef115 Compare January 10, 2023 20:59
@kimdv
Copy link
Contributor Author

kimdv commented Jan 10, 2023

@swift-ci please test

Comment on lines +165 to +166
(.postfixQuestionMark, .rightAngle), // Ensures there is not space in `ContiguousArray<RawSyntax?>`
(.postfixQuestionMark, .rightParen), // Ensures there is not space in `myOptionalClosure?()`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those are also no longer necessary

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see they are necessary to remove the trailing space on postfixQuestionMark

@kimdv kimdv merged commit 8936b6e into swiftlang:main Jan 11, 2023
@kimdv kimdv deleted the kimdv/fix-spacing branch February 6, 2023 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TryExpr with questionOrExclamationMark does not build correct syntax.
2 participants