Compartilhar via


IVsExpansion.InsertExpansion Method

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

Namespace:  Microsoft.VisualStudio.TextManager.Interop
Assembly:  Microsoft.VisualStudio.TextManager.Interop.8.0 (in Microsoft.VisualStudio.TextManager.Interop.8.0.dll)

Syntax

'Declaration
Function InsertExpansion ( _
    tsContext As TextSpan, _
    tsInsertPos As TextSpan, _
    pExpansionClient As IVsExpansionClient, _
    guidLang As Guid, _
    <OutAttribute> ByRef pSession As IVsExpansionSession _
) As Integer
int InsertExpansion(
    TextSpan tsContext,
    TextSpan tsInsertPos,
    IVsExpansionClient pExpansionClient,
    Guid guidLang,
    out IVsExpansionSession pSession
)
int InsertExpansion(
    [InAttribute] TextSpan tsContext, 
    [InAttribute] TextSpan tsInsertPos, 
    [InAttribute] IVsExpansionClient^ pExpansionClient, 
    [InAttribute] Guid guidLang, 
    [OutAttribute] IVsExpansionSession^% pSession
)
abstract InsertExpansion : 
        tsContext:TextSpan * 
        tsInsertPos:TextSpan * 
        pExpansionClient:IVsExpansionClient * 
        guidLang:Guid * 
        pSession:IVsExpansionSession byref -> int
function InsertExpansion(
    tsContext : TextSpan, 
    tsInsertPos : TextSpan, 
    pExpansionClient : IVsExpansionClient, 
    guidLang : Guid, 
    pSession : IVsExpansionSession
) : int

Parameters

  • guidLang
    Type: System.Guid

    [in] GUID of the language service. Can be a nulla null reference (Nothing in Visual Basic) value. Default is the language service of the file.

Return Value

Type: System.Int32
If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From textmgr2.idl:

HRESULT IVsExpansion::InsertExpansion(
   [in] TextSpan tsContext,
   [in] TextSpan tsInsertPos,
   [in]IVsExpansionClient *pExpansionClient,
   [in]GUID guidLang,
   [out] IVsExpansionSession **pSession
);

This method reads the snippet shortcut from the text buffer at the position specified by the tsContext parameter (remember, the IVsExpansion interface is implemented on the same object that implements the IVsTextBuffer interface), loads the snippet based on the shortcut and then inserts the snippet into the text buffer at position specified by the tsInsertPos parameter.

If an IVsExpansionClient object is supplied, it receives before (OnBeforeInsertion method) and after (OnAfterInsertion method) notifications during the insertion process. The expansion client is also used to validate the kind of snippet (IsValidKind method) to make sure the snippet can actually be inserted at the specified location.

.NET Framework Security

See Also

Reference

IVsExpansion Interface

Microsoft.VisualStudio.TextManager.Interop Namespace