-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
Improve formatting of pattern matching (IsPatternExpression, BinaryPattern, etc) #154
Comments
See also if (
MethodKind
is not (MethodKind.Ordinary
or MethodKind.LocalFunction)
) {
return;
} Which could break like this and still be below the print width if (
MethodKind
is not (MethodKind.Ordinary or MethodKind.LocalFunction)
) {
return;
} |
I believe we want to treat BinaryPatterns more like BinaryExpressions. That requires flattening out the patterns into an array, and then grouping them. |
This doesn't look like valid syntax to me. Maybe I'm missing something. |
It is using pattern matching, I think some of this wasn't introduced until c# 9 |
BinaryPatterns are essentially the same as a BinaryExpression and should be printed the same. See #37, possibly do this at the same time. Mixed example if (
nestedExpression.Children[j]
is IntermediateToken cSharpToken && cSharpToken.IsCSharp
) { }
// should be
if (
nestedExpression.Children[j]
is IntermediateToken cSharpToken
&& cSharpToken.IsCSharp
) { } |
Another edge case if (
!(node
is PrefixUnaryExpressionSyntax { Operand: ParenthesizedExpressionSyntax { Expression: IsPatternExpressionSyntax { Pattern: DeclarationPatternSyntax, } isPattern, }, } notExpression)
) {
return;
} |
Probably related return rightNode switch
{
InitializerExpressionSyntax => Layout.BasicConcatWithoutLine,
ConditionalExpressionSyntax { Condition: BinaryExpressionSyntax }
or BinaryExpressionSyntax
or InterpolatedStringExpressionSyntax
or IsPatternExpressionSyntax
or LiteralExpressionSyntax
or QueryExpressionSyntax
or StackAllocArrayCreationExpressionSyntax
or ImplicitObjectCreationExpressionSyntax
=> Layout.BreakAfterOperator,
_ => Layout.Fluid
}; |
* Getting pattern matching formatting straightened out. closes #154 * Fixing case with empty property pattern * Fixing edge case with long is pattern * Format is parenthesizes the same as binary parenthesizes Co-authored-by: Lasath Fernando <devel@lasath.org>
Should IsPatterns break like this?
They currently break like
The text was updated successfully, but these errors were encountered: