private IEnumerable <SuggestedActionSet> GetRefactorings(
                IDocumentSupportsSuggestionService supportSuggestion,
                ISuggestedActionCategorySet requestedActionCategories,
                Workspace workspace,
                Document document,
                SnapshotSpan range,
                CancellationToken cancellationToken)
            {
                var optionService = workspace.Services.GetService <IOptionService>();

                if (optionService.GetOption(EditorComponentOnOffOptions.CodeRefactorings) &&
                    _owner._codeRefactoringService != null &&
                    supportSuggestion.SupportsRefactorings(document) &&
                    requestedActionCategories.Contains(PredefinedSuggestedActionCategoryNames.Refactoring))
                {
                    // Get the selection while on the UI thread.
                    var selection = TryGetCodeRefactoringSelection(_subjectBuffer, _textView, range);
                    if (!selection.HasValue)
                    {
                        // this is here to fail test and see why it is failed.
                        Trace.WriteLine("given range is not current");
                        return(null);
                    }

                    var refactorings = Task.Run(
                        async() => await _owner._codeRefactoringService.GetRefactoringsAsync(
                            document, selection.Value, cancellationToken).ConfigureAwait(false),
                        cancellationToken).WaitAndGetResult(cancellationToken);

                    return(refactorings.Select(r => OrganizeRefactorings(workspace, r)));
                }

                return(null);
            }
            private async Task <bool> HasRefactoringsAsync(
                IDocumentSupportsSuggestionService supportSuggestion,
                ISuggestedActionCategorySet requestedActionCategories,
                SuggestedActionsSourceProvider provider,
                Document document,
                ITextBuffer buffer,
                ITextView view,
                SnapshotSpan range,
                CancellationToken cancellationToken)
            {
                var optionService = document.Project.Solution.Workspace.Services.GetService <IOptionService>();

                if (optionService.GetOption(EditorComponentOnOffOptions.CodeRefactorings) &&
                    provider._codeRefactoringService != null &&
                    supportSuggestion.SupportsRefactorings(document) &&
                    requestedActionCategories.Contains(PredefinedSuggestedActionCategoryNames.Refactoring))
                {
                    TextSpan?selection = null;
                    if (IsForeground())
                    {
                        // This operation needs to happen on UI thread because it needs to access textView.Selection.
                        selection = TryGetCodeRefactoringSelection(buffer, view, range);
                    }
                    else
                    {
                        await InvokeBelowInputPriority(() =>
                        {
                            // This operation needs to happen on UI thread because it needs to access textView.Selection.
                            selection = TryGetCodeRefactoringSelection(buffer, view, range);
                        }).ConfigureAwait(false);
                    }

                    if (!selection.HasValue)
                    {
                        // this is here to fail test and see why it is failed.
                        Trace.WriteLine("given range is not current");
                        return(false);
                    }

                    return(await Task.Run(
                               async() => await provider._codeRefactoringService.HasRefactoringsAsync(
                                   document, selection.Value, cancellationToken).ConfigureAwait(false),
                               cancellationToken).ConfigureAwait(false));
                }

                return(false);
            }
            private async Task<bool> HasRefactoringsAsync(
                IDocumentSupportsSuggestionService supportSuggestion,
                ISuggestedActionCategorySet requestedActionCategories,
                SuggestedActionsSourceProvider provider,
                Document document,
                ITextBuffer buffer,
                ITextView view,
                SnapshotSpan range,
                CancellationToken cancellationToken)
            {
                var optionService = document.Project.Solution.Workspace.Services.GetService<IOptionService>();

                if (optionService.GetOption(EditorComponentOnOffOptions.CodeRefactorings) &&
                    provider._codeRefactoringService != null &&
                    supportSuggestion.SupportsRefactorings(document) &&
                    requestedActionCategories.Contains(PredefinedSuggestedActionCategoryNames.Refactoring))
                {
                    TextSpan? selection = null;
                    if (IsForeground())
                    {
                        // This operation needs to happen on UI thread because it needs to access textView.Selection.
                        selection = TryGetCodeRefactoringSelection(buffer, view, range);
                    }
                    else
                    {
                        await InvokeBelowInputPriority(() =>
                        {
                            // This operation needs to happen on UI thread because it needs to access textView.Selection.
                            selection = TryGetCodeRefactoringSelection(buffer, view, range);
                        }).ConfigureAwait(false);
                    }

                    if (!selection.HasValue)
                    {
                        // this is here to fail test and see why it is failed.
                        Trace.WriteLine("given range is not current");
                        return false;
                    }

                    return await Task.Run(
                        async () => await provider._codeRefactoringService.HasRefactoringsAsync(
                            document, selection.Value, cancellationToken).ConfigureAwait(false),
                        cancellationToken).ConfigureAwait(false);
                }

                return false;
            }
            private IEnumerable<SuggestedActionSet> GetRefactorings(
                IDocumentSupportsSuggestionService supportSuggestion,
                ISuggestedActionCategorySet requestedActionCategories,
                Workspace workspace,
                Document document,
                SnapshotSpan range,
                CancellationToken cancellationToken)
            {
                var optionService = workspace.Services.GetService<IOptionService>();

                if (optionService.GetOption(EditorComponentOnOffOptions.CodeRefactorings) &&
                    _owner._codeRefactoringService != null &&
                    supportSuggestion.SupportsRefactorings(document) &&
                    requestedActionCategories.Contains(PredefinedSuggestedActionCategoryNames.Refactoring))
                {
                    // Get the selection while on the UI thread.
                    var selection = TryGetCodeRefactoringSelection(_subjectBuffer, _textView, range);
                    if (!selection.HasValue)
                    {
                        // this is here to fail test and see why it is failed.
                        Trace.WriteLine("given range is not current");
                        return null;
                    }

                    var refactorings = Task.Run(
                        async () => await _owner._codeRefactoringService.GetRefactoringsAsync(
                            document, selection.Value, cancellationToken).ConfigureAwait(false),
                        cancellationToken).WaitAndGetResult(cancellationToken);

                    return refactorings.Select(r => OrganizeRefactorings(workspace, r));
                }

                return null;
            }