Compartilhar via


IVsExpansion Interface

Definition

Provides a way to insert code snippets into a text buffer.

public interface class IVsExpansion
public interface class IVsExpansion
__interface IVsExpansion
[System.Runtime.InteropServices.Guid("798CC43B-7714-4DC1-925A-47863C24630D")]
[System.Runtime.InteropServices.InterfaceType(1)]
public interface IVsExpansion
[System.Runtime.InteropServices.Guid("798CC43B-7714-4DC1-925A-47863C24630D")]
[System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)]
public interface IVsExpansion
[<System.Runtime.InteropServices.Guid("798CC43B-7714-4DC1-925A-47863C24630D")>]
[<System.Runtime.InteropServices.InterfaceType(1)>]
type IVsExpansion = interface
[<System.Runtime.InteropServices.Guid("798CC43B-7714-4DC1-925A-47863C24630D")>]
[<System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIUnknown)>]
type IVsExpansion = interface
Public Interface IVsExpansion
Attributes

Remarks

Code snippets are pieces of code that are inserted and formatted automatically, typically by selecting from a menu of snippets (as displayed by the InvokeInsertionUI method in the IVsExpansionManager interface). An alternative approach is to obtain a shortcut to a code snippet, call the GetExpansionByShortcut method in the IVsExpansionManager interface to obtain the path to the snippet, and then call the InsertNamedExpansion in the IVsExpansion interface.

The InvokeInsertionUI method is passed an IVsExpansionClient interface that in turn handles the details of calling the InsertNamedExpansion method on the IVsExpansion interface (specifically, in the OnItemChosen method in the IVsExpansionClient interface). This means the object that implements the IVsExpansionClient interface must obtain or be given an IVsExpansion interface before the InvokeInsertionUI method is called.

Notes to Implementers

This interface is implemented on the same object that implements an IVsTextBuffer interface as this interface affects the associated text buffer.

Notes to Callers

Obtain this interface with a call to the QueryInterface method on an IVsTextBuffer object (or, for managed code, cast the IVsTextBuffer object to the IVsExpansion interface). If the IVsExpansion interface can be obtained, then the text buffer is announcing support for inserting code snippets.

Methods

InsertExpansion(TextSpan, TextSpan, IVsExpansionClient, Guid, IVsExpansionSession)

Inserts the code snippet associated with the shortcut that can be found at the given context position in the text buffer.

InsertNamedExpansion(String, String, TextSpan, IVsExpansionClient, Guid, Int32, IVsExpansionSession)

Inserts snippet with the specified name at the specified position in the text buffer.

InsertSpecificExpansion(IXMLDOMNode, TextSpan, IVsExpansionClient, Guid, String, IVsExpansionSession)

Inserts the code snippet from the specified XML node into the text buffer at the specified position.

Applies to