Пример #1
0
        protected override async Task ProduceTagsAsync(
            TaggerContext <InlineHintDataTag> context, DocumentSnapshotSpan documentSnapshotSpan, int?caretPosition, CancellationToken cancellationToken)
        {
            var document = documentSnapshotSpan.Document;

            if (document == null)
            {
                return;
            }

            var service = document.GetLanguageService <IInlineHintsService>();

            if (service == null)
            {
                return;
            }

            var options = InlineHintsOptions.From(document.Project);

            var snapshotSpan = documentSnapshotSpan.SnapshotSpan;
            var hints        = await service.GetInlineHintsAsync(document, snapshotSpan.Span.ToTextSpan(), options, cancellationToken).ConfigureAwait(false);

            foreach (var hint in hints)
            {
                // If we don't have any text to actually show the user, then don't make a tag.
                if (hint.DisplayParts.Sum(p => p.ToString().Length) == 0)
                {
                    continue;
                }

                context.AddTag(new TagSpan <InlineHintDataTag>(
                                   hint.Span.ToSnapshotSpan(snapshotSpan.Snapshot),
                                   new InlineHintDataTag(hint)));
            }
        }
Пример #2
0
        public static async Task <ImmutableArray <OmniSharpInlineHint> > GetInlineHintsAsync(Document document, TextSpan textSpan, CancellationToken cancellationToken)
        {
            var service = document.GetRequiredLanguageService <IInlineHintsService>();
            var options = InlineHintsOptions.From(document.Project);

            var hints = await service.GetInlineHintsAsync(document, textSpan, options, cancellationToken).ConfigureAwait(false);

            return(hints.SelectAsArray(static h => new OmniSharpInlineHint(
        public async Task <ImmutableArray <InlineHint> > GetInlineHintsAsync(Document document, TextSpan textSpan, InlineHintsOptions options, CancellationToken cancellationToken)
        {
            if (_service == null)
            {
                return(ImmutableArray <InlineHint> .Empty);
            }

            var hints = await _service.GetInlineHintsAsync(document, textSpan, cancellationToken).ConfigureAwait(false);

            return(hints.SelectAsArray(h => new InlineHint(h.Span, h.DisplayParts, (d, c) => h.GetDescriptionAsync(d, c))));
        }