public static async Task ComputeRefactoringsAsync(RefactoringContext context, SyntaxNode node)
        {
            if (context.IsAnyRefactoringEnabled(
                    RefactoringIdentifiers.WrapInRegion,
                    RefactoringIdentifiers.WrapInIfDirective))
            {
                SelectedLinesInfo info = await SelectedLinesRefactoring.GetSelectedLinesInfoAsync(context, node).ConfigureAwait(false);

                if (info?.IsAnySelected == true)
                {
                    if (context.IsRefactoringEnabled(RefactoringIdentifiers.WrapInRegion))
                    {
                        context.RegisterRefactoring(
                            "Wrap in region",
                            cancellationToken =>
                        {
                            var refactoring = new WrapInRegionRefactoring();

                            return(refactoring.RefactorAsync(context.Document, info, cancellationToken));
                        });
                    }

                    if (context.IsRefactoringEnabled(RefactoringIdentifiers.WrapInIfDirective))
                    {
                        context.RegisterRefactoring(
                            "Wrap in #if",
                            cancellationToken =>
                        {
                            var refactoring = new WrapInIfDirectiveRefactoring();

                            return(refactoring.RefactorAsync(context.Document, info, cancellationToken));
                        });
                    }
                }
            }

            if (context.IsRefactoringEnabled(RefactoringIdentifiers.RemoveEmptyLines) &&
                await RemoveEmptyLinesRefactoring.CanRefactorAsync(context, node).ConfigureAwait(false))
            {
                context.RegisterRefactoring(
                    "Remove empty lines",
                    cancellationToken =>
                {
                    return(RemoveEmptyLinesRefactoring.RefactorAsync(
                               context.Document,
                               node,
                               context.Span,
                               cancellationToken));
                });
            }
        }
        public async Task <Document> RefactorAsync(
            Document document,
            SelectedLinesInfo info,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);

            SourceText sourceText = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);

            ImmutableArray <TextChange> textChanges = GetTextChanges(info.SelectedLines());

            SourceText newSourceText = sourceText.WithChanges(textChanges);

            return(document.WithText(newSourceText));
        }