Skip to content

Add custom format to code gen for TupleExprElementListSyntax, FunctionParameterListSyntax, ArrayElementListSyntax and DictionaryElementListSyntax #1323

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 2 commits into from
Feb 7, 2023

Conversation

kimdv
Copy link
Contributor

@kimdv kimdv commented Feb 7, 2023

No description provided.

@kimdv kimdv requested a review from ahoppen as a code owner February 7, 2023 11:33
@kimdv kimdv force-pushed the kimdv/add-custom-format-to-code-gen branch from 7d5b5de to 09d60b3 Compare February 7, 2023 11:41
@kimdv kimdv changed the title Add custom format to code gen Add custom format to code gen for TupleExprElementListSyntax, FunctionParameterListSyntax, ArrayElementListSyntax and DictionaryElementListSyntax Feb 7, 2023
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.

Nice

@kimdv kimdv requested a review from ahoppen February 7, 2023 13:55
@kimdv kimdv force-pushed the kimdv/add-custom-format-to-code-gen branch from 09d60b3 to a94c34c Compare February 7, 2023 13:55
public override func visit(_ node: ArrayElementListSyntax) -> ArrayElementListSyntax {
let children = node.children(viewMode: .all)
// Short array literals are presented on one line, list each element on a different line.
if children.count > 2 {
Copy link
Member

Choose a reason for hiding this comment

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

One last question: Why did you choose 2 for arrays and dictionaries but 3 for function parameters? If there’s a reason, I’m totally fine with it, if it’s arbitrary I think it would be nice to keep them the same so the next person who looks at this doesn’t wonder why there’s a difference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it reads better. But I don't have strong options here.
I actually rather would make a newline for all arrays + dictionaries

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed all to 3 for now.

We can change later if we think it will improve the readability

Copy link
Member

Choose a reason for hiding this comment

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

I’m not saying I want 2 or 3. It’s totally fine to mix and match. I just wanted to make sure you deliberately chose those values if they are different.

@kimdv
Copy link
Contributor Author

kimdv commented Feb 7, 2023

@swift-ci please test

@kimdv kimdv force-pushed the kimdv/add-custom-format-to-code-gen branch from a94c34c to 59801d4 Compare February 7, 2023 14:10
@kimdv
Copy link
Contributor Author

kimdv commented Feb 7, 2023

@swift-ci please test

@kimdv
Copy link
Contributor Author

kimdv commented Feb 7, 2023

@swift-ci please test macOS

1 similar comment
@kimdv
Copy link
Contributor Author

kimdv commented Feb 7, 2023

@swift-ci please test macOS

@kimdv kimdv merged commit 7f83979 into swiftlang:main Feb 7, 2023
@kimdv kimdv deleted the kimdv/add-custom-format-to-code-gen branch February 7, 2023 19:56
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.

2 participants