示例#1
0
        IVsTextLines GetTextBuffer(IntPtr docDataExisting)
        {
            IVsTextLines textLines;

            if (docDataExisting == IntPtr.Zero)
            {
                // Create a new IVsTextLines buffer.
                //
                Type textLinesType = typeof(IVsTextLines);
                Guid riid          = textLinesType.GUID;
                Guid clsid         = typeof(VsTextBufferClass).GUID;
                textLines = _package.CreateInstance(ref clsid, ref riid, textLinesType) as IVsTextLines;

                // Set the buffer's site/
                //
                ((IObjectWithSite)textLines).SetSite(_serviceProvider.GetService(typeof(IOleServiceProvider)));
            }
            else
            {
                // Use the existing text buffer.
                //
                Object dataObject = Marshal.GetObjectForIUnknown(docDataExisting);

                textLines = dataObject as IVsTextLines;

                if (textLines == null)
                {
                    // Try get the text buffer from textbuffer provider.
                    //
                    IVsTextBufferProvider textBufferProvider = dataObject as IVsTextBufferProvider;

                    if (textBufferProvider != null)
                    {
                        textBufferProvider.GetTextBuffer(out textLines);
                    }
                }

                if (textLines == null)
                {
                    // Unknown docData type then, so we have to force VS to close the other editor.
                    //
                    ErrorHandler.ThrowOnFailure(VSConstants.VS_E_INCOMPATIBLEDOCDATA);
                }
            }

            return(textLines);
        }
示例#2
0
        IVsSmartTagTipWindow GetSmartTagTipWindow()
        {
            NemerlePackage pkg = Package;

            if (_smartTagWin == null)
            {
                Type typeSTagWin  = typeof(VsSmartTagTipWindowClass);
                Guid clsidSTagWin = typeSTagWin.GUID;
                Guid iidSTagWin   = typeof(IVsSmartTagTipWindow).GUID;
                _smartTagWin = (IVsSmartTagTipWindow)pkg.CreateInstance(ref clsidSTagWin, ref iidSTagWin, typeSTagWin);
                Debug.Assert(_smartTagWin != null);
            }

            return(_smartTagWin);
        }