private void MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e) { if (_session != null) { _session.Dismiss(); } }
void IQuickInfoSource.AugmentQuickInfoSession(IQuickInfoSession existingQuickInfoSession, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { // Augmenting quick info isn't cancellable. var cancellationToken = CancellationToken.None; EventHookupSessionManager eventHookupSessionManager; // Ensure this is a quick info session created by event hookup if (!existingQuickInfoSession.Properties.TryGetProperty(typeof(EventHookupSessionManager), out eventHookupSessionManager)) { applicableToSpan = null; return; } if (!eventHookupSessionManager.IsTrackingSession()) { existingQuickInfoSession.Dismiss(); applicableToSpan = null; return; } string eventHandlerName = null; // Get the event handler method name. The name was calculated when the quick info // session was created, so we do not need to wait for the task here. if (eventHookupSessionManager.CurrentSession.GetEventNameTask.Status == TaskStatus.RanToCompletion) { eventHandlerName = eventHookupSessionManager.CurrentSession.GetEventNameTask.Result; } if (eventHandlerName == null) { existingQuickInfoSession.Dismiss(); applicableToSpan = null; return; } // We should show the quick info session. Calculate the span and create the content. var currentSnapshot = _textBuffer.CurrentSnapshot; applicableToSpan = currentSnapshot.CreateTrackingSpan( start: eventHookupSessionManager.CurrentSession.TrackingPoint.GetPosition(currentSnapshot), length: 0, trackingMode: SpanTrackingMode.EdgeInclusive); // Clear any existing quick info content. This ensures that the event hookup text is // the only text in the quick info. quickInfoContent.Clear(); var content = CreateContent(eventHandlerName, _classificationTypeMap); quickInfoContent.Add(content); // For test purposes only! eventHookupSessionManager.TEST_MostRecentQuickInfoContent = content; }
void IQuickInfoSource.AugmentQuickInfoSession(IQuickInfoSession existingQuickInfoSession, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) { // Augmenting quick info isn't cancellable. var cancellationToken = CancellationToken.None; EventHookupSessionManager eventHookupSessionManager; // Ensure this is a quick info session created by event hookup if (!existingQuickInfoSession.Properties.TryGetProperty(typeof(EventHookupSessionManager), out eventHookupSessionManager)) { applicableToSpan = null; return; } if (!eventHookupSessionManager.IsTrackingSession()) { existingQuickInfoSession.Dismiss(); applicableToSpan = null; return; } string eventHandlerName = null; // Get the event handler method name. The name was calculated when the quick info // session was created, so we do not need to wait for the task here. if (eventHookupSessionManager.CurrentSession.GetEventNameTask.Status == TaskStatus.RanToCompletion) { eventHandlerName = eventHookupSessionManager.CurrentSession.GetEventNameTask.Result; } if (eventHandlerName == null) { existingQuickInfoSession.Dismiss(); applicableToSpan = null; return; } // We should show the quick info session. Calculate the span and create the content. var currentSnapshot = _textBuffer.CurrentSnapshot; applicableToSpan = currentSnapshot.CreateTrackingSpan( start: eventHookupSessionManager.CurrentSession.TrackingPoint.GetPosition(currentSnapshot), length: 0, trackingMode: SpanTrackingMode.EdgeInclusive); // Clear any existing quick info content. This ensures that the event hookup text is // the only text in the quick info. quickInfoContent.Clear(); var content = CreateContent(eventHandlerName, _classificationTypeMap); quickInfoContent.Add(content); // For test purposes only! eventHookupSessionManager.TEST_MostRecentQuickInfoContent = content; }
/// <summary> /// Activates a new QuickInfo session in response to the MouseHover event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void textView_MouseHover(object sender, MouseHoverEventArgs e) { if (activeSession != null) { activeSession.Dismiss(); } SnapshotPoint?point = e.TextPosition.GetPoint( textBuffer => ( buffer == textBuffer // only text buffers require expilicit session activation // XML and HTML already have quickInfo session activation code // adding our own would cause 'double vision' - our source would be hit // by our session as well as by the standard one && textBuffer.ContentType.TypeName == "plaintext" ) , PositionAffinity.Predecessor); if (point.HasValue) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); activeSession = provider.quickInfoBroker.CreateQuickInfoSession(textView, triggerPoint, true); activeSession.Start(); } }
private void RetriggerQuickInfoSession(IEnumerable <IRFunctionQuickInfo> infos, IQuickInfoSession session) { if (session == null || _processingRetrigger) { return; } _processingRetrigger = true; _services.MainThread().Post(() => { try { var broker = _services.GetService <IQuickInfoBroker>(); if (!session.IsDismissed) { session.Dismiss(); } _infos = infos; _lastPosition = -1; broker.TriggerQuickInfo(session.TextView); } finally { _processingRetrigger = false; } }); }
public void AugmentQuickInfoSession(IQuickInfoSession session, System.Collections.Generic.IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { if (_curSession != null && !_curSession.IsDismissed) { _curSession.Dismiss(); _curSession = null; } _curSession = session; _curSession.Dismissed += CurSessionDismissed; if (_provider._PublicFunctionProvider != null) { _provider._PublicFunctionProvider.SetFilename(_textBuffer.GetFilePath()); } if (_provider._DatabaseInfoProvider != null) { _provider._DatabaseInfoProvider.SetFilename(_textBuffer.GetFilePath()); } var vars = _textBuffer.CurrentSnapshot.AnalyzeExpression( session.CreateTrackingSpan(_textBuffer), false, _provider._PublicFunctionProvider, _provider._DatabaseInfoProvider, _provider._ProgramFileProvider ); AugmentQuickInfoWorker(session, _textBuffer, _viewAdapter, vars, quickInfoContent, out applicableToSpan); }
private void TextViewMouseHover(object sender, MouseHoverEventArgs e) { if (_quickInfoSession != null && !_quickInfoSession.IsDismissed) { _quickInfoSession.Dismiss(); } var pt = e.TextPosition.GetPoint(EditorExtensions.IsPythonContent, PositionAffinity.Successor); if (pt != null) { _quickInfoSession = _provider._QuickInfoBroker.TriggerQuickInfo( _textView, pt.Value.Snapshot.CreateTrackingPoint(pt.Value.Position, PointTrackingMode.Positive), true); } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <Object> quickInfoContent, out ITrackingSpan applicableToSpan) { if (!Keyboard.IsKeyDown(Key.LeftCtrl) && !Keyboard.IsKeyDown(Key.RightCtrl)) { session.Dismiss(); } applicableToSpan = null; }
private static bool TryGetQuickInfoFromDebugger(IQuickInfoSession session, SnapshotSpan span, IVsTextView viewAdapter, out string tipText) { IVsTextLines lines; tipText = null; IVsDebugger debuggerService = GetDebuggerService(session.TextView); if (debuggerService == null) { return(false); } IVsTextView vsTextView = viewAdapter; var txtSpan = GetTextSpan(viewAdapter, span); //GetTextSpan(session.TextView.TextBuffer, span, out vsTextView); TextSpan[] dataBufferTextSpan = new TextSpan[] { txtSpan }; int hr = -2147467259; if ((dataBufferTextSpan[0].iStartLine == dataBufferTextSpan[0].iEndLine) && (dataBufferTextSpan[0].iStartIndex == dataBufferTextSpan[0].iEndIndex)) { int iStartIndex = dataBufferTextSpan[0].iStartIndex; int iStartLine = dataBufferTextSpan[0].iStartLine; //if (ErrorHandler.Failed(textViewWindow.GetWordExtent(iStartLine, iStartIndex, 0, dataBufferTextSpan))) //{ // return false; //} if ((iStartLine < dataBufferTextSpan[0].iStartLine) || (iStartLine > dataBufferTextSpan[0].iEndLine)) { return(false); } if ((iStartLine == dataBufferTextSpan[0].iStartLine) && (iStartIndex < dataBufferTextSpan[0].iStartIndex)) { return(false); } if ((iStartLine == dataBufferTextSpan[0].iEndLine) && (iStartIndex >= dataBufferTextSpan[0].iEndIndex)) { return(false); } } if (ErrorHandler.Failed(vsTextView.GetBuffer(out lines))) { return(false); } hr = debuggerService.GetDataTipValue(lines, dataBufferTextSpan, null, out tipText); if (hr == 0x45001) { HandoffNoDefaultTipToDebugger(session); session.Dismiss(); tipText = null; return(true); } if (ErrorHandler.Failed(hr)) { return(false); } return(true); }
private void TextViewMouseHover(object sender, MouseHoverEventArgs e) { if (_quickInfoSession != null && !_quickInfoSession.IsDismissed) { _quickInfoSession.Dismiss(); } _quickInfoSession = _provider._QuickInfoBroker.TriggerQuickInfo(_textView, _textView.TextSnapshot.CreateTrackingPoint(e.Position, PointTrackingMode.Negative), true); }
public virtual void DismissQuickInfo() { IQuickInfoSession session = QuickInfoSession; QuickInfoSession = null; if (session != null && !session.IsDismissed) { session.Dismiss(); } }
private void RetriggerQuickInfoSession(IQuickInfoSession session) { if (session != null && !session.IsDismissed) { session.Dismiss(); } _lastPosition = -1; IQuickInfoBroker broker = EditorShell.Current.ExportProvider.GetExport <IQuickInfoBroker>().Value; broker.TriggerQuickInfo(session.TextView, session.GetTriggerPoint(session.TextView.TextBuffer), session.TrackMouse); }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <Object> qiContent, out ITrackingSpan applicableToSpan) { // don't show Quick Info when CtrlQuickInfo option is on and shift is not pressed if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.CtrlQuickInfo) && Keyboard.Modifiers.MatchFlags(ModifierKeys.Shift) == false // do not show Quick Info when user is hovering on the smart bar || session.TextView.Properties.ContainsProperty(nameof(SmartBars.SmartBar)) ) { session.Dismiss(); } applicableToSpan = null; }
private void RetriggerQuickInfoSession(IQuickInfoSession session, string packageName) { if (session != null && !session.IsDismissed) { session.Dismiss(); } _lastPosition = -1; _packageName = packageName; if (packageName != null) { IQuickInfoBroker broker = _coreShell.GetService <IQuickInfoBroker>(); broker.TriggerQuickInfo(session.TextView, session.GetTriggerPoint(session.TextView.TextBuffer), session.TrackMouse); } }
private void RetriggerQuickInfoSession(IQuickInfoSession session, string packageName) { if (session != null && !session.IsDismissed) { session.Dismiss(); } _lastPosition = -1; _packageName = packageName; if (packageName != null) { IQuickInfoBroker broker = _catalog.ExportProvider.GetExport <IQuickInfoBroker>().Value; broker.TriggerQuickInfo(session.TextView, session.GetTriggerPoint(session.TextView.TextBuffer), session.TrackMouse); } }
public void AugmentQuickInfoSession(IQuickInfoSession session, System.Collections.Generic.IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { if (_curSession != null && !_curSession.IsDismissed) { _curSession.Dismiss(); _curSession = null; } _curSession = session; _curSession.Dismissed += CurSessionDismissed; var quickInfo = GetQuickInfo(session.TextView); AugmentQuickInfoWorker(quickInfoContent, quickInfo, out applicableToSpan); }
public void AugmentQuickInfoSession(IQuickInfoSession session, System.Collections.Generic.IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { if (_curSession != null && !_curSession.IsDismissed) { _curSession.Dismiss(); _curSession = null; } _curSession = session; _curSession.Dismissed += CurSessionDismissed; var vars = _textBuffer.CurrentSnapshot.AnalyzeExpression( _provider._serviceProvider, session.CreateTrackingSpan(_textBuffer), false ); AugmentQuickInfoWorker(vars, quickInfoContent, out applicableToSpan); }
private void RetriggerQuickInfoSession(IEnumerable <IRFunctionQuickInfo> infos, IQuickInfoSession session) { if (session == null) { return; } var broker = _services.GetService <IQuickInfoBroker>(); if (!session.IsDismissed) { session.Dismiss(); } _infos = infos; _lastPosition = -1; broker.TriggerQuickInfo(session.TextView); }
public void Dismiss() { AssertIsForeground(); if (_editorSessionOpt == null) { // No editor session, nothing to do here. return; } if (_item == null) { // We don't have an item, so we're being asked to augment a session. // Since we didn't put anything in the session, don't dismiss it either. return; } _editorSessionOpt.Dismiss(); _editorSessionOpt = null; }
bool IIntellisenseCommandTarget.ExecuteKeyboardCommand(IntellisenseKeyboardCommand command) { switch (command) { case IntellisenseKeyboardCommand.Escape: session.Dismiss(); return(true); case IntellisenseKeyboardCommand.Up: case IntellisenseKeyboardCommand.Down: case IntellisenseKeyboardCommand.PageUp: case IntellisenseKeyboardCommand.PageDown: case IntellisenseKeyboardCommand.Home: case IntellisenseKeyboardCommand.End: case IntellisenseKeyboardCommand.TopLine: case IntellisenseKeyboardCommand.BottomLine: case IntellisenseKeyboardCommand.Enter: case IntellisenseKeyboardCommand.IncreaseFilterLevel: case IntellisenseKeyboardCommand.DecreaseFilterLevel: default: return(false); } }
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(); } }
private void RetriggerQuickInfoSession(IQuickInfoSession session) { if (session != null && !session.IsDismissed) { session.Dismiss(); } _lastPosition = -1; IQuickInfoBroker broker = EditorShell.Current.ExportProvider.GetExport<IQuickInfoBroker>().Value; broker.TriggerQuickInfo(session.TextView, session.GetTriggerPoint(session.TextView.TextBuffer), session.TrackMouse); }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { // Dismiss the session immediately. session.Dismiss(); applicableToSpan = null; }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList<object> quickInfoContent, out ITrackingSpan applicableToSpan) { // Dismiss the session immediately. session.Dismiss(); applicableToSpan = null; }
private void RetriggerQuickInfoSession(IQuickInfoSession session, string packageName) { if (session != null && !session.IsDismissed) { session.Dismiss(); } _lastPosition = -1; _packageName = packageName; if (packageName != null) { IQuickInfoBroker broker = _catalog.ExportProvider.GetExport<IQuickInfoBroker>().Value; broker.TriggerQuickInfo(session.TextView, session.GetTriggerPoint(session.TextView.TextBuffer), session.TrackMouse); } }
public void Dismiss() { QuickInfoSession.Dismiss(); }
static void ApplyClickAndGo(ISymbol symbol, TextBlock description, IQuickInfoSession quickInfoSession) { var locs = symbol.DeclaringSyntaxReferences; if (symbol.Kind == SymbolKind.Namespace) { description.ToolTip = "Locations: " + locs.Length; description.MouseEnter += HookNamespaceSymbolEvents; return; } string path; description.UseDummyToolTip(); if (locs.IsDefaultOrEmpty) { if (symbol.ContainingType != null) { // if the symbol is implicitly declared but its containing type is in source, // navigate to the containing type locs = symbol.ContainingType.DeclaringSyntaxReferences; if (locs.Length != 0) { symbol = symbol.ContainingType; goto ClickAndGo; } } var asm = symbol.GetAssemblyModuleName(); if (asm != null) { path = asm; description.MouseEnter += HookMetaSymbolEvents; } return; } ClickAndGo: path = System.IO.Path.GetFileName(locs[0].SyntaxTree.FilePath); description.MouseEnter += HookEvents; void HookMetaSymbolEvents(object sender, MouseEventArgs e) { var s = sender as FrameworkElement; s.MouseEnter -= HookMetaSymbolEvents; s.ToolTipOpening += ShowToolTip; s.UseDummyToolTip(); s.ContextMenuOpening += ShowContextMenu; } void HookNamespaceSymbolEvents(object sender, EventArgs e) { var s = sender as FrameworkElement; s.MouseEnter -= HookNamespaceSymbolEvents; ((TextBlock)sender).Background = __HighlightBrush; s.Cursor = Cursors.Hand; s.MouseEnter += HighlightSymbol; s.MouseLeave += RemoveSymbolHighlight; s.MouseLeftButtonUp += ListLocations; s.ContextMenuOpening += ShowContextMenu; s.ContextMenuClosing += ReleaseQuickInfo; } void HookEvents(object sender, MouseEventArgs e) { var s = sender as FrameworkElement; s.MouseEnter -= HookEvents; ((TextBlock)sender).Background = __HighlightBrush; s.Cursor = Cursors.Hand; s.ToolTipOpening += ShowToolTip; s.MouseEnter += HighlightSymbol; s.MouseLeave += RemoveSymbolHighlight; if (locs.Length == 1) { s.MouseLeftButtonUp += GoToSource; } else { s.MouseLeftButtonUp += ListLocations; } s.UseDummyToolTip(); s.ContextMenuOpening += ShowContextMenu; s.ContextMenuClosing += ReleaseQuickInfo; } void GoToSource(object sender, MouseButtonEventArgs e) { symbol.GoToSource(); } void ListLocations(object sender, MouseButtonEventArgs e) { quickInfoSession.Dismiss(); CSharpSymbolContextMenu.ShowLocations(symbol, SemanticContext.GetOrCreateSingetonInstance(quickInfoSession.TextView as IWpfTextView)); } void ShowToolTip(object sender, ToolTipEventArgs e) { var t = sender as TextBlock; t.ToolTip = ShowSymbolLocation(symbol, path); t.ToolTipOpening -= ShowToolTip; } void HighlightSymbol(object sender, MouseEventArgs e) { ((TextBlock)sender).Background = __HighlightBrush; } void RemoveSymbolHighlight(object sender, MouseEventArgs e) { ((TextBlock)sender).Background = Brushes.Transparent; } void ShowContextMenu(object sender, ContextMenuEventArgs e) { var s = sender as FrameworkElement; if (s.ContextMenu == null) { var ctx = SemanticContext.GetHovered(); SyncHelper.RunSync(() => ctx.UpdateAsync(default));
internal void Dismiss() { _session?.Dismiss(); }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> qiContent, out ITrackingSpan applicableToSpan) { this._eventsFilter?.Remove(); this._eventsFilter = Helpers.DemandEventsFilterForCurrentNativeTextView(); session.Dismissed += this.RemoveFilter; applicableToSpan = null; var buffer = session.TextView.TextBuffer; SnapshotPoint?point = session.GetTriggerPoint(buffer.CurrentSnapshot); if (!point.HasValue) { return; } int position = point.Value.Position; var line = point.Value.GetContainingLine(); var span = new SnapshotSpan(line.Start, line.Length); var tags = this._classifier.GetClassificationSpans(span); foreach (var tag in tags.Where(t => t.Span.Contains(position))) { if (tag.ClassificationType.IsOfType(IgnoreClassificationTypes.PathNoMatch)) { string text = tag.Span.GetText(); // Only show error tooltips if (!text.Contains("../") && !IgnorePackage.Options.ShowTooltip) { continue; } string tooltip = $"The path \"{text}\" does not point to any existing file"; if (text.StartsWith("../")) { tooltip = "The entry contains a relative path segment which is not allowed"; } applicableToSpan = buffer.CurrentSnapshot.CreateTrackingSpan(tag.Span.Span, SpanTrackingMode.EdgeNegative); qiContent.Add(tooltip); break; } else if (tag.ClassificationType.IsOfType(IgnoreClassificationTypes.Path)) { if (!IgnorePackage.Options.ShowTooltip) { continue; } string pattern = tag.Span.GetText().Trim(); IgnoreTree tree = new IgnoreTree(this._root, pattern, () => { try { session.Dismiss(); } catch { } }); //Resizing in quick info causes the position to change relative to the mouse's position relative to // the original launch point. Fix the size of the control when launching from QI tree.Width = tree.MaxWidth; tree.Height = (tree.MaxHeight + tree.MinHeight) / 2; qiContent.Add(tree); applicableToSpan = buffer.CurrentSnapshot.CreateTrackingSpan(tag.Span.Span, SpanTrackingMode.EdgeNegative); //var files = GetFiles(_root, pattern); //qiContent.Add(string.Join(Environment.NewLine, files.Take(_maxFiles))); //if (files.Count() > _maxFiles) //{ // qiContent.Add($"...and {files.Count() - _maxFiles} more"); //} break; } } }