public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan)
        {
            if (_state == QuickInfoState.Disable)
            {
                applicableToSpan = default;
                return;
            }

            if (_state == QuickInfoState.Override)
            {
                quickInfoContent.Clear();
            }

            var triggerPoint = session.GetTriggerPoint(_textBuffer.CurrentSnapshot);

            if (!triggerPoint.HasValue)
            {
                applicableToSpan = default;
                return;
            }

            var quickInfo = QuickInfoService.GetQuickInfoAsync(_textBuffer, triggerPoint.Value, CancellationToken.None).Result;

            if (quickInfo is null || quickInfo.Descriptions.Length == 0)
            {
                applicableToSpan = default;
                return;
            }

            var trackingSpan = triggerPoint.Value.Snapshot.CreateTrackingSpan(quickInfo.GetSpan(), SpanTrackingMode.EdgeInclusive);

            var items = new List <UIElement>();

            foreach (var item in quickInfo.Descriptions)
            {
                var textBlock = ToTextBlock(item);
                if (item.Kind == SymbolDescriptionKind.Main)
                {
                    var panel = new WrapPanel();

                    var uiElements = TryGetImageElement(quickInfo.Image, out var image)
                        ? image.Enumerate().Concat(textBlock.Enumerate())
                        : textBlock.Enumerate();
                    Populate(panel, uiElements);

                    items.Insert(0, panel);
                }
                else
                {
                    items.Add(textBlock);
                }
            }

            var container = new StackPanel();

            Populate(container, items);
            quickInfoContent.Add(container);
            applicableToSpan = trackingSpan;
        }
        public async Task <MsQuickInfoItem> GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken)
        {
            // NOTE: returned null would be ignored by VS
            if (_state == QuickInfoState.Disable)
            {
                return(null);
            }

            var triggerPoint = session.GetTriggerPoint(_textBuffer.CurrentSnapshot);

            if (!triggerPoint.HasValue)
            {
                return(null);
            }

            var quickInfo = await QuickInfoService.GetQuickInfoAsync(_textBuffer, triggerPoint.Value, cancellationToken);

            if (quickInfo is null || quickInfo.Descriptions.Length == 0)
            {
                return(null);
            }

            var trackingSpan = triggerPoint.Value.Snapshot.CreateTrackingSpan(quickInfo.GetSpan(), SpanTrackingMode.EdgeInclusive);

            var items = new List <object>();

            foreach (var item in quickInfo.Descriptions)
            {
                if (item.Kind == SymbolDescriptionKind.Main)
                {
                    var containerItem = TryGetImageElement(quickInfo.Image, out var image)
                        ? new ContainerElement(ContainerElementStyle.Wrapped, image, ToClassifiedTextElement(item))
                        : new ContainerElement(ContainerElementStyle.Wrapped, ToClassifiedTextElement(item));

                    items.Insert(0, containerItem);
                }
                else
                {
                    items.Add(ToClassifiedTextElement(item));
                }
            }

            // NOTE: wrap element into a specified type to determine that the content element was created by CoCo or not
            return(_state == QuickInfoState.Override
                ? new MsQuickInfoItem(trackingSpan, new QuickInfoWrapper(new ContainerElement(ContainerElementStyle.Stacked, items)))
                : new MsQuickInfoItem(trackingSpan, new ContainerElement(ContainerElementStyle.Stacked, items)));
        }