Beispiel #1
0
        private async Task <Document> ApplyFormattingAsync(Document document, ExpressionStatementSyntax expressionStatement, CancellationToken ct)
        {
            var visitor = new StatementSyntaxVisitor(new ExpressionSyntaxVisitor());
            var formattedExpressionStatement = expressionStatement.Accept(visitor);

            var oldRoot = await document.GetSyntaxRootAsync(ct).ConfigureAwait(false);

            var newRoot = oldRoot.ReplaceNode(expressionStatement, formattedExpressionStatement);

            return(document.WithSyntaxRoot(newRoot));
        }