Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,62 @@ private static List<Doc> PrintBinaryExpression(SyntaxNode node, PrintingContext
var binaryOnTheRight = binaryExpressionSyntax.Kind() == SyntaxKind.CoalesceExpression;
if (binaryOnTheRight)
{
docs.Add(
Node.Print(binaryExpressionSyntax.Left, context),
Doc.Line,
Token.Print(binaryExpressionSyntax.OperatorToken, context),
" "
);
var chain = 0;
var possibleInvocation = binaryExpressionSyntax.Left;
while (possibleInvocation is not null)
{
if (possibleInvocation is InvocationExpressionSyntax invocationExpression)
{
possibleInvocation = invocationExpression.Expression;
chain++;
}
else if (
possibleInvocation
is MemberAccessExpressionSyntax memberAccessExpressionSyntax
)
{
possibleInvocation = memberAccessExpressionSyntax.Expression;
chain++;
}
else if (
possibleInvocation
is ConditionalAccessExpressionSyntax conditionalAccessExpressionSyntax
)
{
possibleInvocation = conditionalAccessExpressionSyntax.Expression;
chain++;
}
else if (
possibleInvocation
is ElementAccessExpressionSyntax elementAccessExpressionSyntax
)
{
possibleInvocation = elementAccessExpressionSyntax.Expression;
chain++;
}
else
{
possibleInvocation = null;
}
}
var leftDoc = Node.Print(binaryExpressionSyntax.Left, context);
if (chain > 3)
{
docs.Add(
Doc.Group(leftDoc, Doc.Line),
Token.Print(binaryExpressionSyntax.OperatorToken, context),
" "
);
}
else
{
docs.Add(
leftDoc,
Doc.Line,
Token.Print(binaryExpressionSyntax.OperatorToken, context),
" "
);
}
}

var possibleBinary = binaryOnTheRight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,31 @@ class TestClass
someLongValue__________________________________________
) ?? someOtherValue;

var x =
someValue
.Property.CallLongMethod_____________________________________()
.CallMethod__________()
?? throw new Exception();

var x =
someValue
.Property.CallLongMethod_____________________________________()
.CallLongMethod___________________________________________________()
?? throw new Exception();

return SomeObject.CallSomeMethod___________()
?? SomeObject.CallSomeMethod___________()
?? new SomeObject();

var storeObject =
entityType.GetSchemaQualifiedTableName()
?? entityType.GetInsertStoredProcedure()?.GetSchemaQualifiedName()
?? entityType.GetDeleteStoredProcedure()?.GetSchemaQualifiedName()
?? entityType.GetUpdateStoredProcedure()?.GetSchemaQualifiedName();

return parameterDescriptor.BindingInfo.Binder
?? Binders.GetBinder(parameterDescriptor.ParameterType);

var notIdealSee355 =
variable
.Replace(someParameter_______________________, '.')
Expand Down
Loading