-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve how expressions in control flow headers are handled. (#1326)
Improve how parenthesized expressions in control flow are handled. In the process of writing tests for if statements, I realized that the way if conditions are formatted was different than switch values. And it turns out that, based on looking at how all of the control flow in Flutter is hand-formatted, the way I was handling switches was more complex than needed. It seems like the right behavior we want is to just visit the expression directly and let the parentheses attach directly to it. So I updated if, while, and switch to all do that. Also added tests for comments in if statements.
- Loading branch information
1 parent
967d15e
commit a8ab052
Showing
7 changed files
with
141 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
40 columns | | ||
>>> Line comment after `if`. | ||
if // comment | ||
(c) { body; } | ||
<<< | ||
if // comment | ||
(c) { | ||
body; | ||
} | ||
>>> Line comment before condition. | ||
if (// comment | ||
c) { body; } | ||
<<< | ||
if ( // comment | ||
c) { | ||
body; | ||
} | ||
>>> Line comment after condition. | ||
if (c // comment | ||
){ body; } | ||
<<< | ||
if (c // comment | ||
) { | ||
body; | ||
} | ||
>>> Line comment after `)`. | ||
if (c) // comment | ||
{ body; } | ||
<<< | ||
if (c) // comment | ||
{ | ||
body; | ||
} | ||
>>> Line comment after body. | ||
if (c) | ||
{ body; } // comment | ||
<<< | ||
if (c) { | ||
body; | ||
} // comment | ||
>>> Line comment before `else`. | ||
if (c) { body; } // comment | ||
else { other; } | ||
<<< | ||
if (c) { | ||
body; | ||
} // comment | ||
else { | ||
other; | ||
} | ||
>>> Line comment after `else`. | ||
if (c) { body; } else// comment | ||
{ other; } | ||
<<< | ||
if (c) { | ||
body; | ||
} else // comment | ||
{ | ||
other; | ||
} | ||
>>> Line comment after `else` body. | ||
if (c) { body; } else { other; }// comment | ||
<<< | ||
if (c) { | ||
body; | ||
} else { | ||
other; | ||
} // comment | ||
>>> Line comments in logic condition. | ||
if (// Do stuff. | ||
condition1 || | ||
// More stuff. | ||
condition2) { body; } | ||
<<< | ||
if ( // Do stuff. | ||
condition1 || | ||
// More stuff. | ||
condition2) { | ||
body; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters