IVsExpansionManager.GetExpansionByShortcut Method

Definition

Retrieves the title and path to a snippet given its shortcut name.

public:
 int GetExpansionByShortcut(Microsoft::VisualStudio::TextManager::Interop::IVsExpansionClient ^ pClient, Guid guidLang, System::String ^ szShortcut, Microsoft::VisualStudio::TextManager::Interop::IVsTextView ^ pView, cli::array <Microsoft::VisualStudio::TextManager::Interop::TextSpan> ^ pts, int fShowUI, [Runtime::InteropServices::Out] System::String ^ % pszExpansionPath, [Runtime::InteropServices::Out] System::String ^ % pszTitle);
public int GetExpansionByShortcut (Microsoft.VisualStudio.TextManager.Interop.IVsExpansionClient pClient, Guid guidLang, string szShortcut, Microsoft.VisualStudio.TextManager.Interop.IVsTextView pView, Microsoft.VisualStudio.TextManager.Interop.TextSpan[] pts, int fShowUI, out string pszExpansionPath, out string pszTitle);
abstract member GetExpansionByShortcut : Microsoft.VisualStudio.TextManager.Interop.IVsExpansionClient * Guid * string * Microsoft.VisualStudio.TextManager.Interop.IVsTextView * Microsoft.VisualStudio.TextManager.Interop.TextSpan[] * int * string * string -> int
Public Function GetExpansionByShortcut (pClient As IVsExpansionClient, guidLang As Guid, szShortcut As String, pView As IVsTextView, pts As TextSpan(), fShowUI As Integer, ByRef pszExpansionPath As String, ByRef pszTitle As String) As Integer

Parameters

pClient
IVsExpansionClient

[in] An IVsExpansionClient object representing the client that can control what code snippets can be inserted.

guidLang
Guid

[in] The GUID of the coding language (typically, this is the language service GUID).

szShortcut
String

[in] A string containing the shortcut name of the snippet.

pView
IVsTextView

[in] An IVsTextView object used as the parent if the UI needs to be shown. This can be a null value if fShowUI is zero (FALSE).

pts
TextSpan[]

[in] A TextSpan object that describes the span (position and extent) where the code snippet is to be inserted.

fShowUI
Int32

[in] Non-zero (TRUE) if to show the UI to allow the user to choose among multiple snippets with the same shortcut name.

pszExpansionPath
String

[out] Returns a string containing the full path to the snippet.

pszTitle
String

[out] Returns a string containing the title of the snippet.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr2.idl:

HRESULT IVsExpansionManager::GetExpansionByShortcut(  
   [in]GUID guidLang,  
   [in]WCHAR *szShortcut,  
   [in]IVsTextView *pView,  
   [in]bool fShowUI,  
   [out]BSTR *pszExpansionPath,  
   [out]BSTR *pszTitle  
);  

One scenario for calling this method is when a snippet shortcut name is selected from an IntelliSense completion list. The language service handling the completion passes the selected shortcut name to this method to get the path and title of the snippet. This information is then passed to the InsertNamedExpansion method in the IVsExpansion interface to insert the snippet into the document. In Visual Studio, the IVsExpansion interface can be obtained by calling the QueryInterface method in the IVsTextBuffer interface.

Applies to