private void AdddropdownBar(IVsDropdownBarManager dropdownManager)
            {
                IVsTextLines buffer;

                if (ErrorHandler.Failed(_codeWindow.GetBuffer(out buffer)))
                {
                    return;
                }

                var navigationBarClient      = new NavigationBarClient(dropdownManager, _codeWindow, _languageService.SystemServiceProvider, _languageService.Workspace);
                var textBuffer               = _languageService.EditorAdaptersFactoryService.GetDataBuffer(buffer);
                var controllerFactoryService = _languageService.Package.ComponentModel.GetService <INavigationBarControllerFactoryService>();
                var newController            = controllerFactoryService.CreateController(navigationBarClient, textBuffer);
                var hr = dropdownManager.AddDropdownBar(cCombos: 3, pClient: navigationBarClient);

                if (ErrorHandler.Failed(hr))
                {
                    newController.Disconnect();
                    ErrorHandler.ThrowOnFailure(hr);
                }

                _navigationBarController = newController;
                _dropdownBarClient       = navigationBarClient;
                return;
            }
        public static IVsTextLines GetBuffer(this IVsCodeWindow codeWindow)
        {
            Contract.Requires <ArgumentNullException>(codeWindow != null, "codeWindow");

            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(codeWindow.GetBuffer(out buffer));
            return(buffer);
        }
Beispiel #3
0
        public static IVsTextLines GetBuffer([NotNull] this IVsCodeWindow codeWindow)
        {
            Requires.NotNull(codeWindow, nameof(codeWindow));

            IVsTextLines buffer;

            ErrorHandler.ThrowOnFailure(codeWindow.GetBuffer(out buffer));
            return(buffer);
        }
        /// <include file='doc\TextBuffer.uex' path='docs/doc[@for="TextBuffer.ShowCode2"]/*' />
        /// <devdoc>
        ///     If there is a text view associated with this buffer, this will
        ///     attempt to surface this view to the user.  The caret will be
        ///     moved to lineNum, columnNum.
        /// </devdoc>
        public override void ShowCode(int lineNum, int columnNum)
        {
            try {
                // First get the frame of the code editor.
                //
                IVsWindowFrame frame = GetWindowFrame(LOGVIEWID.LOGVIEWID_Code);

                // Next ask the text manager to navigate to the requested place.
                //
                Object obj = null;
#if GETPROPERTY_MARSHAL
                int hr = frame.GetProperty(__VSFPROPID.VSFPROPID_DocView, ref obj);
                if (!win.Succeeded(hr))
                {
                    throw new COMException("Error retrieving document view", hr);
                }
#else
                obj = frame.GetProperty(__VSFPROPID.VSFPROPID_DocView);
#endif
                IVsCodeWindow codeWindow = (IVsCodeWindow)obj;

                // Buffer is zero based.
                if (lineNum > 0)
                {
                    lineNum--;
                }

                if (columnNum > 0)
                {
                    columnNum--;
                }

                Debug.Assert(codeWindow != null, "Cannot get to code editor");
                if (codeWindow != null)
                {
                    IVsTextLines textLines;
                    codeWindow.GetBuffer(out textLines);

                    IVsTextManager mgr = (IVsTextManager)serviceProvider.
                                         GetService(typeof(VsTextManager));

                    if (mgr != null)
                    {
                        mgr.NavigateToLineAndColumn((IVsTextBuffer)textLines, ref LOGVIEWID.LOGVIEWID_Code, lineNum, columnNum, lineNum, columnNum);
                    }
                }

                // And finally, show the frame.
                //
                // SBurke, Naviagate to position should do the show...
                //frame.Show();
            }
            catch (Exception ex) {
                Debug.Fail("Could not show text editor because: " + ex.ToString());
            }
        }
Beispiel #5
0
        public int GetBuffer(out IVsTextLines ppBuffer)
        {
            IVsCodeWindow vsCodeWindow = SourceCodeWindow;

            if (vsCodeWindow != null)
            {
                return(vsCodeWindow.GetBuffer(out ppBuffer));
            }
            ppBuffer = null;
            return(VSConstants.E_NOTIMPL);
        }
        public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
        {
            var adaptersFactory = _serviceProvider.GetComponentModel().GetService<IVsEditorAdaptersFactoryService>();

            IVsTextLines textLines;
            ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines));
            var textBuffer = adaptersFactory.GetDataBuffer(textLines);
            if (textBuffer == null)
            {
                ppCodeWinMgr = null;
                return VSConstants.E_FAIL;
            }

            ppCodeWinMgr = _serviceProvider.GetHlslToolsService().GetOrCreateCodeWindowManager(pCodeWin);
            return VSConstants.S_OK;
        }
        public int GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
        {
            var adaptersFactory = _serviceProvider.GetComponentModel().GetService <IVsEditorAdaptersFactoryService>();

            IVsTextLines textLines;

            ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines));
            var textBuffer = adaptersFactory.GetDataBuffer(textLines);

            if (textBuffer == null)
            {
                ppCodeWinMgr = null;
                return(VSConstants.E_FAIL);
            }

            ppCodeWinMgr = _languagePackage.GetOrCreateCodeWindowManager(pCodeWin);
            return(VSConstants.S_OK);
        }
Beispiel #8
0
        int IVsLanguageInfo.GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
        {
            IVsEditorAdaptersFactoryService adaptersFactory = ComponentModel.GetService <IVsEditorAdaptersFactoryService>();

            IVsTextLines textLines;

            ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines));
            ITextBuffer textBuffer = adaptersFactory.GetDataBuffer(textLines);

            if (textBuffer == null)
            {
                ppCodeWinMgr = null;
                return(VSConstants.E_FAIL);
            }

            ppCodeWinMgr = GetCodeWindowManager(pCodeWin, textBuffer);
            return(VSConstants.S_OK);
        }
Beispiel #9
0
 int IVsLanguageInfo.GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
 {
     IVsTextLines lines;
     IVsEditorAdaptersFactoryService service = this.ComponentModel.GetService<IVsEditorAdaptersFactoryService>();
     ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out lines));
     IVsTextBuffer bufferAdapter = lines;
     ITextBuffer dataBuffer = service.GetDataBuffer(bufferAdapter);
     if (dataBuffer == null)
     {
         ppCodeWinMgr = null;
         return -2147467259;
     }
     ppCodeWinMgr = this.GetCodeWindowManager(pCodeWin, dataBuffer);
     return 0;
 }
Beispiel #10
0
 public int GetBuffer(out IVsTextLines ppBuffer)
 {
     return(codeWindow.GetBuffer(out ppBuffer));
 }
Beispiel #11
0
 // GetCodeWindowManager -- this gives us the VsCodeWindow which is what we need to
 // add adornments and so forth.
 /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.GetCodeWindowManager"]/*' />
 public int GetCodeWindowManager(IVsCodeWindow codeWindow, out IVsCodeWindowManager mgr) {
     Initialize();
     IVsTextLines buffer = null;
     NativeMethods.ThrowOnFailure(codeWindow.GetBuffer(out buffer));
     mgr = CreateCodeWindowManager(codeWindow, GetOrCreateSource(buffer));
     return NativeMethods.S_OK;
 }
Beispiel #12
0
 int IVsCodeWindow.GetBuffer(out IVsTextLines ppBuffer) => _editorWindow.GetBuffer(out ppBuffer);
Beispiel #13
0
        int IVsLanguageInfo.GetCodeWindowManager(IVsCodeWindow pCodeWin, out IVsCodeWindowManager ppCodeWinMgr)
        {
            IVsEditorAdaptersFactoryService adaptersFactory = ComponentModel.GetService<IVsEditorAdaptersFactoryService>();

            IVsTextLines textLines;
            ErrorHandler.ThrowOnFailure(pCodeWin.GetBuffer(out textLines));
            ITextBuffer textBuffer = adaptersFactory.GetDataBuffer(textLines);
            if (textBuffer == null)
            {
                ppCodeWinMgr = null;
                return VSConstants.E_FAIL;
            }

            ppCodeWinMgr = GetCodeWindowManager(pCodeWin, textBuffer);
            return VSConstants.S_OK;
        }
        // GetCodeWindowManager -- this gives us the VsCodeWindow which is what we need to
        // add adornments and so forth.
        /// <include file='doc\LanguageService.uex' path='docs/doc[@for="LanguageService.GetCodeWindowManager"]/*' />
        public int GetCodeWindowManager(IVsCodeWindow codeWindow, out IVsCodeWindowManager mgr)
        {
            //set the inheritKeyBinding guid so that navigation keys work. Do this before deriving class's
            //CreateCodeWindowManager method gets called, so they may override if required
            IOleServiceProvider sp = codeWindow as IOleServiceProvider;
            if (sp != null) {
                ServiceProvider site = new ServiceProvider(sp);
                object window = site.GetService(typeof(IVsWindowFrame).GUID);
                if (window is IVsWindowFrame) {
                    IVsWindowFrame frame = (IVsWindowFrame)window;
                    Guid CMDUIGUID_TextEditor = new Guid(0x8B382828, 0x6202, 0x11d1, 0x88, 0x70, 0x00, 0x00, 0xF8, 0x75, 0x79, 0xD2);
                    NativeMethods.ThrowOnFailure(frame.SetGuidProperty((int)__VSFPROPID.VSFPROPID_InheritKeyBindings, ref CMDUIGUID_TextEditor));
                }
            }

            Initialize();
            IVsTextLines buffer = null;
            NativeMethods.ThrowOnFailure(codeWindow.GetBuffer(out buffer));
            mgr = CreateCodeWindowManager(codeWindow, GetOrCreateSource(buffer));
            return NativeMethods.S_OK;
        }