async Task GetDescriptionAsync(RoslynCompletionSet completionSet, RoslynCompletion completion, CancellationToken cancellationToken) { var description = await completionSet.GetDescriptionAsync(completion, cancellationToken); if (description is null || description.TaggedParts.IsDefault || description.TaggedParts.Length == 0) { InitializeDefaultDocumentation(); }
public AsyncToolTipContent(CompletionToolTipProvider owner, RoslynCompletionSet completionSet, RoslynCompletion completion, ICompletionSession session, ITaggedTextElementProviderService taggedTextElementProviderService, bool colorize) { this.owner = owner; Session = session; cancellationTokenSource = new CancellationTokenSource(); this.taggedTextElementProviderService = taggedTextElementProviderService; this.colorize = colorize; Session.Dismissed += Session_Dismissed; Unloaded += AsyncToolTipContent_Unloaded; GetDescriptionAsync(completionSet, completion, cancellationTokenSource.Token) .ContinueWith(t => { var ex = t.Exception; Dispose(); }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> 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); session.Properties.TryGetProperty(typeof(CompletionTrigger), out CompletionTrigger completionTrigger); var completionList = info.Value.CompletionService.GetCompletionsAsync(info.Value.Document, triggerPoint.Value.Position, completionTrigger).GetAwaiter().GetResult(); if (completionList == null) { return; } Debug.Assert(completionList.Span.End <= snapshot.Length); if (completionList.Span.End > snapshot.Length) { return; } var trackingSpan = snapshot.CreateTrackingSpan(completionList.Span.Start, completionList.Span.Length, SpanTrackingMode.EdgeInclusive, TrackingFidelityMode.Forward); var completionSet = RoslynCompletionSet.Create(imageMonikerService, mruCompletionService, completionList, info.Value.CompletionService, session.TextView, DefaultCompletionSetMoniker, dnSpy_Roslyn_Resources.CompletionSet_All, trackingSpan); completionSets.Add(completionSet); }