public static InitializerExpressionSyntax ToMultiLine(InitializerExpressionSyntax initializer, CancellationToken cancellationToken)
        {
            SyntaxNode parent = initializer.Parent;

            SyntaxTrivia endOfLine = DetermineEndOfLine(initializer);

            if (parent.IsKind(SyntaxKind.ObjectCreationExpression) &&
                !initializer.IsKind(SyntaxKind.CollectionInitializerExpression))
            {
                return(initializer
                       .WithExpressions(
                           SeparatedList(
                               initializer.Expressions.Select(expression => expression.WithLeadingTrivia(endOfLine)))));
            }
            else
            {
                IndentationAnalysis indentationAnalysis = AnalyzeIndentation(initializer, cancellationToken);

                SyntaxTriviaList braceTrivia      = TriviaList(endOfLine, indentationAnalysis.Indentation);
                SyntaxTriviaList expressionTrivia = TriviaList(endOfLine, indentationAnalysis.GetIncreasedIndentationTrivia());

                return(initializer
                       .WithExpressions(
                           SeparatedList(
                               initializer.Expressions.Select(expression => expression.WithLeadingTrivia(expressionTrivia))))
                       .WithOpenBraceToken(initializer.OpenBraceToken.WithLeadingTrivia(braceTrivia))
                       .WithCloseBraceToken(initializer.CloseBraceToken.WithLeadingTrivia(braceTrivia)));
            }
        }
        public static Task <Document> WrapCallChainAsync(
            Document document,
            ExpressionSyntax expression,
            SemanticModel semanticModel,
            CancellationToken cancellationToken = default)
        {
            IndentationAnalysis indentationAnalysis = AnalyzeIndentation(expression, cancellationToken);

            string indentation = Environment.NewLine + indentationAnalysis.GetIncreasedIndentation();

            TextChange?       textChange  = null;
            List <TextChange> textChanges = null;

            foreach (SyntaxNode node in new MethodChain(expression))
            {
                switch (node.Kind())
                {
                case SyntaxKind.SimpleMemberAccessExpression:
                {
                    var memberAccess = (MemberAccessExpressionSyntax)node;

                    if (memberAccess.Expression.IsKind(SyntaxKind.ThisExpression))
                    {
                        break;
                    }

                    if (semanticModel
                        .GetSymbol(memberAccess.Expression, cancellationToken)?
                        .Kind == SymbolKind.Namespace)
                    {
                        break;
                    }

                    AddTextChange(memberAccess.OperatorToken);
                    break;
                }

                case SyntaxKind.MemberBindingExpression:
                {
                    var memberBinding = (MemberBindingExpressionSyntax)node;

                    AddTextChange(memberBinding.OperatorToken);
                    break;
                }
                }
            }

            if (textChanges != null)
            {
                TextChange[] arr = textChanges.ToArray();
                Array.Reverse(arr);
                return(document.WithTextChangesAsync(arr, cancellationToken));
            }
            else
            {
                return(document.WithTextChangeAsync(textChange.Value, cancellationToken));
            }

            void AddTextChange(SyntaxToken operatorToken)
            {
                var tc = new TextChange(new TextSpan(operatorToken.SpanStart, 0), indentation);

                if (textChange == null)
                {
                    textChange = tc;
                }
                else
                {
                    (textChanges ??= new List <TextChange>()
                    {
                        textChange.Value
                    }).Add(tc);
                }
            }
        }