-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Flatten chained conditionals. (#1489)
When testing the new formatter on a large corpus, I noticed the solver would get stuck on large conditional chains because (unfortunately), we can't separately format the else clause of a split conditional expression. By merging long conditional chains into a single InfixPiece, we can separately format all but the very last dangling else clause. While I was at it, I also put a hard cap in the number of solutions the solver will try in case it still gets stuck. The old formatter has a similar limit. It's rare for real-world code to hit this limit in the new solver, but it's better than getting totally stuck when it happens.
- Loading branch information
1 parent
ce04d38
commit 6641bde
Showing
10 changed files
with
171 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
void securityItem() { | ||
return SelectableText( | ||
itemSecurityScheme.securitySchemeType == SecuritySchemeType.QueryAPIKey | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.HeaderAPIKey || | ||
itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.CookieAPIKey | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.BasicHTTP | ||
? Constants.demoUsernameTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.BearerHTTP | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.DigestHTTP | ||
? Constants.digestDemoTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2PasswordFlow || | ||
itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2ClientFlow | ||
? Constants.emptyTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2ImplicitFlow | ||
? Constants.emptyTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2CodeFlow | ||
? Constants.emptyTxt | ||
: Constants.emptyTxt, | ||
); | ||
} |
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,32 @@ | ||
void securityItem() { | ||
return SelectableText( | ||
itemSecurityScheme.securitySchemeType == SecuritySchemeType.QueryAPIKey | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.HeaderAPIKey || | ||
itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.CookieAPIKey | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.BasicHTTP | ||
? Constants.demoUsernameTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.BearerHTTP | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.DigestHTTP | ||
? Constants.digestDemoTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2PasswordFlow || | ||
itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2ClientFlow | ||
? Constants.emptyTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2ImplicitFlow | ||
? Constants.emptyTxt | ||
: itemSecurityScheme.securitySchemeType == | ||
SecuritySchemeType.OAuth2CodeFlow | ||
? Constants.emptyTxt | ||
: Constants.emptyTxt, | ||
); | ||
} |
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,23 @@ | ||
void securityItem() { | ||
return SelectableText( | ||
itemSecurityScheme.securitySchemeType == SecuritySchemeType.QueryAPIKey | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.HeaderAPIKey || | ||
itemSecurityScheme.securitySchemeType == SecuritySchemeType.CookieAPIKey | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.BasicHTTP | ||
? Constants.demoUsernameTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.BearerHTTP | ||
? Constants.oneTwoThreeTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.DigestHTTP | ||
? Constants.digestDemoTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.OAuth2PasswordFlow || | ||
itemSecurityScheme.securitySchemeType == SecuritySchemeType.OAuth2ClientFlow | ||
? Constants.emptyTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.OAuth2ImplicitFlow | ||
? Constants.emptyTxt | ||
: itemSecurityScheme.securitySchemeType == SecuritySchemeType.OAuth2CodeFlow | ||
? Constants.emptyTxt | ||
: Constants.emptyTxt, | ||
); | ||
} |
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
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ class C { | |
_currentSunAngleDeg < 0 | ||
? 1 | ||
: _currentSunAngleDeg < 10 | ||
? 2 | ||
: 3; | ||
? 2 | ||
: 3; | ||
} |