void DestroyWindow() { Runtime.AssertMainThread(); if (window != null) { window.Close(); window = null; } if (lastView != null) { lastView.LayoutChanged -= LayoutChanged; #if CLOSE_ON_FOCUS_LOST lastView.LostAggregateFocus -= View_LostAggregateFocus; #endif lastView = null; } if (lastDocumentView != null) { lastDocumentView.ContentHidden -= DocumentView_ContentHidden; lastDocumentView = null; } }
private async Task EvaluateAndShowTooltipAsync(IAsyncQuickInfoSession session, ITextView view, SnapshotPoint point, DataTipInfo debugInfo, CancellationToken cancellationToken) { var options = DebuggingService.DebuggerSession.EvaluationOptions.Clone(); options.AllowMethodEvaluation = true; options.AllowTargetInvoke = true; var val = DebuggingService.CurrentFrame.GetExpressionValue(debugInfo.Text, options); if (val.IsEvaluating) { await WaitOneAsync(val.WaitHandle, cancellationToken); } if (cancellationToken.IsCancellationRequested) { return; } if (val == null || val.IsUnknown || val.IsNotSupported) { return; } if (!view.Properties.TryGetProperty(typeof(Widget), out Widget gtkParent)) { return; } provider.textDocumentFactoryService.TryGetTextDocument(view.TextDataModel.DocumentBuffer, out var textDocument); // This is a bit hacky, since AsyncQuickInfo is designed to display multiple elements if multiple sources // return value, we don't want that for debugger value hovering, hence we dismiss AsyncQuickInfo // and do our own thing, notice VS does same thing await session.DismissAsync(); await provider.joinableTaskContext.Factory.SwitchToMainThreadAsync(); lastView = view; val.Name = debugInfo.Text; #if MAC var location = new PinnedWatchLocation(textDocument?.FilePath); var snapshot = view.TextDataModel.DocumentBuffer.CurrentSnapshot; int line, column; var start = debugInfo.Span.GetStartPoint(snapshot); snapshot.GetLineAndColumn(start, out line, out column); location.Column = column; location.Line = line; var end = debugInfo.Span.GetEndPoint(snapshot); snapshot.GetLineAndColumn(end, out line, out column); location.EndColumn = column; location.EndLine = line; window = new MacDebuggerTooltipWindow(location, DebuggingService.CurrentFrame, val, watch: null); view.LayoutChanged += LayoutChanged; #if CLOSE_ON_FOCUS_LOST view.LostAggregateFocus += View_LostAggregateFocus; #endif RegisterForHiddenAsync(view).Ignore(); var cocoaView = (ICocoaTextView)view; var bounds = view.TextViewLines.GetCharacterBounds(point); var rect = new CoreGraphics.CGRect(bounds.Left - view.ViewportLeft, bounds.Top - view.ViewportTop, bounds.Width, bounds.Height); window.Show(rect, cocoaView.VisualElement, AppKit.NSRectEdge.MaxXEdge); #else throw new NotImplementedException(); #endif }