Beispiel #1
0
        protected TStatement AddNestedIf(
            TStatement statement,
            BinaryExpressionSelection binaryExpressionSelection)
        {
            ExpressionSyntax expression = ParseExpression(binaryExpressionSelection.ToString());

            return(AddNestedIf(statement, expression));
        }
        public Task <Document> RefactorAsync(
            Document document,
            IfStatementSyntax ifStatement,
            BinaryExpressionSyntax condition,
            BinaryExpressionSelection binaryExpressionSelection,
            CancellationToken cancellationToken)
        {
            IfStatementSyntax newNode = RemoveExpressionsFromCondition(ifStatement, condition, binaryExpressionSelection);

            ExpressionSyntax expression = SyntaxFactory.ParseExpression(binaryExpressionSelection.ToString());

            newNode = AddNestedIf(newNode, expression)
                      .WithFormatterAnnotation();

            return(document.ReplaceNodeAsync(ifStatement, newNode, cancellationToken));
        }
Beispiel #3
0
        public Task <Document> RefactorAsync(
            Document document,
            StatementsInfo statementsInfo,
            BinaryExpressionSyntax condition,
            BinaryExpressionSelection binaryExpressionSelection,
            CancellationToken cancellationToken)
        {
            var ifStatement = (IfStatementSyntax)condition.Parent;

            IfStatementSyntax newIfStatement = RemoveExpressionsFromCondition(ifStatement, condition, binaryExpressionSelection)
                                               .WithFormatterAnnotation();

            ExpressionSyntax expression = SyntaxFactory.ParseExpression(binaryExpressionSelection.ToString());

            SyntaxNode newNode = AddNextIf(statementsInfo, ifStatement, newIfStatement, expression);

            return(document.ReplaceNodeAsync(statementsInfo.Node, newNode, cancellationToken));
        }