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 ContainerElement classifiedTextElement)) { var vsHover = new OmniSharpVSHover { Contents = new MarkedStringsOrMarkupContent(), Range = range, RawContent = classifiedTextElement, }; return(vsHover); } else { var hoverContentFormat = GetHoverContentFormat(clientCapabilities); if (!_lspTagHelperTooltipFactory.TryCreateTooltip(elementDescriptionInfo, 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); } }
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); }
private IReadOnlyList <RazorCompletionItem> GetElementCompletions( SyntaxNode containingTag, string containingTagName, IEnumerable <KeyValuePair <string, string> > attributes, TagHelperDocumentContext tagHelperDocumentContext) { var ancestors = containingTag.Ancestors(); var(ancestorTagName, ancestorIsTagHelper) = _tagHelperFactsService.GetNearestAncestorTagInfo(ancestors); var elementCompletionContext = new ElementCompletionContext( tagHelperDocumentContext, existingCompletions: Enumerable.Empty <string>(), containingTagName, attributes, ancestorTagName, ancestorIsTagHelper, HtmlFactsService.IsHtmlTagName); var completionItems = new List <RazorCompletionItem>(); var completionResult = _tagHelperCompletionService.GetElementCompletions(elementCompletionContext); foreach (var completion in completionResult.Completions) { var razorCompletionItem = new RazorCompletionItem( displayText: completion.Key, insertText: completion.Key, RazorCompletionItemKind.TagHelperElement, ElementCommitCharacters); var tagHelperDescriptions = completion.Value.Select(tagHelper => BoundElementDescriptionInfo.From(tagHelper)); var elementDescription = new AggregateBoundElementDescription(tagHelperDescriptions.ToList()); razorCompletionItem.SetTagHelperElementDescriptionInfo(elementDescription); completionItems.Add(razorCompletionItem); } return(completionItems); }