Exemplo n.º 1
0
        private async Task ComputeSourceContentAsync(
            IAsyncQuickInfoSource source,
            IList <object> items,
            IList <ITrackingSpan> applicableToSpans,
            IList <Exception> failures,
            CancellationToken cancellationToken)
        {
            Debug.Assert(!this.JoinableTaskContext.IsOnMainThread);

            cancellationToken.ThrowIfCancellationRequested();

            try
            {
                // Bug #512117: Remove compatibility shims for 2nd gen. Quick Info APIs.
                if (!await this.TryComputeContentFromLegacySourceAsync(source, items, applicableToSpans).ConfigureAwait(false))
                {
                    var result = await source.GetQuickInfoItemAsync(this, cancellationToken).ConfigureAwait(false);

                    if (result != null)
                    {
                        items.Add(result.Item);
                        if (result.ApplicableToSpan != null)
                        {
                            applicableToSpans.Add(result.ApplicableToSpan);
                        }
                    }
                }
            }
            catch (Exception ex) when(ex.GetType() != typeof(OperationCanceledException))
            {
                failures.Add(ex);
            }
        }
Exemplo n.º 2
0
        private async Task ComputeSourceContentAsync(
            IAsyncQuickInfoSource source,
            IList <object> items,
            IList <ITrackingSpan> applicableToSpans,
            IList <Exception> failures,
            CancellationToken cancellationToken)
        {
            Debug.Assert(!this.joinableTaskContext.IsOnMainThread);

            cancellationToken.ThrowIfCancellationRequested();

            try
            {
                var result = await source.GetQuickInfoItemAsync(this, cancellationToken).ConfigureAwait(false);

                if (result != null)
                {
                    items.Add(result.Item);
                    if (result.ApplicableToSpan != null)
                    {
                        applicableToSpans.Add(result.ApplicableToSpan);
                    }
                }
            }
            catch (Exception ex) when(ex.GetType() != typeof(OperationCanceledException))
            {
                failures.Add(ex);
            }
        }
Exemplo n.º 3
0
        public static void TryCreateQuickInfoSourceReturnsTemplateQuickInfoSource()
        {
            ITemplateEditorOptions options = OptionsWithQuickInfoTooltipsEnabled(true);
            var provider   = new TemplateQuickInfoSourceProvider(options);
            var textBuffer = new FakeTextBuffer(string.Empty);
            IAsyncQuickInfoSource quickInfoSource = provider.TryCreateQuickInfoSource(textBuffer);

            Assert.Equal(typeof(TemplateQuickInfoSource), quickInfoSource.GetType());
        }
Exemplo n.º 4
0
        public static void TryCreateQuickInfoSourceReturnsSameObjectWhenCalledMultipleTimesForSameBuffer()
        {
            ITemplateEditorOptions options = OptionsWithQuickInfoTooltipsEnabled(true);
            var provider   = new TemplateQuickInfoSourceProvider(options);
            var textBuffer = new FakeTextBuffer(string.Empty);
            IAsyncQuickInfoSource source1 = provider.TryCreateQuickInfoSource(textBuffer);
            IAsyncQuickInfoSource source2 = provider.TryCreateQuickInfoSource(textBuffer);

            Assert.Same(source1, source2);
        }
        // Bug #512117: Remove compatibility shims for 2nd gen. Quick Info APIs.
        private async Task <bool> TryComputeContentFromLegacySourceAsync(
            IAsyncQuickInfoSource source,
            IList <object> items,
            IList <ITrackingSpan> applicableToSpans)
        {
            if (source is ILegacyQuickInfoSource legacySource)
            {
#pragma warning restore 618

                // Legacy sources expect to be on the UI thread.
                await this.JoinableTaskContext.Factory.SwitchToMainThreadAsync();

                legacySource.AugmentQuickInfoSession(this, items, out var applicableToSpan);

                if (applicableToSpan != null)
                {
                    applicableToSpans.Add(applicableToSpan);
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 6
0
 public OrderedSource(int order, IAsyncQuickInfoSource source)
 {
     this.Order  = order;
     this.Source = source ?? throw new ArgumentNullException(nameof(source));
 }