Пример #1
0
        private void ShowVariableInsights(Token token, ToolTipRequestEventArgs args)
        {
            var stackFrames = _debuggerService.GetStackFrames();
            var stackFrame  = stackFrames?.FirstOrDefault();

            if (stackFrame == null)
            {
                return;
            }

            var variable =
                stackFrame?.LocalVariables.Children.FirstOrDefault(
                    x => x.Name.Equals(token.Text, StringComparison.InvariantCultureIgnoreCase));

            if (variable == null)
            {
                // Make sure to unset _currentToken since we can't find a variable named what we've selected.
                _currentToken = null;
                return;
            }

            // Create an inspectable object
            var inspectableObject = new Dictionary <string, object>
            {
                { variable.Name, variable.Value }
            };

            ShowInspectorWindow(inspectableObject);
        }
Пример #2
0
        public void HandleToolTipRequest(ToolTipRequestEventArgs args)
        {
            if (!args.InDocument)
            {
                return;
            }
            var offset = _editor.Document.GetOffset(args.LogicalPosition);

            //FoldingManager foldings = _editor.GetService(typeof(FoldingManager)) as FoldingManager;
            //if (foldings != null)
            //{
            //    var foldingsAtOffset = foldings.GetFoldingsAt(offset);
            //    FoldingSection collapsedSection = foldingsAtOffset.FirstOrDefault(section => section.IsFolded);

            //    if (collapsedSection != null)
            //    {
            //        args.SetToolTip(GetTooltipTextForCollapsedSection(args, collapsedSection));
            //    }
            //}

            var markersAtOffset   = _textMarkerService.GetMarkersAtOffset(offset);
            var markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);

            if (markerWithToolTip != null)
            {
                args.SetToolTip(markerWithToolTip.ToolTip);
            }
        }
Пример #3
0
        private void EditorOnToolTipRequest(object sender, ToolTipRequestEventArgs args)
        {
            var offset = _document.GetOffset(args.LogicalPosition);

            var markersAtOffset = GetMarkersAtOffset(offset);
            var markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);

            if (markerWithToolTip != null)
            {
                args.SetToolTip(markerWithToolTip.ToolTip);
            }
        }
Пример #4
0
        private void EditorOnToolTipRequest(object sender, ToolTipRequestEventArgs args)
        {
            var offset = _document.GetOffset(args.LogicalPosition);

            var markersAtOffset   = GetMarkersAtOffset(offset);
            var markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);

            if (markerWithToolTip != null)
            {
                args.SetToolTip(markerWithToolTip.ToolTip);
            }
        }
Пример #5
0
        private void OnMouseHover(object sender, MouseEventArgs e)
        {
            var position = TextArea.TextView.GetPositionFloor(e.GetPosition(TextArea.TextView) + TextArea.TextView.ScrollOffset);
            var args     = new ToolTipRequestEventArgs {
                InDocument = position.HasValue
            };

            if (!position.HasValue || position.Value.Location.IsEmpty)
            {
                return;
            }

            args.LogicalPosition = position.Value.Location;

            RaiseEvent(args);

            if (args.ContentToShow == null)
            {
                return;
            }

            if (_toolTip == null)
            {
                _toolTip = new ToolTip {
                    MaxWidth = 300
                };
                _toolTip.Closed += OnToolTipClosed;

                ToolTipService.SetInitialShowDelay(_toolTip, 0);
            }

            _toolTip.PlacementTarget = this;

            var stringContent = args.ContentToShow as string;

            if (stringContent != null)
            {
                _toolTip.Content = new TextBlock
                {
                    Text         = stringContent,
                    TextWrapping = TextWrapping.Wrap
                };
            }
            else
            {
                _toolTip.Content = args.ContentToShow;
            }

            e.Handled       = true;
            _toolTip.IsOpen = true;
        }
Пример #6
0
        private void OnToolTipRequest(object sender, ToolTipRequestEventArgs args)
        {
            if (!_debuggerService.IsActiveDebugging)
            {
                return;
            }

            var tokens =
                _languageContext.Tokens.Where(
                    x =>
                    x.Extent.StartLineNumber == args.LogicalPosition.Line &&
                    x.Extent.StartColumnNumber <= args.LogicalPosition.Column &&
                    x.Extent.EndColumnNumber >= args.LogicalPosition.Column)
                .ToList();

            if (tokens.Count > 0)
            {
                var token = tokens.First();

                if (_objectInspector != null)
                {
                    // We already have an object inspector open, close that.
                    if (_currentToken != token)
                    {
                        _objectInspector.Close();
                        _currentToken = null;
                    }
                }

                _currentToken = token;

                switch (token.Kind)
                {
                case TokenKind.Variable:
                    ShowVariableInsights(token, args);
                    break;

                default:
                    args.ContentToShow = token.Kind + ": " + token.Text;
                    break;
                }
            }
            else
            {
                _objectInspector?.Close();
                _currentToken = null;
            }
        }
        public void HandleToolTipRequest(ToolTipRequestEventArgs args)
        {
            if (!args.InDocument) return;
            var offset = _editor.Document.GetOffset(args.LogicalPosition);

            //FoldingManager foldings = _editor.GetService(typeof(FoldingManager)) as FoldingManager;
            //if (foldings != null)
            //{
            //    var foldingsAtOffset = foldings.GetFoldingsAt(offset);
            //    FoldingSection collapsedSection = foldingsAtOffset.FirstOrDefault(section => section.IsFolded);

            //    if (collapsedSection != null)
            //    {
            //        args.SetToolTip(GetTooltipTextForCollapsedSection(args, collapsedSection));
            //    }
            //}

            var markersAtOffset = _textMarkerService.GetMarkersAtOffset(offset);
            var markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);
            if (markerWithToolTip != null)
            {
                args.SetToolTip(markerWithToolTip.ToolTip);
            }
        }
Пример #8
0
        private void ShowVariableInsights(Token token, ToolTipRequestEventArgs args)
        {
            var stackFrames = _debuggerService.GetStackFrames();
            var stackFrame = stackFrames?.FirstOrDefault();

            if (stackFrame == null)
                return;

            var variable =
                stackFrame?.LocalVariables.Children.FirstOrDefault(
                    x => x.Name.Equals(token.Text, StringComparison.InvariantCultureIgnoreCase));

            if (variable == null)
            {
                // Make sure to unset _currentToken since we can't find a variable named what we've selected.
                _currentToken = null;
                return;
            }

            // Create an inspectable object
            var inspectableObject = new Dictionary<string, object>
            {
                {variable.Name, variable.Value}
            };

            ShowInspectorWindow(inspectableObject);
        }
Пример #9
0
        private void OnToolTipRequest(object sender, ToolTipRequestEventArgs args)
        {
            if (!_debuggerService.IsActiveDebugging)
                return;

            var tokens =
                _languageContext.Tokens.Where(
                    x =>
                        x.Extent.StartLineNumber == args.LogicalPosition.Line &&
                        x.Extent.StartColumnNumber <= args.LogicalPosition.Column &&
                        x.Extent.EndColumnNumber >= args.LogicalPosition.Column)
                    .ToList();

            if (tokens.Count > 0)
            {
                var token = tokens.First();

                if (_objectInspector != null)
                {
                    // We already have an object inspector open, close that.
                    if (_currentToken != token)
                    {
                        _objectInspector.Close();
                        _currentToken = null;
                    }
                }

                _currentToken = token;

                switch (token.Kind)
                {
                    case TokenKind.Variable:
                        ShowVariableInsights(token, args);
                        break;
                    default:
                        args.ContentToShow = token.Kind + ": " + token.Text;
                        break;
                }
            }
            else
            {
                _objectInspector?.Close();
                _currentToken = null;
            }
        }
Пример #10
0
        private void OnMouseHover(object sender, MouseEventArgs e)
        {
            var position = TextArea.TextView.GetPositionFloor(e.GetPosition(TextArea.TextView) + TextArea.TextView.ScrollOffset);
            var args = new ToolTipRequestEventArgs { InDocument = position.HasValue };

            if (!position.HasValue || position.Value.Location.IsEmpty)
            {
                return;
            }

            args.LogicalPosition = position.Value.Location;

            RaiseEvent(args);

            if (args.ContentToShow == null) return;

            if (_toolTip == null)
            {
                _toolTip = new ToolTip { MaxWidth = 300 };
                _toolTip.Closed += OnToolTipClosed;

                ToolTipService.SetInitialShowDelay(_toolTip, 0);
            }

            _toolTip.PlacementTarget = this;

            var stringContent = args.ContentToShow as string;

            if (stringContent != null)
            {
                _toolTip.Content = new TextBlock
                {
                    Text = stringContent,
                    TextWrapping = TextWrapping.Wrap
                };
            }
            else
            {
                _toolTip.Content = args.ContentToShow;
            }

            e.Handled = true;
            _toolTip.IsOpen = true;
        }