Skip to content

Commit

Permalink
Merge pull request #155 from belav/ispattern-breaking
Browse files Browse the repository at this point in the history
Breaking IsPattern better
  • Loading branch information
belav authored May 1, 2021
2 parents d8e1375 + 44e8dd9 commit 5a2d90e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class ClassName
}

if (
MethodKind is not (MethodKind.Ordinary
or MethodKind.LocalFunction)
MethodKind
is not (MethodKind.Ordinary
or MethodKind.LocalFunction)
) {
return;
}
Expand All @@ -32,10 +33,19 @@ class ClassName
}

var useLine =
node.OperatorToken.Kind() is SyntaxKind.BarBarToken
or SyntaxKind.BarToken
or SyntaxKind.AmpersandAmpersandToken
or SyntaxKind.AmpersandToken
or SyntaxKind.PlusToken;
node.OperatorToken.Kind()
is SyntaxKind.BarBarToken
or SyntaxKind.BarToken
or SyntaxKind.AmpersandAmpersandToken
or SyntaxKind.AmpersandToken
or SyntaxKind.PlusToken;

if (
Nullable.GetUnderlyingType111111111111111(typeof(T))
is Type innerType
&& innerType.IsEnum
) {
return;
}
}
}
14 changes: 7 additions & 7 deletions Src/CSharpier/Printer/IsPatternExpressionSyntax.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CSharpier.DocTypes;
using CSharpier.SyntaxPrinter;
using Microsoft.CodeAnalysis.CSharp.Syntax;

namespace CSharpier
Expand All @@ -9,13 +10,12 @@ private Doc PrintIsPatternExpressionSyntax(
IsPatternExpressionSyntax node
) {
return Doc.Concat(
this.Print(node.Expression),
" ",
this.PrintSyntaxToken(
node.IsKeyword,
afterTokenIfNoTrailing: " "
),
Doc.Indent(this.Print(node.Pattern))
Node.Print(node.Expression),
Doc.Indent(
Doc.Line,
Token.PrintWithSuffix(node.IsKeyword, " "),
Doc.Indent(this.Print(node.Pattern))
)
);
}
}
Expand Down

0 comments on commit 5a2d90e

Please sign in to comment.