Inheritance: AvalonStudio.Debugging.WatchListViewModel
        public async Task <object> UpdateToolTipAsync(int offset)
        {
            if (offset != -1 && ShellViewModel.Instance.CurrentPerspective == Perspective.Editor)
            {
                var symbol = await _editor?.GetSymbolAsync(offset);

                if (symbol != null)
                {
                    switch (symbol.Kind)
                    {
                    case CursorKind.CompoundStatement:
                    case CursorKind.NoDeclarationFound:
                    case CursorKind.NotImplemented:
                    case CursorKind.FirstDeclaration:
                    case CursorKind.InitListExpression:
                    case CursorKind.IntegerLiteral:
                    case CursorKind.ReturnStatement:
                    case CursorKind.WhileStatement:
                    case CursorKind.BinaryOperator:
                        return(null);

                    default:
                        return(new SymbolViewModel(symbol));
                    }
                }
            }

            if (offset != -1 && ShellViewModel.Instance.CurrentPerspective == Perspective.Debug)
            {
                var expression = _editor?.GetWordAtOffset(offset);

                if (expression != string.Empty)
                {
                    var debugManager = IoC.Get <IDebugManager2>();

                    var newToolTip = new DebugHoverProbeViewModel();

                    bool result = newToolTip.AddWatch(expression);

                    return(newToolTip);
                }
            }

            return(null);
        }
Beispiel #2
0
        public async Task <bool> UpdateToolTipAsync(int offset)
        {
            if (offset != -1 && ShellViewModel.Instance.CurrentPerspective == Perspective.Editor)
            {
                var matching = Model.CodeAnalysisResults?.Diagnostics.FindSegmentsContaining(offset).FirstOrDefault();

                if (matching != null)
                {
                    ToolTip = new ErrorProbeViewModel(matching);

                    return(true);
                }
            }

            if (offset != -1 && ShellViewModel.Instance.CurrentPerspective == Perspective.Editor && Model.LanguageService != null)
            {
                var symbol = await Model.LanguageService.GetSymbolAsync(Model.ProjectFile, EditorModel.UnsavedFiles.ToList(), offset);

                if (symbol != null)
                {
                    switch (symbol.Kind)
                    {
                    case CursorKind.CompoundStatement:
                    case CursorKind.NoDeclarationFound:
                    case CursorKind.NotImplemented:
                    case CursorKind.FirstDeclaration:
                    case CursorKind.InitListExpression:
                    case CursorKind.IntegerLiteral:
                    case CursorKind.ReturnStatement:
                        break;

                    default:

                        ToolTip = new SymbolViewModel(symbol);
                        return(true);
                    }
                }
            }

            if (offset != -1 && ShellViewModel.Instance.CurrentPerspective == Perspective.Debug)
            {
                var expression = GetWordAtOffset(offset);

                if (expression != string.Empty)
                {
                    var debugManager = IoC.Get <IDebugManager>();

                    var evaluatedExpression = await debugManager.ProbeExpressionAsync(expression);

                    if (evaluatedExpression != null)
                    {
                        var newToolTip = new DebugHoverProbeViewModel(debugManager);
                        newToolTip.AddExistingWatch(evaluatedExpression);

                        ToolTip = newToolTip;
                        return(true);
                    }
                }
            }

            return(false);
        }