Пример #1
0
        public async Task <object> UpdateToolTipAsync()
        {
            if (VisualRoot == null)
            {
                return(null);
            }

            var mouseDevice = (VisualRoot as IInputRoot)?.MouseDevice;
            var position    = GetPositionFromPoint(mouseDevice.GetPosition(this));

            if (position.HasValue)
            {
                var offset = Document.GetOffset(position.Value.Location);

                var matching = Diagnostics?.FindSegmentsContaining(offset).FirstOrDefault();

                if (matching != null)
                {
                    return(new ErrorProbeViewModel(matching));
                }

                var tooltipRequestEventArgs = new TooltipDataRequestEventArgs();

                RequestTooltipContent?.Invoke(this, tooltipRequestEventArgs);

                if (tooltipRequestEventArgs.GetViewModelAsyncTask != null)
                {
                    return(await tooltipRequestEventArgs.GetViewModelAsyncTask(offset));
                }
            }

            return(null);
        }
Пример #2
0
        public async Task <object> UpdateToolTipAsync()
        {
            if (VisualRoot == null)
            {
                return(null);
            }

            var mouseDevice = (VisualRoot as IInputRoot)?.MouseDevice;
            var position    = GetPositionFromPoint(mouseDevice.GetPosition(this));

            if (position.HasValue)
            {
                var offset = Document.GetOffset(position.Value.Location);

                var matching = _diagnosticMarkersRenderer?.GetMarkersAtOffset(offset).FirstOrDefault()?.Diagnostic;

                if (matching != null && matching.Level != DiagnosticLevel.Hidden)
                {
                    return(new ErrorProbeViewModel(matching));
                }

                if (LanguageService != null)
                {
                    var symbol = await LanguageService?.GetSymbolAsync(DocumentAccessor, UnsavedFiles, 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));
                        }
                    }
                }

                var tooltipRequestEventArgs = new TooltipDataRequestEventArgs();

                RequestTooltipContent?.Invoke(this, tooltipRequestEventArgs);

                if (tooltipRequestEventArgs.GetViewModelAsyncTask != null)
                {
                    return(await tooltipRequestEventArgs.GetViewModelAsyncTask(offset));
                }
            }

            return(null);
        }
Пример #3
0
        public virtual async Task <object> GetToolTipContentAsync(int offset)
        {
            var args = new TooltipDataRequestEventArgs(this, offset);

            TooltipContentRequested?.Invoke(this, args);

            if (args.GetViewModelAsyncTask != null)
            {
                return(await args.GetViewModelAsyncTask(this, offset));
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        public async Task <object> UpdateToolTipAsync()
        {
            if (VisualRoot == null)
            {
                return(null);
            }

            var mouseDevice = (VisualRoot as IInputRoot)?.MouseDevice;
            var position    = GetPositionFromPoint(mouseDevice.GetPosition(this));

            if (position.HasValue)
            {
                var offset = Document.GetOffset(position.Value.Location);

                var matching = _diagnosticMarkersRenderer?.GetMarkersAtOffset(offset).FirstOrDefault()?.Diagnostic;

                if (matching != null && matching.Level != DiagnosticLevel.Hidden)
                {
                    return(new ErrorProbeViewModel(matching));
                }

                if (LanguageService != null)
                {
                    var quickInfo = await LanguageService?.QuickInfo(DocumentAccessor, UnsavedFiles, offset);

                    if (quickInfo != null)
                    {
                        return(new QuickInfoViewModel(quickInfo));
                    }
                }

                var tooltipRequestEventArgs = new TooltipDataRequestEventArgs();

                RequestTooltipContent?.Invoke(this, tooltipRequestEventArgs);

                if (tooltipRequestEventArgs.GetViewModelAsyncTask != null)
                {
                    return(await tooltipRequestEventArgs.GetViewModelAsyncTask(offset));
                }
            }

            return(null);
        }