public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
        {
            SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken);

            IfStatementSyntax ifStatement = root
                                            .FindNode(context.Span, getInnermostNodeForTie: true)?
                                            .FirstAncestorOrSelf <IfStatementSyntax>();

            if (ifStatement == null)
            {
                return;
            }

            AddBracesToIfElseChain(context, ifStatement);

            if (ifStatement.Condition != null &&
                ifStatement.Condition.Span.Contains(context.Span) &&
                context.Document.SupportsSemanticModel)
            {
                SemanticModel semanticModel = await context.Document.GetSemanticModelAsync(context.CancellationToken);

                AddBooleanComparisonRefactoring.Refactor(ifStatement.Condition, context, semanticModel);
            }

            FormatBinaryExpressionRefactoring.Refactor(context, ifStatement);

            SwapStatements(context, ifStatement);
        }
        public override async Task ComputeRefactoringsAsync(CodeRefactoringContext context)
        {
            SyntaxNode root = await context.Document.GetSyntaxRootAsync(context.CancellationToken);

            BinaryExpressionSyntax binaryExpression = root
                                                      .FindNode(context.Span, getInnermostNodeForTie: true)?
                                                      .FirstAncestorOrSelf <BinaryExpressionSyntax>();

            if (binaryExpression == null)
            {
                return;
            }

            if (binaryExpression.IsAnyKind(SyntaxKind.LogicalAndExpression, SyntaxKind.LogicalOrExpression) &&
                binaryExpression.Left?.IsMissing == false &&
                binaryExpression.Right?.IsMissing == false)
            {
                if (context.Document.SupportsSemanticModel)
                {
                    SemanticModel semanticModel = null;

                    if (binaryExpression.Left.Span.Contains(context.Span))
                    {
                        if (semanticModel == null)
                        {
                            semanticModel = await context.Document.GetSemanticModelAsync(context.CancellationToken);
                        }

                        AddBooleanComparisonRefactoring.Refactor(binaryExpression.Left, context, semanticModel);
                    }
                    else if (binaryExpression.Right.Span.Contains(context.Span))
                    {
                        if (semanticModel == null)
                        {
                            semanticModel = await context.Document.GetSemanticModelAsync(context.CancellationToken);
                        }

                        AddBooleanComparisonRefactoring.Refactor(binaryExpression.Right, context, semanticModel);
                    }
                }

                context.RegisterRefactoring(
                    "Negate binary expression",
                    cancellationToken =>
                {
                    return(NegateBinaryExpressionAsync(
                               context.Document,
                               GetTopmostExpression(binaryExpression),
                               cancellationToken));
                });
            }

            if (binaryExpression.OperatorToken.Span.Contains(context.Span) &&
                ExpandCoalesceExpressionRefactoring.CanRefactor(binaryExpression))
            {
                context.RegisterRefactoring(
                    "Expand coalesce expression",
                    cancellationToken =>
                {
                    return(ExpandCoalesceExpressionRefactoring.RefactorAsync(
                               context.Document,
                               binaryExpression,
                               cancellationToken));
                });
            }

            SwapExpressionsRefactoring.Refactor(context, binaryExpression);
        }