-
-
Notifications
You must be signed in to change notification settings - Fork 106
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
BinaryExpression Grouping #37
Comments
This is also related return value == null
|| string.IsNullOrEmpty(value.Trim());
// should be
return value == null
|| string.IsNullOrEmpty(value.Trim()); |
This was partially addressed in #84 but requires a lot more work |
this looks weird if (
trivia.Kind() == SyntaxKind.SingleLineCommentTrivia
|| trivia.Kind()
== SyntaxKind.SingleLineDocumentationCommentTrivia1111111
) { } |
See also protected override bool IsBinaryLike(ExpressionSyntax node) =>
node is BinaryExpressionSyntax
|| node
is IsPatternExpressionSyntax isPattern
&& isPattern.Pattern is ConstantPatternSyntax; |
Related while (
// stop if we have reached the end of the token being read
initialDepth - 1 <
reader.Depth - (JsonTokenUtils.IsEndToken(reader.TokenType) ? 1 : 0) &&
writeChildren &&
reader.Read()
); |
See also if (
query
&& (currentChar == '='
|| currentChar == '<'
|| currentChar == '!'
|| currentChar == '>'
|| currentChar == '|'
|| currentChar == '&')
) {
ended = true;
} The current alignment leads you to believe that the && and || operators are chained but they aren't really. We should do some kind of nesting here. |
This was referenced Jun 19, 2021
This was referenced Jul 11, 2021
Make sure to handle the test case in SwitchExpression that isn't indenting. |
This was referenced Jul 19, 2021
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Take this example
The && is the root BinaryExpression, which is a LogicalAnd
The left and right of it are EqualsExpression.
CSharpier should group the LogicalAnd, but if it groups every binary Expression than the following doesn't format correctly.
Which is basically a tree of BinaryExpressions where the Left is LogicalAnd BinaryExpression and the Right is IdentifierName.
This may require flattening out BinaryExpressions and conditionally grouping them based on what operation they are performing.
See prettier/src/language-js/print/binaryish.js for all the logic that goes into making this work for js
The text was updated successfully, but these errors were encountered: