Exemple #1
0
        private static void Write(
            ExpressionSyntax expression,
            ExpressionSyntax nextExpression,
            SyntaxToken token,
            string newText,
            NodeWriter writer)
        {
            if (IsFixable(expression, token))
            {
                if (expression.GetTrailingTrivia().Any(f => !f.IsWhitespaceOrEndOfLineTrivia()) ||
                    token.LeadingTrivia.Any(f => !f.IsWhitespaceOrEndOfLineTrivia()))
                {
                    writer.WriteTrailingTrivia(expression);
                    writer.WriteLeadingTrivia(token);
                }

                writer.WriteTrailingTrivia(token);
                writer.WriteLeadingTrivia(nextExpression);
                writer.Write(newText);
                writer.WriteSpan(nextExpression);
            }
            else
            {
                writer.WriteTrailingTrivia(expression);
                writer.WriteFullSpan(token);
                writer.WriteLeadingTriviaAndSpan(nextExpression);
            }
        }