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; }
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; }
public PieScanner(IVsTextBuffer buffer) { m_buffer = buffer; grammar = new PieGrammar(); parser = new Irony.Parsing.Parser(grammar); parser.Context.Mode = Irony.Parsing.ParseMode.VsLineScan; }
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); }
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; }
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; }
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; } }
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; }
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)); } }
public virtual int IsMappedLocation(IVsTextBuffer buffer, int line, int col);
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; }
public int GetNameOfLocation(IVsTextBuffer pBuffer, int iLine, int iCol, out string pbstrName, out int piLineOffset) { pbstrName = null; piLineOffset = 0; return VSConstants.E_FAIL; }
public int UnregisterIndependentView(object pUnk, IVsTextBuffer pBuffer) { throw new Exception("The method or operation is not implemented."); }
public int UnregisterBuffer(IVsTextBuffer pBuffer) { throw new Exception("The method or operation is not implemented."); }
public int RegisterView(IVsTextView pView, IVsTextBuffer pBuffer) { throw new Exception("The method or operation is not implemented."); }
public int NavigateToPosition(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iPos, int iLen) { throw new Exception("The method or operation is not implemented."); }
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."); }
public int IgnoreNextFileChange(IVsTextBuffer pBuffer) { throw new Exception("The method or operation is not implemented."); }
public virtual int ValidateBreakpointLocation(IVsTextBuffer buffer, int line, int col, TextSpan[] pCodeSpan);
public int AdjustFileChangeIgnoreCount(IVsTextBuffer pBuffer, int fIgnore) { throw new Exception("The method or operation is not implemented."); }
public int CreateSelectionAction(IVsTextBuffer pBuffer, out IVsTextSelectionAction ppAction) { throw new Exception("The method or operation is not implemented."); }
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; }
public int EnumViews(IVsTextBuffer pBuffer, out IVsEnumTextViews ppEnum) { throw new Exception("The method or operation is not implemented."); }
public int IsMappedLocation(IVsTextBuffer pBuffer, int iLine, int iCol) { return VSConstants.E_FAIL; }
public virtual int GetNameOfLocation(IVsTextBuffer buffer, int line, int col, out string name, out int lineOffset);
public virtual int GetLanguageID(IVsTextBuffer buffer, int line, int col, out Guid langId);
public int GetLanguageID(IVsTextBuffer pBuffer, int iLine, int iCol, out Guid pguidLanguageID) { pguidLanguageID = DebuggerConstants.guidLanguagePython; return(VSConstants.S_OK); }
public int GetActiveView2(int fMustHaveFocus, IVsTextBuffer pBuffer, uint grfIncludeViewFrameType, out IVsTextView ppView) { throw new NotImplementedException(); }
public virtual int GetProximityExpressions(IVsTextBuffer buffer, int line, int col, int cLines, out IVsEnumBSTR ppEnum);
public Microsoft.VisualStudio.Text.ITextBuffer GetDocumentBuffer(IVsTextBuffer bufferAdapter) { throw new NotImplementedException(); }
/// <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; }
public int GetBufferSccStatus3(IVsTextBuffer pBuffer, string pszFileName, out int pbCheckoutSucceeded, out int piStatusFlags) { throw new NotImplementedException(); }
public int IsMappedLocation(IVsTextBuffer pBuffer, int iLine, int iCol) { return(VSConstants.E_FAIL); }
public void SetDataBuffer(IVsTextBuffer bufferAdapter, Microsoft.VisualStudio.Text.ITextBuffer dataBuffer) { throw new NotImplementedException(); }
public int NavigateToPosition2(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iPos, int iLen, uint grfIncludeViewFrameType) { throw new NotImplementedException(); }
public int GetLanguageID(IVsTextBuffer pBuffer, int iLine, int iCol, out Guid pguidLanguageID) { pguidLanguageID = DebuggerConstants.guidLanguagePython; return VSConstants.S_OK; }
public int AdjustFileChangeIgnoreCount(IVsTextBuffer pBuffer, int fIgnore) { throw new NotImplementedException(); }
public int CreateSelectionAction(IVsTextBuffer pBuffer, out IVsTextSelectionAction ppAction) { throw new NotImplementedException(); }
public int EnumViews(IVsTextBuffer pBuffer, out IVsEnumTextViews ppEnum) { throw new NotImplementedException(); }
public int GetActiveView(int fMustHaveFocus, IVsTextBuffer pBuffer, out IVsTextView ppView) { throw new NotImplementedException(); }
public int IgnoreNextFileChange(IVsTextBuffer pBuffer) { throw new NotImplementedException(); }
public int NavigateToLineAndColumn(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iStartRow, int iStartIndex, int iEndRow, int iEndIndex) { throw new NotImplementedException(); }
/// <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; }
public int NavigateToPosition(IVsTextBuffer pBuffer, ref Guid guidDocViewType, int iPos, int iLen) { throw new NotImplementedException(); }
public int GetLanguageID(IVsTextBuffer pBuffer, int iLine, int iCol, out Guid pguidLanguageID) { pguidLanguageID = Guids.NodejsDebugLanguage; return VSConstants.S_OK; }
public int RegisterBuffer(IVsTextBuffer pBuffer) { throw new NotImplementedException(); }
public int GetProximityExpressions(IVsTextBuffer pBuffer, int iLine, int iCol, int cLines, out IVsEnumBSTR ppEnum) { ppEnum = null; return VSConstants.E_FAIL; }
public int RegisterIndependentView(object pUnk, IVsTextBuffer pBuffer) { throw new NotImplementedException(); }