void TextView_MouseHover(object sender, MouseHoverEventArgs e) { SnapshotPoint?point = TextView.BufferGraph.MapDownToFirstMatch( new SnapshotPoint(TextView.TextSnapshot, e.Position), PointTrackingMode.Positive, snapshot => SubjectBuffers.Contains(snapshot.TextBuffer), PositionAffinity.Predecessor); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); var currentDispatcher = Dispatcher.CurrentDispatcher; if (!Provider.QuickInfoBroker.IsQuickInfoActive(TextView)) { JavaQuickInfo precomputedQuickInfo = new JavaQuickInfo(point.Value.Snapshot.TextBuffer); precomputedQuickInfo.RequestQuickInfo(TextView, triggerPoint).ContinueWith((Task t) => { currentDispatcher.Invoke(() => { if (TextView != null) // Check whether detached { Thread.Sleep(100); var newSession = Provider.QuickInfoBroker.CreateQuickInfoSession(TextView, triggerPoint, true); if (newSession.Properties != null) { newSession.Properties.AddProperty(typeof(JavaQuickInfo), precomputedQuickInfo); newSession.Start(); Session = newSession; } } }); }); } } }
public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { SnapshotPoint?triggerPoint = session.GetTriggerPoint(TextBuffer.CurrentSnapshot); if (!triggerPoint.HasValue) { applicableToSpan = null; return; } JavaQuickInfo qi = null; if (session.Properties.TryGetProperty <JavaQuickInfo>(typeof(JavaQuickInfo), out qi)) { //quickInfoContent.Clear(); foreach (var o in qi.QuickInfoContent) { var display = o; if (display.Contains("{")) { display = display.Substring(0, display.IndexOf("{")); } if (display.Contains("[in")) { display = display.Substring(0, display.IndexOf("[in")); } //quickInfoContent.Add(o); quickInfoContent.Add(display); // TODO: Workaround to only show the declaration of the type and not the full location string } // Get whole word under point ITextStructureNavigator navigator = Provider.NavigatorService.GetTextStructureNavigator(TextBuffer); TextExtent extent = navigator.GetExtentOfWord(triggerPoint.Value); applicableToSpan = triggerPoint.Value.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive); } else { applicableToSpan = null; } }
void TextView_MouseHover(object sender, MouseHoverEventArgs e) { SnapshotPoint? point = TextView.BufferGraph.MapDownToFirstMatch( new SnapshotPoint(TextView.TextSnapshot, e.Position), PointTrackingMode.Positive, snapshot => SubjectBuffers.Contains(snapshot.TextBuffer), PositionAffinity.Predecessor); if (point != null) { ITrackingPoint triggerPoint = point.Value.Snapshot.CreateTrackingPoint(point.Value.Position, PointTrackingMode.Positive); var currentDispatcher = Dispatcher.CurrentDispatcher; if (!Provider.QuickInfoBroker.IsQuickInfoActive(TextView)) { JavaQuickInfo precomputedQuickInfo = new JavaQuickInfo(point.Value.Snapshot.TextBuffer); precomputedQuickInfo.RequestQuickInfo(TextView, triggerPoint).ContinueWith((Task t) => { currentDispatcher.Invoke(() => { if (TextView != null) // Check whether detached { Thread.Sleep(100); var newSession = Provider.QuickInfoBroker.CreateQuickInfoSession(TextView, triggerPoint, true); if (newSession.Properties != null) { newSession.Properties.AddProperty(typeof(JavaQuickInfo), precomputedQuickInfo); newSession.Start(); Session = newSession; } } }); }); } } }