/// <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.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); }