/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.InsertNamedExpansion"]/*' /> public virtual bool InsertNamedExpansion(IVsTextView view, string title, string path, TextSpan pos, bool showDisambiguationUI) { if (this.source.IsCompletorActive) { this.source.DismissCompletor(); } this.view = view; if (this.expansionActive) { this.EndTemplateEditing(true); } TextSpan2 t2 = TextSpanHelper.TextSpan2FromTextSpan(pos); Guid guidLanguage = this.source.LanguageService.GetLanguageServiceGuid(); int hr = this.vsExpansion.InsertNamedExpansion(title, path, t2, this, guidLanguage, showDisambiguationUI ? 1 : 0, out this.expansionSession); if (hr != NativeMethods.S_OK || this.expansionSession == null) { this.EndTemplateEditing(true); return(false); } else if (hr == NativeMethods.S_OK) { this.expansionActive = true; return(true); } return(false); }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.InsertSpecificExpansion"]/*' /> public virtual bool InsertSpecificExpansion(IVsTextView view, XmlElement snippet, TextSpan pos, string relativePath) { if (this.expansionActive) { this.EndTemplateEditing(true); } if (this.source.IsCompletorActive) { this.source.DismissCompletor(); } this.view = view; MSXML.IXMLDOMDocument doc = new MSXML.DOMDocumentClass(); if (!doc.loadXML(snippet.OuterXml)) { throw new ArgumentException(doc.parseError.reason); } Guid guidLanguage = this.source.LanguageService.GetLanguageServiceGuid(); TextSpan2 t2 = TextSpanHelper.TextSpan2FromTextSpan(pos); int hr = this.vsExpansion.InsertSpecificExpansion(doc, t2, this, guidLanguage, relativePath, out this.expansionSession); if (hr != NativeMethods.S_OK || this.expansionSession == null) { this.EndTemplateEditing(true); } else { this.expansionActive = true; return(true); } return(false); }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.BeginTemplateEditing"]/*' /> public virtual void BeginTemplateEditing(int line, int col) { if (!this.expansionPrepared) { throw new System.InvalidOperationException(SR.GetString(SR.TemplateNotPrepared)); } TextSpan2 tsInsert = new TextSpan2(); tsInsert.iStartLine = tsInsert.iEndLine = line; tsInsert.iStartIndex = tsInsert.iEndIndex = col; Guid languageSID = this.source.LanguageService.GetType().GUID; int hr = this.vsExpansion.InsertNamedExpansion(this.titleToInsert, this.pathToInsert, tsInsert, (IVsExpansionClient)this, languageSID, 0, // fShowDisambiguationUI, out this.expansionSession); if (hr != NativeMethods.S_OK) { this.EndTemplateEditing(true); } this.pathToInsert = null; this.titleToInsert = null; }
/// <include file='doc\Utilities.uex' path='docs/doc[@for="TextSpanHelper.TextSpan2FromTextSpan"]/*' /> public static TextSpan2 TextSpan2FromTextSpan(TextSpan span) { TextSpan2 t2 = new TextSpan2(); t2.iStartLine = span.iStartLine; t2.iStartIndex = span.iStartIndex; t2.iEndLine = span.iEndLine; t2.iEndIndex = span.iEndIndex; return t2; }
/// <include file='doc\Utilities.uex' path='docs/doc[@for="TextSpanHelper.TextSpanFromTextSpan2"]/*' /> public static TextSpan TextSpanFromTextSpan2(TextSpan2 t2) { TextSpan span = new TextSpan(); span.iStartLine = t2.iStartLine; span.iStartIndex = t2.iStartIndex; span.iEndLine = t2.iEndLine; span.iEndIndex = t2.iEndIndex; return span; }
/// <include file='doc\Utilities.uex' path='docs/doc[@for="TextSpanHelper.TextSpan2FromTextSpan"]/*' /> public static TextSpan2 TextSpan2FromTextSpan(TextSpan span) { TextSpan2 t2 = new TextSpan2(); t2.iStartLine = span.iStartLine; t2.iStartIndex = span.iStartIndex; t2.iEndLine = span.iEndLine; t2.iEndIndex = span.iEndIndex; return(t2); }
/// <include file='doc\Utilities.uex' path='docs/doc[@for="TextSpanHelper.TextSpanFromTextSpan2"]/*' /> public static TextSpan TextSpanFromTextSpan2(TextSpan2 t2) { TextSpan span = new TextSpan(); span.iStartLine = t2.iStartLine; span.iStartIndex = t2.iStartIndex; span.iEndLine = t2.iEndLine; span.iEndIndex = t2.iEndIndex; return(span); }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.InTemplateEditingMode"]/*' /> public virtual TextSpan GetExpansionSpan() { if (this.expansionSession == null) { throw new System.InvalidOperationException(SR.GetString(SR.NoExpansionSession)); } TextSpan2[] pts = new TextSpan2[1]; int hr = this.expansionSession.GetSnippetSpan(pts); if (NativeMethods.Succeeded(hr)) { return(TextSpanHelper.TextSpanFromTextSpan2(pts[0])); } return(new TextSpan()); }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.GetFieldSpan"]/*' /> public virtual bool GetFieldSpan(string field, out TextSpan2 pts) { if (this.expansionSession == null) { throw new System.InvalidOperationException(SR.GetString(SR.NoExpansionSession)); } if (this.expansionSession != null) { TextSpan2[] apt = new TextSpan2[1]; this.expansionSession.GetFieldSpan(field, apt); pts = apt[0]; return(true); } else { pts = new TextSpan2(); return(false); } }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.FindExpansionByShortcut"]/*' /> /// <summary>Returns S_OK if match found, S_FALSE if expansion UI is shown, and error otherwise</summary> public virtual int FindExpansionByShortcut(IVsTextView view, string shortcut, TextSpan span, bool showDisambiguationUI, out string title, out string path) { if (this.expansionActive) { this.EndTemplateEditing(true); } this.view = view; title = path = null; LanguageService svc = this.source.LanguageService; IVsExpansionManager mgr = svc.Site.GetService(typeof(SVsExpansionManager)) as IVsExpansionManager; if (mgr == null) { return(NativeMethods.E_FAIL); } Guid guidLanguage = svc.GetLanguageServiceGuid(); TextSpan2[] pts = new TextSpan2[1]; pts[0] = TextSpanHelper.TextSpan2FromTextSpan(span); int hr = mgr.GetExpansionByShortcut(this, guidLanguage, shortcut, this.TextView, pts, showDisambiguationUI ? 1 : 0, out path, out title); return(hr); }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.InTemplateEditingMode"]/*' /> public virtual TextSpan GetExpansionSpan() { if (this.expansionSession == null){ throw new System.InvalidOperationException(SR.GetString(SR.NoExpansionSession)); } TextSpan2[] pts = new TextSpan2[1]; int hr = this.expansionSession.GetSnippetSpan(pts); if (NativeMethods.Succeeded(hr)) { return TextSpanHelper.TextSpanFromTextSpan2(pts[0]); } return new TextSpan(); }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.PositionCaretForEditing"]/*' /> public virtual int PositionCaretForEditing(IVsTextLines pBuffer, TextSpan2[] ts) { // NOP return NativeMethods.S_OK; }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.IsValidType"]/*' /> public virtual int IsValidType(IVsTextLines buffer, TextSpan2[] ts, string[] rgTypes, int iCountTypes) { if (this.source.GetTextLines() != buffer) { throw new System.ArgumentException(SR.GetString(SR.UnknownBuffer), "buffer"); } // idl says this method return value is "bool" return 1; // true; }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.FormatSpan"]/*' /> public virtual int FormatSpan(IVsTextLines buffer, TextSpan2[] ts) { if (this.source.GetTextLines() != buffer) { throw new System.ArgumentException(SR.GetString(SR.UnknownBuffer), "buffer"); } int rc = NativeMethods.E_NOTIMPL; if (ts != null) { for (int i = 0, n = ts.Length; i < n; i++) { if (this.source.LanguageService.Preferences.EnableFormatSelection) { TextSpan span = TextSpanHelper.TextSpanFromTextSpan2(ts[i]); // We should not merge edits in this case because it might clobber the // $varname$ spans which are markers for yellow boxes. EditArray edits = new EditArray(this.source, this.view, false, SR.GetString(SR.FormatSpan)); this.source.ReformatSpan(edits, span); edits.ApplyEdits(); rc = NativeMethods.S_OK; } } } return rc; }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.GetFieldSpan"]/*' /> public virtual bool GetFieldSpan(string field, out TextSpan2 pts) { if (this.expansionSession == null) { throw new System.InvalidOperationException(SR.GetString(SR.NoExpansionSession)); } if (this.expansionSession != null) { TextSpan2[] apt = new TextSpan2[1]; this.expansionSession.GetFieldSpan(field, apt); pts = apt[0]; return true; } else { pts = new TextSpan2(); return false; } }
/// <include file='doc\ExpansionProvider.uex' path='docs/doc[@for="ExpansionProvider.FindExpansionByShortcut"]/*' /> /// <summary>Returns S_OK if match found, S_FALSE if expansion UI is shown, and error otherwise</summary> public virtual int FindExpansionByShortcut(IVsTextView view, string shortcut, TextSpan span, bool showDisambiguationUI, out string title, out string path) { if (this.expansionActive) this.EndTemplateEditing(true); this.view = view; title = path = null; LanguageService svc = this.source.LanguageService; IVsExpansionManager mgr = svc.Site.GetService(typeof(SVsExpansionManager)) as IVsExpansionManager; if (mgr == null) return NativeMethods.E_FAIL ; Guid guidLanguage = svc.GetLanguageServiceGuid(); TextSpan2[] pts = new TextSpan2[1]; pts[0] = TextSpanHelper.TextSpan2FromTextSpan(span); int hr = mgr.GetExpansionByShortcut(this, guidLanguage, shortcut, this.TextView, pts, showDisambiguationUI ? 1 : 0, out path, out title); return hr; }