internal void PopupQuickFixMenu(Gdk.EventButton evt, CodeActionContainer fixes, Action <CodeFixMenu> menuAction, Xwt.Point?point = null)
        {
            var token = quickFixCancellationTokenSource.Token;

            if (token.IsCancellationRequested)
            {
                return;
            }

            var menu = CodeFixMenuService.CreateFixMenu(Editor, fixes, token);

            if (token.IsCancellationRequested)
            {
                return;
            }

            if (menu.Items.Count == 0)
            {
                return;
            }

            if (menuAction != null)
            {
                menuAction(menu);
            }
            Gdk.Rectangle rect;
            Widget        widget = Editor;

            if (!point.HasValue)
            {
                var p = Editor.LocationToPoint(Editor.CaretLocation);
                rect = new Gdk.Rectangle(
                    (int)p.X + widget.Allocation.X,
                    (int)p.Y + widget.Allocation.Y, 0, 0);
            }
            else
            {
                rect = new Gdk.Rectangle((int)point.Value.X, (int)point.Value.Y, 0, 0);
            }
            ShowFixesMenu(widget, rect, menu);
        }
Example #2
0
        async void PopupQuickFixMenu(Gdk.EventButton evt, Action <CodeFixMenu> menuAction)
        {
            using (Counters.FixesMenu.BeginTiming("Show quick fixes menu")) {
                var token = quickFixCancellationTokenSource.Token;

                var fixes = await GetCurrentFixesAsync(token);

                if (token.IsCancellationRequested)
                {
                    return;
                }

                var menu = CodeFixMenuService.CreateFixMenu(Editor, fixes, token);
                if (token.IsCancellationRequested)
                {
                    return;
                }

                if (menu.Items.Count == 0)
                {
                    return;
                }

                Editor.SuppressTooltips = true;
                if (menuAction != null)
                {
                    menuAction(menu);
                }

                var    p      = Editor.LocationToPoint(Editor.OffsetToLocation(currentSmartTagBegin));
                Widget widget = Editor;
                var    rect   = new Gdk.Rectangle(
                    (int)p.X + widget.Allocation.X,
                    (int)p.Y + widget.Allocation.Y, 0, 0);

                ShowFixesMenu(widget, rect, menu);
            }
        }
        async void PopupQuickFixMenu(Gdk.EventButton evt, Action <CodeFixMenu> menuAction)
        {
            var menu = await CodeFixMenuService.CreateFixMenu(Editor, await GetCurrentFixesAsync(default(CancellationToken)));

            if (menu.Items.Count == 0)
            {
                return;
            }

            Editor.SuppressTooltips = true;
            if (menuAction != null)
            {
                menuAction(menu);
            }

            var    p      = Editor.LocationToPoint(Editor.OffsetToLocation(currentSmartTagBegin));
            Widget widget = Editor;
            var    rect   = new Gdk.Rectangle(
                (int)p.X + widget.Allocation.X,
                (int)p.Y + widget.Allocation.Y, 0, 0);

            ShowFixesMenu(widget, rect, menu);
        }