Beispiel #1
0
        private static VSCompletionList PromotedDataOntoList(VSCompletionList completionList)
        {
            // This piece makes a massive assumption that all completion items will have a resultId associated with them and their
            // data properties will all be the same. Therefore, we can inspect the first item and empty out the rest.
            var commonDataItem = completionList.FirstOrDefault();

            if (commonDataItem is null)
            {
                // No common data items, nothing to do
                return(completionList);
            }

            var promotedCompletionItems = new List <CompletionItem>();

            foreach (var completionItem in completionList.Items)
            {
                var clearedCompletionItem = completionItem with {
                    Data = null
                };
                promotedCompletionItems.Add(clearedCompletionItem);
            }

            var promotedCompletionList = new VSCompletionList(promotedCompletionItems, completionList.IsIncomplete)
            {
                CommitCharacters = completionList.CommitCharacters,
                Data             = commonDataItem.Data,
            };

            return(promotedCompletionList);
        }
    }
        private static void PromotedDataOntoList(VSCompletionList completionList)
        {
            // This piece makes a massive assumption that all completion items will have a resultId associated with them and their
            // data properties will all be the same. Therefore, we can inspect the first item and empty out the rest.
            var commonDataItem = completionList.FirstOrDefault();

            if (commonDataItem is null)
            {
                // Empty list
                return;
            }

            completionList.Data = commonDataItem.Data;
            foreach (var completionItem in completionList.Items)
            {
                completionItem.Data = null;
            }
        }