Skip to content
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

Do not indent switch when used in beginControlFlow #11

Closed
JakeWharton opened this issue Jul 24, 2020 · 2 comments · Fixed by #22
Closed

Do not indent switch when used in beginControlFlow #11

JakeWharton opened this issue Jul 24, 2020 · 2 comments · Fixed by #22
Labels
enhancement New feature or request
Milestone

Comments

@JakeWharton
Copy link
Contributor

If the string starts with "switch " then do not automatically indent. Downside: we would have to maintain a boolean stack of calls to beginControlFlow such that on symmetric calls to nextControlFlow/endControlFlow know whether or not to unindent. As a result, this may not be worth doing! And that's fine.

This syntactical formatting oddity offends me, but apparently it's idiomatic. I just ported all my use of beginControlFlow for switch to addCode. I'm perfectly fine leaving it like that, but figured I'd file and see what others thought.

@kdubb kdubb added the enhancement New feature or request label Aug 19, 2020
@kdubb
Copy link
Contributor

kdubb commented Aug 19, 2020

Why not add a beginSwitch/endSwitch pair?

Alternatively we can make the control statement explicit in beginControlFlow/endControlFlow.

For example...

codeBlock.beginControlFlow("switch", code);
// generate cases
codeBlock.endControlFlow("switch")

In either case, I'm assuming you probably know your ending a switch when calling endControlFlow and nextControlFlow is irrelevant for switch.

@kdubb
Copy link
Contributor

kdubb commented Aug 19, 2020

The second option (adding an explicit control statement name) essentially just pushes the idea of keeping a state stack onto the caller, which seems like a good idea since the calling code is probably structured in that way already,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants