public VsInteractiveWindowCommandFilter(IVsEditorAdaptersFactoryService adapterFactory, IInteractiveWindow window, IVsTextView textViewAdapter, IVsTextBuffer bufferAdapter, IEnumerable<Lazy<IVsInteractiveWindowOleCommandTargetProvider, ContentTypeMetadata>> oleCommandTargetProviders, IContentTypeRegistryService contentTypeRegistry)
        {
            _window = window;
            _oleCommandTargetProviders = oleCommandTargetProviders;
            _contentTypeRegistry = contentTypeRegistry;

            this.textViewAdapter = textViewAdapter;

            // make us a code window so we'll have the same colors as a normal code window.
            IVsTextEditorPropertyContainer propContainer;
            ErrorHandler.ThrowOnFailure(((IVsTextEditorPropertyCategoryContainer)textViewAdapter).GetPropertyCategory(Microsoft.VisualStudio.Editor.DefGuidList.guidEditPropCategoryViewMasterSettings, out propContainer));
            propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewComposite_AllCodeWindowDefaults, true);
            propContainer.SetProperty(VSEDITPROPID.VSEDITPROPID_ViewGlobalOpt_AutoScrollCaretOnTextEntry, true);

            // editor services are initialized in textViewAdapter.Initialize - hook underneath them:
            _preEditorCommandFilter = new CommandFilter(this, CommandFilterLayer.PreEditor);
            ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preEditorCommandFilter, out _editorCommandFilter));

            textViewAdapter.Initialize(
                (IVsTextLines)bufferAdapter,
                IntPtr.Zero,
                (uint)TextViewInitFlags.VIF_HSCROLL | (uint)TextViewInitFlags.VIF_VSCROLL | (uint)TextViewInitFlags3.VIF_NO_HWND_SUPPORT,
                new[] { new INITVIEW { fSelectionMargin = 0, fWidgetMargin = 0, fVirtualSpace = 0, fDragDropMove = 1 } });

            // disable change tracking because everything will be changed
            var textViewHost = adapterFactory.GetWpfTextViewHost(textViewAdapter);

            _preLanguageCommandFilter = new CommandFilter(this, CommandFilterLayer.PreLanguage);
            ErrorHandler.ThrowOnFailure(textViewAdapter.AddCommandFilter(_preLanguageCommandFilter, out _editorServicesCommandFilter));

            _textViewHost = textViewHost;
        }
예제 #2
0
        public int GetNameOfLocation(IVsTextBuffer pBuffer, int iLine, int iCol, out string pbstrName, out int piLineOffset)
        {
            pbstrName = null;
            piLineOffset = 0;
            return VSConstants.E_FAIL;

            //var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
            //var service = model.GetService<IVsEditorAdaptersFactoryService>();
            //var buffer = service.GetDataBuffer(pBuffer);
            //IAlpaProjectEntry projEntry;
            //if (buffer.TryGetAlpaProjectEntry(out projEntry))
            //{
            //    var tree = projEntry.Tree;
            //    var name = FindNodeInTree(tree, tree.Body as SuiteStatement, iLine);
            //    if (name != null)
            //    {
            //        pbstrName = projEntry.Analysis.ModuleName + "." + name;
            //        piLineOffset = iCol;
            //    }
            //    else
            //    {
            //        pbstrName = projEntry.Analysis.ModuleName;
            //        piLineOffset = iCol;
            //    }
            //    return VSConstants.S_OK;
            //}

            //pbstrName = "";
            //piLineOffset = iCol;
            //return VSConstants.S_OK;
        }
        public ITextBuffer GetDataBuffer(IVsTextBuffer bufferAdapter)
        {
            ITextBuffer tb = null;
            _vsTextBufferAdapters.TryGetValue(bufferAdapter, out tb);

            return tb;
        }
예제 #4
0
        public PieScanner(IVsTextBuffer buffer)
        {
            m_buffer = buffer;

            grammar = new PieGrammar();
            parser = new Irony.Parsing.Parser(grammar);
            parser.Context.Mode = Irony.Parsing.ParseMode.VsLineScan;
        }
예제 #5
0
        public TextStreamEventAdapter(IVsTextBuffer buffer)
        {
            if (buffer == null) throw new ArgumentNullException("buffer");

            var cpContainer = buffer as IConnectionPointContainer;
            Guid riid = typeof(IVsTextStreamEvents).GUID;
            cpContainer.FindConnectionPoint(ref riid, out _connectionPoint);

            _connectionPoint.Advise(this, out _connectionCookie);
        }
예제 #6
0
        public override int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, TextSpan[] pCodeSpan) {
            pCodeSpan[0] = default(TextSpan);
            pCodeSpan[0].iStartLine = iLine;
            pCodeSpan[0].iEndLine = iLine;

            // Returning E_NOTIMPL indicates that this language only supports entire-line breakpoints. Consequently,
            // VS debugger will highlight the entire line when the breakpoint is active and the corresponding option
            // ("Highlight entire source line for breakpoints and current statement") is set. If we returned S_OK,
            // we'd have to handle this ourselves.
            return VSConstants.E_NOTIMPL;
        }
예제 #7
0
        public static int GetPositionsOfSpan(IVsTextBuffer textStream, TextSpan ts, out int startPos, out int endPos) {
            int hr;

            startPos = 0;
            endPos = 0;

            hr = textStream.GetPositionOfLineIndex(ts.iStartLine, ts.iStartIndex, out startPos);
            if (hr == VSConstants.S_OK) {
                hr = textStream.GetPositionOfLineIndex(ts.iEndLine, ts.iEndIndex, out endPos);
            }

            return hr;
        }
예제 #8
0
        public int GetActiveView(int fMustHaveFocus, IVsTextBuffer pBuffer, out IVsTextView ppView)
        {
            string fileName = ((MockTextLines)pBuffer).FileName;

            if (_views.ContainsKey(fileName))
            {
                ppView = _views[fileName];
                return VSConstants.S_OK;
            }
            else
            {
                ppView = null;
                return VSConstants.E_INVALIDARG;
            }
        }
예제 #9
0
        private void CreateCodeEditor()
        {
            Guid clsidTextBuffer = typeof(VsTextBufferClass).GUID;
            Guid iidTextBuffer = VSConstants.IID_IUnknown;
            TextBuffer = (IVsTextBuffer)MySqlDataProviderPackage.Instance.CreateInstance(
                                 ref clsidTextBuffer,
                                 ref iidTextBuffer,
                                 typeof(object));
            if (TextBuffer == null)
                throw new Exception("Failed to create core editor");

            // first we need to site our buffer
            IObjectWithSite textBufferSite = TextBuffer as IObjectWithSite;
            if (textBufferSite != null)
            {
                textBufferSite.SetSite(psp);
            }

            // then we need to tell our buffer not to attempt to autodetect the
            // language settings
            IVsUserData userData = TextBuffer as IVsUserData;
            Guid g = EditorFactory.GuidVSBufferDetectLangSid;
            int result = userData.SetData(ref g, false);

            Guid clsidCodeWindow = typeof(VsCodeWindowClass).GUID;
            Guid iidCodeWindow = typeof(IVsCodeWindow).GUID;
            IVsCodeWindow pCodeWindow = (IVsCodeWindow)MySqlDataProviderPackage.Instance.CreateInstance(
                   ref clsidCodeWindow,
                   ref iidCodeWindow,
                   typeof(IVsCodeWindow));
            if (pCodeWindow == null)
                throw new Exception("Failed to create core editor");

            // Give the text buffer to the code window.                    
            // We are giving up ownership of the text buffer!                    
            pCodeWindow.SetBuffer((IVsTextLines)TextBuffer);

            CodeWindow = pCodeWindow;
        }
예제 #10
0
        private void OnDocumentLoadCompleted(IVsTextBuffer shimTextBuffer, DocumentKey documentKeyOpt, string moniker)
        {
            AssertIsForeground();
            // This is called when IVsTextBufferDataEvents.OnLoadComplete() has been triggered for a
            // newly-created buffer.
            if (!_runningDocumentTable.TryGetCookieForInitializedDocument(moniker, out var docCookie))
            {
                return;
            }

            var textBuffer = _editorAdaptersFactoryService.GetDocumentBuffer(shimTextBuffer);
            if (textBuffer == null)
            {
                throw new InvalidOperationException("The IVsTextBuffer has been populated but the underlying ITextBuffer does not exist!");
            }

            if (documentKeyOpt == null)
            {
                // Non-Roslyn document.
                OnNonRoslynBufferOpened_NoLock(textBuffer, docCookie);
            }
            else
            {
                NewBufferOpened(docCookie, textBuffer, documentKeyOpt, IsCurrentContext(docCookie, documentKeyOpt));
            }
        }
예제 #11
0
 public virtual int IsMappedLocation(IVsTextBuffer buffer, int line, int col);
예제 #12
0
            public EditorInterfaces(ITextBuffer textBuffer, ITextDocument textDocument, IVsTextBuffer vsTextBuffer)
            {
                Contract.Assert(textBuffer != null);
                Contract.Assert(textDocument != null);
                Contract.Assert(vsTextBuffer != null);

                TextBuffer   = textBuffer;
                TextDocument = textDocument;
                VsTextBuffer = vsTextBuffer;
            }
예제 #13
0
 public int GetNameOfLocation(IVsTextBuffer pBuffer, int iLine, int iCol, out string pbstrName, out int piLineOffset) {
     pbstrName = null;
     piLineOffset = 0;
     return VSConstants.E_FAIL;
 }
예제 #14
0
 public int UnregisterIndependentView(object pUnk, IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #15
0
 public int UnregisterIndependentView(object pUnk, IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #16
0
 public int UnregisterBuffer(IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #17
0
 public int RegisterView(IVsTextView pView, IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #18
0
 public int NavigateToPosition(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iPos, int iLen)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #19
0
 public int NavigateToLineAndColumn(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iStartRow, int iStartIndex, int iEndRow, int iEndIndex)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #20
0
 public int IgnoreNextFileChange(IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #21
0
 public virtual int ValidateBreakpointLocation(IVsTextBuffer buffer, int line, int col, TextSpan[] pCodeSpan);
예제 #22
0
 public int NavigateToLineAndColumn(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iStartRow, int iStartIndex, int iEndRow, int iEndIndex)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #23
0
 public int RegisterView(IVsTextView pView, IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #24
0
 public int AdjustFileChangeIgnoreCount(IVsTextBuffer pBuffer, int fIgnore)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #25
0
 public int CreateSelectionAction(IVsTextBuffer pBuffer, out IVsTextSelectionAction ppAction)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #26
0
 public int CreateSelectionAction(IVsTextBuffer pBuffer, out IVsTextSelectionAction ppAction)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #27
0
        public int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, TextSpan[] pCodeSpan) {
            // per the docs, even if we don't intend to validate, we need to set the span info:
            // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.textmanager.interop.ivslanguagedebuginfo.validatebreakpointlocation.aspx
            // 
            // Caution
            // Even if you do not intend to support the ValidateBreakpointLocation method but your 
            // language does support breakpoints, you must implement this method and return a span 
            // that contains the specified line and column; otherwise, breakpoints cannot be set 
            // anywhere except line 1. You can return E_NOTIMPL to indicate that you do not otherwise 
            // support this method but the span must always be set. 

            // http://pytools.codeplex.com/workitem/787
            // We were previously returning S_OK here indicating to VS that we have in fact validated
            // the breakpoint.  Validating breakpoints actually interacts and effectively disables
            // the "Highlight entire source line for breakpoints and current statement" option as instead
            // VS highlights the validated region.  So we return E_NOTIMPL here to indicate that we have 
            // not validated the breakpoint, and then VS will happily respect the option when we're in 
            // design mode.
            pCodeSpan[0].iStartLine = iLine;
            pCodeSpan[0].iEndLine = iLine;
            return VSConstants.E_NOTIMPL;
        }
예제 #28
0
 public int EnumViews(IVsTextBuffer pBuffer, out IVsEnumTextViews ppEnum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #29
0
 public int IsMappedLocation(IVsTextBuffer pBuffer, int iLine, int iCol) {
     return VSConstants.E_FAIL;
 }
예제 #30
0
 public virtual int GetNameOfLocation(IVsTextBuffer buffer, int line, int col, out string name, out int lineOffset);
예제 #31
0
 public virtual int GetLanguageID(IVsTextBuffer buffer, int line, int col, out Guid langId);
예제 #32
0
 public int GetLanguageID(IVsTextBuffer pBuffer, int iLine, int iCol, out Guid pguidLanguageID)
 {
     pguidLanguageID = DebuggerConstants.guidLanguagePython;
     return(VSConstants.S_OK);
 }
예제 #33
0
 public int GetActiveView2(int fMustHaveFocus, IVsTextBuffer pBuffer, uint grfIncludeViewFrameType, out IVsTextView ppView)
 {
     throw new NotImplementedException();
 }
예제 #34
0
 public virtual int GetProximityExpressions(IVsTextBuffer buffer, int line, int col, int cLines, out IVsEnumBSTR ppEnum);
예제 #35
0
 public Microsoft.VisualStudio.Text.ITextBuffer GetDocumentBuffer(IVsTextBuffer bufferAdapter)
 {
     throw new NotImplementedException();
 }
예제 #36
0
        /// <summary>
        /// Called by debugger to get the list of expressions for the Autos debugger tool window.
        /// </summary>
        /// <remarks>
        /// MSDN docs specify that <paramref name="iLine"/> and <paramref name="iCol"/> specify the beginning of the span,
        /// but they actually specify the end of it (going <paramref name="cLines"/> lines back).
        /// </remarks>
        public int GetProximityExpressions(IVsTextBuffer pBuffer, int iLine, int iCol, int cLines, out IVsEnumBSTR ppEnum) {
            var model = _serviceProvider.GetService(typeof(SComponentModel)) as IComponentModel;
            var service = model.GetService<IVsEditorAdaptersFactoryService>();
            var buffer = service.GetDataBuffer(pBuffer);
            IPythonProjectEntry projEntry;
            if (buffer.TryGetPythonProjectEntry(out projEntry)) {
                int startLine = Math.Max(iLine - cLines + 1, 0);
                if (startLine <= iLine) {
                    var ast = projEntry.Tree;
                    var walker = new ProximityExpressionWalker(ast, startLine, iLine);
                    ast.Walk(walker);
                    var exprs = walker.GetExpressions();
                    ppEnum = new EnumBSTR(exprs.ToArray());
                    return VSConstants.S_OK;
                }
            }

            ppEnum = null;
            return VSConstants.E_FAIL;
        }
예제 #37
0
 public int GetBufferSccStatus3(IVsTextBuffer pBuffer, string pszFileName, out int pbCheckoutSucceeded, out int piStatusFlags)
 {
     throw new NotImplementedException();
 }
예제 #38
0
 public int IsMappedLocation(IVsTextBuffer pBuffer, int iLine, int iCol)
 {
     return(VSConstants.E_FAIL);
 }
예제 #39
0
 public void SetDataBuffer(IVsTextBuffer bufferAdapter, Microsoft.VisualStudio.Text.ITextBuffer dataBuffer)
 {
     throw new NotImplementedException();
 }
예제 #40
0
 public int NavigateToPosition2(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iPos, int iLen, uint grfIncludeViewFrameType)
 {
     throw new NotImplementedException();
 }
예제 #41
0
 public int GetLanguageID(IVsTextBuffer pBuffer, int iLine, int iCol, out Guid pguidLanguageID) {
     pguidLanguageID = DebuggerConstants.guidLanguagePython;
     return VSConstants.S_OK;
 }
예제 #42
0
 public int AdjustFileChangeIgnoreCount(IVsTextBuffer pBuffer, int fIgnore)
 {
     throw new NotImplementedException();
 }
예제 #43
0
 public int IgnoreNextFileChange(IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #44
0
 public int CreateSelectionAction(IVsTextBuffer pBuffer, out IVsTextSelectionAction ppAction)
 {
     throw new NotImplementedException();
 }
예제 #45
0
 public int NavigateToPosition(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iPos, int iLen)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #46
0
 public int EnumViews(IVsTextBuffer pBuffer, out IVsEnumTextViews ppEnum)
 {
     throw new NotImplementedException();
 }
예제 #47
0
 public int UnregisterBuffer(IVsTextBuffer pBuffer)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #48
0
 public int GetActiveView(int fMustHaveFocus, IVsTextBuffer pBuffer, out IVsTextView ppView)
 {
     throw new NotImplementedException();
 }
예제 #49
0
 public int AdjustFileChangeIgnoreCount(IVsTextBuffer pBuffer, int fIgnore)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #50
0
 public int IgnoreNextFileChange(IVsTextBuffer pBuffer)
 {
     throw new NotImplementedException();
 }
예제 #51
0
 public int EnumViews(IVsTextBuffer pBuffer, out IVsEnumTextViews ppEnum)
 {
     throw new Exception("The method or operation is not implemented.");
 }
예제 #52
0
 public int NavigateToLineAndColumn(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iStartRow, int iStartIndex, int iEndRow, int iEndIndex)
 {
     throw new NotImplementedException();
 }
예제 #53
0
 /// <summary>
 /// add by LiXizhi, since we need to set breakpoint on it. 
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="line"></param>
 /// <param name="col"></param>
 /// <param name="pCodeSpan"></param>
 /// <returns></returns>
 public override int ValidateBreakpointLocation(IVsTextBuffer buffer, int line, int col, TextSpan[] pCodeSpan)
 {
     if (pCodeSpan != null)
     {
         // Make sure the span is set to at least the current
         // position by default.
         pCodeSpan[0].iStartLine = line;
         pCodeSpan[0].iStartIndex = col;
         pCodeSpan[0].iEndLine = line;
         pCodeSpan[0].iEndIndex = col;
     }
     return VSConstants.S_OK;
 }
예제 #54
0
 public int NavigateToPosition(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iPos, int iLen)
 {
     throw new NotImplementedException();
 }
예제 #55
0
 public int GetLanguageID(IVsTextBuffer pBuffer, int iLine, int iCol, out Guid pguidLanguageID) {
     pguidLanguageID = Guids.NodejsDebugLanguage;
     return VSConstants.S_OK;
 }
예제 #56
0
 public int RegisterBuffer(IVsTextBuffer pBuffer)
 {
     throw new NotImplementedException();
 }
예제 #57
0
 public int GetProximityExpressions(IVsTextBuffer pBuffer, int iLine, int iCol, int cLines, out IVsEnumBSTR ppEnum) {
     ppEnum = null;
     return VSConstants.E_FAIL;
 }
예제 #58
0
 public int RegisterIndependentView(object pUnk, IVsTextBuffer pBuffer)
 {
     throw new NotImplementedException();
 }
예제 #59
0
            public EditorInterfaces(ITextBuffer textBuffer, ITextDocument textDocument, IVsTextBuffer vsTextBuffer)
            {
                Contract.Assert(textBuffer != null);
                Contract.Assert(textDocument != null);
                Contract.Assert(vsTextBuffer != null);

                TextBuffer = textBuffer;
                TextDocument = textDocument;
                VsTextBuffer = vsTextBuffer;
            }
예제 #60
0
 public void SetDataBuffer(IVsTextBuffer bufferAdapter, Microsoft.VisualStudio.Text.ITextBuffer dataBuffer)
 {
     throw new NotImplementedException();
 }