Skip to content

add a quick fix for curly_braces_in_flow_control_structures #37084

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

Closed
devoncarew opened this issue May 24, 2019 · 4 comments
Closed

add a quick fix for curly_braces_in_flow_control_structures #37084

devoncarew opened this issue May 24, 2019 · 4 comments
Assignees
Labels
devexp-quick-fix Issues with analysis server (quick) fixes legacy-area-analyzer Use area-devexp instead.

Comments

@devoncarew
Copy link
Member

The curly_braces_in_flow_control_structures lint is now enabled and reported in pedantic. It would be nice to have a quick fix for this, for places where it's clear how to fix.

@bwilkerson @pq @srawlins

@devoncarew devoncarew added legacy-area-analyzer Use area-devexp instead. devexp-quick-fix Issues with analysis server (quick) fixes labels May 24, 2019
@srawlins
Copy link
Member

Similar request: dart-lang/dart_style#664

@bwilkerson
Copy link
Member

@scheglov

We already have support for this, but I suspect that it's too hard to use. If a user selects one or more complete statements, when we have assists that will wrap those statements in a block or in any control structure. The part that makes this hard to use is that the complete statement must be selected.

For example, if a user has code like

main() {
  if (0 < 1) print('true');
}

and they select print('true'); (a whole statement), then the assists are produced, but if they select anything less than the whole statement, the assists are not produced.

I suspect that the reason we made that choice originally is because we don't have any mechanism by which we can communicate to users what code will be affected by the change if it's different than what they selected. I'm not sure that was a good choice. Given that they can always undo the change, perhaps we should allow selection of a partial statement.

What do other people think?

@pq
Copy link
Member

pq commented May 25, 2019

Given that they can always undo the change, perhaps we should allow selection of a partial statement.

+1. And in general as I've been hit by this elsewhere as well.

@scheglov scheglov self-assigned this May 25, 2019
@scheglov
Copy link
Contributor

https://dart-review.googlesource.com/c/sdk/+/103721

dart-bot pushed a commit that referenced this issue Jul 1, 2019
Quick assist for converting single line statements to blocks and
vice-versa is also sometimes useful, but separate.

[email protected], [email protected]

Bug: #37084
Change-Id: I9c6b2f7c063bc339a57d991e4d675b87e1910413
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103721
Reviewed-by: Brian Wilkerson <[email protected]>
Reviewed-by: Phil Quitslund <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
@scheglov scheglov closed this as completed Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-quick-fix Issues with analysis server (quick) fixes legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

5 participants