public virtual void Dispose() { EndTemplateEditing(true); this.source = null; this.vsExpansion = null; this.view = null; GC.SuppressFinalize(this); }
public int OnItemChosen(string pszTitle, string pszPath) { int hr = VSConstants.E_FAIL; if (!TextView.Caret.InVirtualSpace) { SnapshotPoint caretPoint = TextView.Caret.Position.BufferPosition; IVsExpansion expansion = TextBuffer.GetBufferAdapter <IVsExpansion>(); _earlyEndExpansionHappened = false; _title = pszTitle; var ts = TextSpanFromPoint(caretPoint); hr = expansion.InsertNamedExpansion(pszTitle, pszPath, ts, this, RGuidList.RLanguageServiceGuid, 0, out _expansionSession); if (_earlyEndExpansionHappened) { // EndExpansion was called before InsertNamedExpansion returned, so set _expansionSession // to null to indicate that there is no active expansion session. This can occur when // the snippet inserted doesn't have any expansion fields. _expansionSession = null; _earlyEndExpansionHappened = false; _title = null; _shortcut = null; } } return(hr); }
public int OnItemChosen(string pszTitle, string pszPath) { var hr = VSConstants.S_OK; try { VsTextSpan textSpan; GetCaretPositionInSurfaceBuffer(out textSpan.iStartLine, out textSpan.iStartIndex); textSpan.iEndLine = textSpan.iStartLine; textSpan.iEndIndex = textSpan.iStartIndex; IVsExpansion expansion = EditorAdaptersFactoryService.GetBufferAdapter(TextView.TextViewModel.DataBuffer) as IVsExpansion; earlyEndExpansionHappened = false; hr = expansion.InsertNamedExpansion(pszTitle, pszPath, textSpan, this, LanguageServiceGuid, fShowDisambiguationUI: 0, pSession: out ExpansionSession); if (earlyEndExpansionHappened) { // EndExpansion was called before InsertNamedExpansion returned, so set // expansionSession to null to indicate that there is no active expansion // session. This can occur when the snippet inserted doesn't have any expansion // fields. ExpansionSession = null; earlyEndExpansionHappened = false; } } catch (COMException ex) { hr = ex.ErrorCode; } return(hr); }
public virtual void Dispose() { EndTemplateEditing(true); this.source = null; this.vsExpansion = null; this.view = null; GC.SuppressFinalize(this); }
public ExpansionClient(ITextView textView, IVsEditorAdaptersFactoryService adapterFactory, IServiceProvider serviceProvider) { _textView = textView; _serviceProvider = serviceProvider; _view = adapterFactory.GetViewAdapter(textView); _lines = (IVsTextLines)adapterFactory.GetBufferAdapter(textView.TextBuffer); _expansion = _lines as IVsExpansion; if (_expansion == null) { throw new ArgumentException("TextBuffer does not support expansions"); } }
private bool InsertAnyExpansion(string shortcut, string title, string path) { //first get the location of the caret, and set up a TextSpan int endColumn, startLine; //get the column number from the IVsTextView, not the ITextView m_vsTextView.GetCaretPos(out startLine, out endColumn); TextSpan addSpan = new TextSpan(); addSpan.iStartIndex = endColumn; addSpan.iEndIndex = endColumn; addSpan.iStartLine = startLine; addSpan.iEndLine = startLine; if (shortcut != null) //get the expansion from the shortcut { //reset the TextSpan to the width of the shortcut, //because we're going to replace the shortcut with the expansion addSpan.iStartIndex = addSpan.iEndIndex - shortcut.Length; m_exManager.GetExpansionByShortcut( this, Guids.LuaLanguageService, shortcut, m_vsTextView, new TextSpan[] { addSpan }, 0, out path, out title); } if (title != null && path != null) { IVsTextLines textLines; m_vsTextView.GetBuffer(out textLines); IVsExpansion bufferExpansion = (IVsExpansion)textLines; if (bufferExpansion != null) { int hr = bufferExpansion.InsertNamedExpansion( title, path, addSpan, this, Guids.LuaLanguageService, 0, out m_exSession); if (VSConstants.S_OK == hr) { return(true); } } } return(false); }
public ExpansionClient(ITextView textView, PythonEditorServices services) { _textView = textView; _services = services; _view = _services.EditorAdaptersFactoryService.GetViewAdapter(_textView); _lines = (IVsTextLines)_services.EditorAdaptersFactoryService.GetBufferAdapter(_textView.TextBuffer); _expansion = _lines as IVsExpansion; if (_expansion == null) { throw new ArgumentException("TextBuffer does not support expansions"); } }
public ExpansionClient(ITextView textView, IVsEditorAdaptersFactoryService adapterFactory, IServiceProvider serviceProvider) { _textView = textView; _serviceProvider = serviceProvider; _view = adapterFactory.GetViewAdapter(textView); _lines = (IVsTextLines)adapterFactory.GetBufferAdapter(textView.TextBuffer); _expansion = _lines as IVsExpansion; if (_expansion == null) { throw new ArgumentException("TextBuffer does not support expansions"); } }
public ExpansionClient(ITextView textView, IVsEditorAdaptersFactoryService editorAdaptersFactoryService) { if (editorAdaptersFactoryService == null) { throw new ArgumentNullException(nameof(editorAdaptersFactoryService)); } _textView = textView ?? throw new ArgumentNullException(nameof(textView)); _view = editorAdaptersFactoryService.GetViewAdapter(_textView); _lines = (IVsTextLines)editorAdaptersFactoryService.GetBufferAdapter(_textView.TextBuffer); _expansion = _lines as IVsExpansion; if (_expansion == null) { throw new ArgumentException("TextBuffer does not support expansions"); } }
internal ExpansionProvider(ISource src) { if (src == null){ throw new ArgumentNullException("src"); } this.fieldDefaults = new ArrayList(); if (src == null) throw new System.ArgumentNullException(); this.source = src; this.vsExpansion = null; // do we need a Close() method here? // QI for IVsExpansion IVsTextLines buffer = src.GetTextLines(); this.vsExpansion = (IVsExpansion)buffer; if (this.vsExpansion == null) { throw new ArgumentNullException("(IVsExpansion)src.GetTextLines()"); } }
private void InsertCodeExpansion(VsExpansion expansion, int startLine, int startColumn, int endLine, int endColumn) { // Insert the selected code snippet and start an expansion session IVsTextLines buffer; vsTextView.GetBuffer(out buffer); // Get the IVsExpansion from the current IVsTextLines IVsExpansion vsExpansion = (IVsExpansion)buffer; // Call the actual method that performs the snippet insertion vsExpansion.InsertNamedExpansion( expansion.title, expansion.path, new TextSpan { iStartIndex = startColumn, iEndIndex = endColumn, iEndLine = endLine, iStartLine = startLine }, null, GuidList.guidSpringLanguage, 0, out expansionSession); }
internal ExpansionProvider(ISource src) { if (src == null) { throw new ArgumentNullException("src"); } this.fieldDefaults = new ArrayList(); if (src == null) { throw new System.ArgumentNullException(); } this.source = src; this.vsExpansion = null; // do we need a Close() method here? // QI for IVsExpansion IVsTextLines buffer = src.GetTextLines(); this.vsExpansion = (IVsExpansion)buffer; if (this.vsExpansion == null) { throw new ArgumentNullException("(IVsExpansion)src.GetTextLines()"); } }