Ejemplo n.º 1
0
        private HoverModel AttributeInfoToHover(IEnumerable <BoundAttributeDescriptor> descriptors, RangeModel range, string attributeName, ClientCapabilities clientCapabilities)
        {
            var descriptionInfos = descriptors.Select(boundAttribute =>
            {
                var indexer         = TagHelperMatchingConventions.SatisfiesBoundAttributeIndexer(attributeName, boundAttribute);
                var descriptionInfo = BoundAttributeDescriptionInfo.From(boundAttribute, indexer);
                return(descriptionInfo);
            }).ToList().AsReadOnly();
            var attrDescriptionInfo = new AggregateBoundAttributeDescription(descriptionInfos);

            var isVSClient = clientCapabilities is PlatformAgnosticClientCapabilities platformAgnosticClientCapabilities &&
                             platformAgnosticClientCapabilities.SupportsVisualStudioExtensions;

            if (isVSClient && _vsLspTagHelperTooltipFactory.TryCreateTooltip(attrDescriptionInfo, out ContainerElement classifiedTextElement))
            {
                var vsHover = new OmniSharpVSHover
                {
                    Contents   = new MarkedStringsOrMarkupContent(),
                    Range      = range,
                    RawContent = classifiedTextElement,
                };

                return(vsHover);
            }
            else
            {
                var hoverContentFormat = GetHoverContentFormat(clientCapabilities);

                if (!_lspTagHelperTooltipFactory.TryCreateTooltip(attrDescriptionInfo, hoverContentFormat, out var vsMarkupContent))
                {
                    return(null);
                }

                Enum.TryParse(vsMarkupContent.Kind.Value, out MarkupKind markupKind);

                var markupContent = new MarkupContent()
                {
                    Value = vsMarkupContent.Value,
                    Kind  = markupKind,
                };

                var hover = new HoverModel
                {
                    Contents = new MarkedStringsOrMarkupContent(markupContent),
                    Range    = range
                };

                return(hover);
            }
        }
Ejemplo n.º 2
0
        private HoverModel ElementInfoToHover(IEnumerable <TagHelperDescriptor> descriptors, RangeModel range)
        {
            var descriptionInfos = descriptors.Select(descriptor => BoundElementDescriptionInfo.From(descriptor))
                                   .ToList()
                                   .AsReadOnly();
            var elementDescriptionInfo = new AggregateBoundElementDescription(descriptionInfos);

            if (!_tagHelperTooltipFactory.TryCreateTooltip(elementDescriptionInfo, out var markupContent))
            {
                return(null);
            }

            var hover = new HoverModel
            {
                Contents = new MarkedStringsOrMarkupContent(markupContent),
                Range    = range
            };

            return(hover);
        }
Ejemplo n.º 3
0
        private HoverModel ElementInfoToHover(IEnumerable <TagHelperDescriptor> descriptors, RangeModel range)
        {
            var descriptionInfos = descriptors.Select(d => new TagHelperDescriptionInfo(d.DisplayName, d.Documentation))
                                   .ToList()
                                   .AsReadOnly();
            var elementDescriptionInfo = new ElementDescriptionInfo(descriptionInfos);

            if (!_tagHelperDescriptionFactory.TryCreateDescription(elementDescriptionInfo, out var markupContent))
            {
                return(null);
            }

            var hover = new HoverModel
            {
                Contents = new MarkedStringsOrMarkupContent(markupContent),
                Range    = range
            };

            return(hover);
        }
Ejemplo n.º 4
0
        private HoverModel AttributeInfoToHover(IEnumerable <BoundAttributeDescriptor> descriptors, RangeModel range, string attributeName)
        {
            var descriptionInfos = descriptors.Select(boundAttribute =>
            {
                var indexer         = TagHelperMatchingConventions.SatisfiesBoundAttributeIndexer(attributeName, boundAttribute);
                var descriptionInfo = BoundAttributeDescriptionInfo.From(boundAttribute, indexer);
                return(descriptionInfo);
            }).ToList().AsReadOnly();
            var attrDescriptionInfo = new AggregateBoundAttributeDescription(descriptionInfos);

            if (!_tagHelperTooltipFactory.TryCreateTooltip(attrDescriptionInfo, out var markupContent))
            {
                return(null);
            }

            var hover = new HoverModel
            {
                Contents = new MarkedStringsOrMarkupContent(markupContent),
                Range    = range
            };

            return(hover);
        }
Ejemplo n.º 5
0
        private HoverModel ElementInfoToHover(IEnumerable <TagHelperDescriptor> descriptors, RangeModel range, ClientCapabilities clientCapabilities)
        {
            var descriptionInfos = descriptors.Select(descriptor => BoundElementDescriptionInfo.From(descriptor))
                                   .ToList()
                                   .AsReadOnly();
            var elementDescriptionInfo = new AggregateBoundElementDescription(descriptionInfos);

            var isVSClient = clientCapabilities is PlatformAgnosticClientCapabilities platformAgnosticClientCapabilities &&
                             platformAgnosticClientCapabilities.SupportsVisualStudioExtensions;

            if (isVSClient && _vsLspTagHelperTooltipFactory.TryCreateTooltip(elementDescriptionInfo, out VSContainerElement classifiedTextElement))
            {
                var vsHover = new VSHover
                {
                    Contents   = new MarkedStringsOrMarkupContent(),
                    Range      = range,
                    RawContent = classifiedTextElement,
                };

                return(vsHover);
            }
            else
            {
                if (!_lspTagHelperTooltipFactory.TryCreateTooltip(elementDescriptionInfo, out var markupContent))
                {
                    return(null);
                }

                var hover = new HoverModel
                {
                    Contents = new MarkedStringsOrMarkupContent(markupContent),
                    Range    = range
                };

                return(hover);
            }
        }
Ejemplo n.º 6
0
        private HoverModel AttributeInfoToHover(IEnumerable <BoundAttributeDescriptor> descriptors, RangeModel range)
        {
            var descriptionInfos = descriptors.Select(d => new TagHelperAttributeDescriptionInfo(d.DisplayName, d.GetPropertyName(), d.TypeName, d.Documentation))
                                   .ToList()
                                   .AsReadOnly();
            var attrDescriptionInfo = new AttributeDescriptionInfo(descriptionInfos);

            if (!_tagHelperDescriptionFactory.TryCreateDescription(attrDescriptionInfo, out var markdown))
            {
                return(null);
            }

            var hover = new HoverModel
            {
                Contents = new MarkedStringsOrMarkupContent(new MarkupContent
                {
                    Kind  = MarkupKind.Markdown,
                    Value = markdown
                }),
                Range = range
            };

            return(hover);
        }