예제 #1
0
        protected virtual int GetDataTipTextImpl(TextSpan[] pSpan, out string pbstrText)
        {
            pbstrText = null;

            var debugInfo = _languageService.LanguageDebugInfo;

            if (debugInfo != null)
            {
                var subjectBuffer = WpfTextView.GetBufferContainingCaret();
                if (subjectBuffer == null)
                {
                    return(VSConstants.E_FAIL);
                }

                var vsBuffer = EditorAdaptersFactory.GetBufferAdapter(subjectBuffer);

                // TODO: broken in REPL
                if (vsBuffer == null)
                {
                    return(VSConstants.E_FAIL);
                }

                return(debugInfo.GetDataTipText(vsBuffer, pSpan, pbstrText));
            }

            return(VSConstants.E_FAIL);
        }
예제 #2
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView textView = EditorAdaptersFactory.GetWpfTextView(textViewAdapter);

            if (textView == null)
            {
                return;
            }
            ITextStructureNavigator navigator = TextStructureNavigatorSelector.GetTextStructureNavigator(textView.TextBuffer);

            AddCommandFilter(textViewAdapter, new MyCommandFilter(textView, navigator, ServiceProvider));
        }
        internal AbstractOleCommandTarget AttachToVsTextView()
        {
            var vsTextView = EditorAdaptersFactory.GetViewAdapter(WpfTextView);

            // Add command filter to IVsTextView. If something goes wrong, throw.
            var returnValue = vsTextView.AddCommandFilter(this, out var nextCommandTarget);

            Marshal.ThrowExceptionForHR(returnValue);
            Contract.ThrowIfNull(nextCommandTarget);

            NextCommandTarget = nextCommandTarget;

            return(this);
        }
예제 #4
0
        protected int GetDataTipTextImpl(ITextBuffer subjectBuffer, TextSpan[] pSpan, AbstractLanguageService <TPackage, TLanguageService> .VsLanguageDebugInfo debugInfo, out string pbstrText)
        {
            pbstrText = null;

            var vsBuffer = EditorAdaptersFactory.GetBufferAdapter(subjectBuffer);

            // TODO: broken in REPL
            if (vsBuffer == null)
            {
                return(VSConstants.E_FAIL);
            }

            return(debugInfo.GetDataTipText(vsBuffer, pSpan, out pbstrText));
        }
예제 #5
0
        public void TextViewCreated(IWpfTextView textView)
        {
            CommandFilter filter = new CommandFilter(textView, SmartIndentation);
            IVsTextView   view   = EditorAdaptersFactory.GetViewAdapter(textView);

            if (view != null)
            {
                IOleCommandTarget next = null;

                int result = view.AddCommandFilter(filter, out next);
                if (result == VSConstants.S_OK)
                {
                    filter.Next = next;
                }
            }
        }
예제 #6
0
        public void VsTextViewCreated(IVsTextView textViewAdapter)
        {
            IWpfTextView wpfTextView = EditorAdaptersFactory.GetWpfTextView(textViewAdapter);

            wpfTextView.Options.OptionChanged += OnOptionsChanged;
            if (wpfTextView.Roles.Contains("PRIMARYDOCUMENT"))
            {
                CommandRouter commandRouter = CommandRouterProvider.GetCommandRouter(wpfTextView);
                commandRouter.AddCommandTarget(new EmacsCommandsFilter(wpfTextView, Manager, commandRouter));
                commandRouter.AddCommandTarget(Manager.GetOrCreateMarkSession(wpfTextView));
                commandRouter.AddCommandTarget(Manager.GetOrCreateUniversalArgumentSession(wpfTextView));
                commandRouter.AddCommandTarget(Manager.GetOrCreateKillClipboardSession(wpfTextView));
            }
            else
            {
                var workAroundFilter = new InteractiveRoleWorkAroundFilter(wpfTextView, Manager);
                IOleCommandTarget ppNextCmdTarg;
                textViewAdapter.AddCommandFilter(workAroundFilter, out ppNextCmdTarg);
                workAroundFilter.NextCommandTarget = ppNextCmdTarg;
            }
        }
        protected int GetDataTipTextImpl(ITextBuffer subjectBuffer, TextSpan[] pSpan, out string pbstrText)
        {
            pbstrText = null;

            var vsBuffer = EditorAdaptersFactory.GetBufferAdapter(subjectBuffer);

            // TODO: broken in REPL
            if (vsBuffer == null)
            {
                return(VSConstants.E_FAIL);
            }

            using (Logger.LogBlock(FunctionId.Debugging_VsLanguageDebugInfo_GetDataTipText, CancellationToken.None))
            {
                pbstrText = null;
                if (pSpan == null || pSpan.Length != 1)
                {
                    return(VSConstants.E_INVALIDARG);
                }

                var    result            = VSConstants.E_FAIL;
                string pbstrTextInternal = null;

                var uiThreadOperationExecutor = ComponentModel.GetService <IUIThreadOperationExecutor>();
                uiThreadOperationExecutor.Execute(
                    title: ServicesVSResources.Debugger,
                    defaultDescription: ServicesVSResources.Getting_DataTip_text,
                    allowCancellation: true,
                    showProgress: false,
                    action: context =>
                {
                    IServiceProvider serviceProvider = ComponentModel.GetService <SVsServiceProvider>();
                    var debugger  = (IVsDebugger)serviceProvider.GetService(typeof(SVsShellDebugger));
                    var debugMode = new DBGMODE[1];

                    var cancellationToken = context.UserCancellationToken;
                    if (ErrorHandler.Succeeded(debugger.GetMode(debugMode)) && debugMode[0] != DBGMODE.DBGMODE_Design)
                    {
                        var textSpan = pSpan[0];

                        var textSnapshot = subjectBuffer.CurrentSnapshot;
                        var document     = textSnapshot.GetOpenDocumentInCurrentContextWithChanges();

                        if (document != null)
                        {
                            var languageDebugInfo = document.Project.LanguageServices.GetService <ILanguageDebugInfoService>();
                            if (languageDebugInfo != null)
                            {
                                var spanOpt = textSnapshot.TryGetSpan(textSpan);
                                if (spanOpt.HasValue)
                                {
                                    var dataTipInfo = languageDebugInfo.GetDataTipInfoAsync(document, spanOpt.Value.Start, cancellationToken).WaitAndGetResult(cancellationToken);
                                    if (!dataTipInfo.IsDefault)
                                    {
                                        var resultSpan = dataTipInfo.Span.ToSnapshotSpan(textSnapshot);
                                        var textOpt    = dataTipInfo.Text;

                                        pSpan[0] = resultSpan.ToVsTextSpan();
                                        result   = debugger.GetDataTipValue((IVsTextLines)vsBuffer, pSpan, textOpt, out pbstrTextInternal);
                                    }
                                }
                            }
                        }
                    }
                });

                pbstrText = pbstrTextInternal;
                return(result);
            }
        }