Ejemplo n.º 1
0
 public static IEnumerable <TSource> GetSources <TSource>(
     IIntellisenseSession session,
     Func <ITextBuffer, IEnumerable <TSource> > sourceCreator) where TSource : IDisposable
 {
     return(IntellisenseSourceCache.GetSources(
                session.TextView,
                GetBuffersForTriggerPoint(session),
                sourceCreator));
 }
Ejemplo n.º 2
0
        private IEnumerable <OrderedSource> GetOrCreateSources(IList <Exception> failures)
        {
            var joinableTaskContext    = this.JoinableTaskContext;
            var orderedSourceProviders = this.orderedSourceProviders;

            // Bug #543960: we use a lambda with explicit capturing of the 'CreateSources'
            // arguments to prevent the compiler from generating a lambda that captures a
            // reference to 'this'. Doing so would cause AsyncQuickInfoSession to be kept
            // alive by the IntellisenseSourceCache and leaked until the view closes.
            return(IntellisenseSourceCache.GetSources(
                       this.TextView,
                       GetBuffersForTriggerPoint().ToList(),
                       (textBuffer) => CreateSources(
                           joinableTaskContext,
                           orderedSourceProviders,
                           textBuffer,
                           failures)));
        }
Ejemplo n.º 3
0
        private async Task <IList <Exception> > ComputeContentAndStartPresenterAsync(CancellationToken cancellationToken)
        {
            IntellisenseUtilities.ThrowIfNotOnMainThread(this.joinableTaskContext);

            // Read current state.
            var originalState = this.State;

            (IList <object> items, IList <ITrackingSpan> applicableToSpans, IList <Exception> failures)? results = null;

            // Alert subscribers on the UI thread.
            this.TransitionTo(QuickInfoSessionState.Calculating);

            cancellationToken.ThrowIfCancellationRequested();

            // Find and create the sources.  Sources cache is smart enough to
            // invalidate on content-type changed and free on view close.
            var sources = IntellisenseSourceCache.GetSources(
                this.TextView,
                GetBuffersForTriggerPoint().ToList(),
                this.CreateSources);

            // Compute quick info items. This method switches off the UI thread.
            // From here on out we're on an arbitrary thread.
            results = await ComputeContentAsync(sources, cancellationToken).ConfigureAwait(false);

            cancellationToken.ThrowIfCancellationRequested();

            // Update our content, or put the empty list if there is none.
            Volatile.Write(
                ref this.content,
                results != null ? ImmutableList.CreateRange(results.Value.items) : ImmutableList <object> .Empty);

            await StartUIThreadEpilogueAsync(originalState, results?.applicableToSpans, cancellationToken).ConfigureAwait(false);

            return(results?.failures);
        }