public async Task <CompletionResult> GetCompletionData(int position, char?triggerChar, bool useSignatureHelp)
        {
            IList <ICompletionDataEx> completionData   = null;
            IOverloadProviderEx       overloadProvider = null;
            bool?isCompletion = null;

            var document = _roslynHost.GetDocument(_documentId);

            if (useSignatureHelp || triggerChar != null)
            {
                var signatureHelpProvider = _roslynHost.GetService <ISignatureHelpProvider>();
                var isSignatureHelp       = useSignatureHelp || signatureHelpProvider.IsTriggerCharacter(triggerChar.Value);
                if (isSignatureHelp)
                {
                    var signatureHelp = await signatureHelpProvider.GetItemsAsync(
                        document,
                        position,
                        new SignatureHelpTriggerInfo(
                            useSignatureHelp
                                ? SignatureHelpTriggerReason.InvokeSignatureHelpCommand
                                : SignatureHelpTriggerReason.TypeCharCommand, triggerChar))
                                        .ConfigureAwait(false);

                    if (signatureHelp != null)
                    {
                        overloadProvider = new RoslynOverloadProvider(signatureHelp);
                    }
                }
                else
                {
                    isCompletion = await CompletionService.IsCompletionTriggerCharacterAsync(document, position - 1).ConfigureAwait(false);
                }
            }

            if (overloadProvider == null && isCompletion != false)
            {
                var data = await CompletionService.GetCompletionListAsync(
                    document,
                    position,
                    triggerChar != null
                    ?CompletionTriggerInfo.CreateTypeCharTriggerInfo(triggerChar.Value)
                    : CompletionTriggerInfo.CreateInvokeCompletionTriggerInfo()
                    ).ConfigureAwait(false);

                completionData = data?.Items.Select(item => new RoslynCompletionData(item, _snippetService.SnippetManager)).ToArray <ICompletionDataEx>()
                                 ?? Array.Empty <ICompletionDataEx>();
            }

            return(new CompletionResult(completionData, overloadProvider));
        }
        private async Task CreateSpellCheckCodeIssueAsync(CodeFixContext context, TSimpleName nameNode, string nameText, CancellationToken cancellationToken)
        {
            var document       = context.Document;
            var completionList = await CompletionService.GetCompletionListAsync(
                document, nameNode.SpanStart, CompletionTriggerInfo.CreateInvokeCompletionTriggerInfo(), cancellationToken : cancellationToken).ConfigureAwait(false);

            if (completionList == null)
            {
                return;
            }

            var completionRules      = CompletionService.GetCompletionRules(document);
            var onlyConsiderGenerics = IsGeneric(nameNode);
            var results = new MultiDictionary <double, string>();

            using (var similarityChecker = new WordSimilarityChecker(nameText, substringsAreSimilar: true))
            {
                foreach (var item in completionList.Items)
                {
                    if (onlyConsiderGenerics && !IsGeneric(item))
                    {
                        continue;
                    }

                    var    candidateText = item.FilterText;
                    double matchCost;
                    if (!similarityChecker.AreSimilar(candidateText, out matchCost))
                    {
                        continue;
                    }

                    var insertionText = completionRules.GetTextChange(item).NewText;
                    results.Add(matchCost, insertionText);
                }
            }

            var matches = results.OrderBy(kvp => kvp.Key)
                          .SelectMany(kvp => kvp.Value.Order())
                          .Where(t => t != nameText)
                          .Take(3)
                          .Select(n => CreateCodeAction(nameNode, nameText, n, document));

            context.RegisterFixes(matches, context.Diagnostics);
        }