public override Window CreateTooltipWindow(TextEditor editor, DocumentContext ctx, TooltipItem item, int offset, Xwt.ModifierKeys modifierState)
        {
            var position = editor.OffsetToLocation(offset);
            var location = new PinnedWatchLocation(editor.FileName)
            {
                Line      = position.Line,
                Column    = position.Column,
                EndLine   = position.Line,
                EndColumn = position.Column
            };

            var window = new DebugValueWindow((Gtk.Window)(editor.GetNativeWidget <Gtk.Widget> ()).Toplevel, location, DebuggingService.CurrentFrame, (ObjectValue)item.Item, null);

            IdeApp.CommandService.RegisterTopWindow(window);
            return(window);
        }
예제 #2
0
        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
        }