public void PresentItem(ITrackingSpan triggerSpan, QuickInfoItem item, bool trackMouse) { AssertIsForeground(); _triggerSpan = triggerSpan; _item = item; // It's a new list of items. Either create the editor session if this is the first time, or ask the // editor session that we already have to recalculate. if (_editorSessionOpt == null || _editorSessionOpt.IsDismissed) { // We're tracking the caret. Don't have the editor do it. var triggerPoint = triggerSpan.GetStartTrackingPoint(PointTrackingMode.Negative); _editorSessionOpt = _quickInfoBroker.CreateQuickInfoSession(_textView, triggerPoint, trackMouse: trackMouse); _editorSessionOpt.Dismissed += (s, e) => OnEditorSessionDismissed(); } // So here's the deal. We cannot create the editor session and give it the right // signatures (even though we know what they are). Instead, the session with // call back into the ISignatureHelpSourceProvider (which is us) to get those // values. It will pass itself along with the calls back into // ISignatureHelpSourceProvider. So, in order to make that connection work, we // add properties to the session so that we can call back into ourselves, get // the signatures and add it to the session. if (!_editorSessionOpt.Properties.ContainsProperty(s_augmentSessionKey)) { _editorSessionOpt.Properties.AddProperty(s_augmentSessionKey, this); } _editorSessionOpt.Recalculate(); }
async Task StartTooltipRequestAsync(IQuickInfoSession session, IList <object> quickInfoContent, ITrackingSpan applicableToSpan, SnapshotPoint?triggerPoint, string filePath) { // If this position didn't have a classification, then it's uninteresting, and won't have tooltips. if (applicableToSpan == null) { return; } // Set the position so we know what request is in process. inProgressPosition = triggerPoint.Value.Position; inProgressTooltipData = null; inProgressApplicableToSpan = null; // Put dummy content in tooltip while the request in in-flight. quickInfoContent.Add("Loading..."); // Fire off a request to the service to get the data. DartAnalysisService analysisService = await provider.DartAnalysisServiceFactory.GetAnalysisServiceAsync().ConfigureAwait(false); HoverInformation[] hovers = await analysisService.GetHover(filePath, triggerPoint.Value.Position); // Build the tooltip info if the response was valid. var tooltipData = BuildTooltip(hovers); if (!string.IsNullOrWhiteSpace(tooltipData)) { // Stash the data for the next call, and tell VS to reclaculate now that we have the good info. inProgressTooltipData = tooltipData; inProgressApplicableToSpan = buffer.CurrentSnapshot.CreateTrackingSpan(hovers[0].Offset, hovers[0].Length, SpanTrackingMode.EdgeInclusive); session.Recalculate(); } else { // Otherwise, no valid response, means no tooltip. session.Dismiss(); } }
async Task StartTooltipRequestAsync(IQuickInfoSession session, IList<object> quickInfoContent, ITrackingSpan applicableToSpan, SnapshotPoint? triggerPoint, string filePath) { // If this position didn't have a classification, then it's uninteresting, and won't have tooltips. if (applicableToSpan == null) return; // Set the position so we know what request is in process. inProgressPosition = triggerPoint.Value.Position; inProgressTooltipData = null; inProgressApplicableToSpan = null; // Put dummy content in tooltip while the request in in-flight. quickInfoContent.Add("Loading..."); // Fire off a request to the service to get the data. DartAnalysisService analysisService = await provider.DartAnalysisServiceFactory.GetAnalysisServiceAsync().ConfigureAwait(false); HoverInformation[] hovers = await analysisService.GetHover(filePath, triggerPoint.Value.Position); // Build the tooltip info if the response was valid. var tooltipData = BuildTooltip(hovers); if (!string.IsNullOrWhiteSpace(tooltipData)) { // Stash the data for the next call, and tell VS to reclaculate now that we have the good info. inProgressTooltipData = tooltipData; inProgressApplicableToSpan = buffer.CurrentSnapshot.CreateTrackingSpan(hovers[0].Offset, hovers[0].Length, SpanTrackingMode.EdgeInclusive); session.Recalculate(); } else { // Otherwise, no valid response, means no tooltip. session.Dismiss(); } }