async Task GetDescriptionAsync(RoslynCompletionCollection collection, RoslynCompletion completion, CancellationToken cancellationToken) { var description = await collection.GetDescriptionAsync(completion, cancellationToken); if (description == null || description.TaggedParts.IsDefault || description.TaggedParts.Length == 0) { InitializeDefaultDocumentation(); } else { Content = CreateContent(description); } }
public AsyncToolTipContent(CompletionToolTipProvider owner, RoslynCompletionCollection collection, RoslynCompletion completion, ICompletionSession session, ITaggedTextElementProviderService taggedTextElementProviderService, IThemeClassificationTypeService themeClassificationTypeService) { this.owner = owner; this.Session = session; this.cancellationTokenSource = new CancellationTokenSource(); this.taggedTextElementProviderService = taggedTextElementProviderService; this.themeClassificationTypeService = themeClassificationTypeService; this.Session.Dismissed += Session_Dismissed; Unloaded += AsyncToolTipContent_Unloaded; GetDescriptionAsync(collection, completion, cancellationTokenSource.Token) .ContinueWith(t => { var ex = t.Exception; Dispose(); }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionCollection> completionSets) { var snapshot = session.TextView.TextSnapshot; var triggerPoint = session.GetTriggerPoint(snapshot); if (triggerPoint == null) { return; } var info = CompletionInfo.Create(snapshot); if (info == null) { return; } // This helps a little to speed up the code ProfileOptimizationHelper.StartProfile("roslyn-completion-" + info.Value.CompletionService.Language); CompletionTrigger completionTrigger; session.Properties.TryGetProperty(typeof(CompletionTrigger), out completionTrigger); var completionList = info.Value.CompletionService.GetCompletionsAsync(info.Value.Document, triggerPoint.Value.Position, completionTrigger).GetAwaiter().GetResult(); if (completionList == null) { return; } Debug.Assert(completionList.DefaultSpan.End <= snapshot.Length); if (completionList.DefaultSpan.End > snapshot.Length) { return; } var trackingSpan = snapshot.CreateTrackingSpan(completionList.DefaultSpan.Start, completionList.DefaultSpan.Length, SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward); var completionSet = RoslynCompletionCollection.Create(mruCompletionService, completionList, info.Value.CompletionService, session.TextView, trackingSpan); completionSets.Add(completionSet); }