Freigeben über


IVsContainedLanguageHost.GetNearestVisibleToken Method

Returns the language token that is nearest the requested line.

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

Syntax

'Declaration
Function GetNearestVisibleToken ( _
    tsSecondaryToken As TextSpan, _
    <OutAttribute> ptsPrimaryToken As TextSpan() _
) As Integer
'Usage
Dim instance As IVsContainedLanguageHost
Dim tsSecondaryToken As TextSpan
Dim ptsPrimaryToken As TextSpan()
Dim returnValue As Integer

returnValue = instance.GetNearestVisibleToken(tsSecondaryToken, _
    ptsPrimaryToken)
int GetNearestVisibleToken(
    TextSpan tsSecondaryToken,
    TextSpan[] ptsPrimaryToken
)
int GetNearestVisibleToken(
    [InAttribute] TextSpan tsSecondaryToken, 
    [OutAttribute] array<TextSpan>^ ptsPrimaryToken
)
abstract GetNearestVisibleToken : 
        tsSecondaryToken:TextSpan * 
        ptsPrimaryToken:TextSpan[] byref -> int 
function GetNearestVisibleToken(
    tsSecondaryToken : TextSpan, 
    ptsPrimaryToken : TextSpan[]
) : int

Parameters

Return Value

Type: System.Int32
If successful, returns S_OK; otherwise, returns an error code.

Remarks

COM Signature

From singlefileeditor.idl:

HRESULT GetNearestVisibleToken(
   [in]  TextSpan  tsSecondaryToken,
   [out] TextSpan* ptsPrimaryToken
);

If a contained language is not able to determine where to create a marker for a compile error that is visible to the user, the contained language should call the GetNearestVisibleToken method, so that the editor can provide the closest item to create marker on.

For example:

<script runat="server" language="vb">
        Sub Foo()
</script>

Normally, Visual Basic would place the wavy underline (squiggles) indicating the point of error on the End Class statement or whatever Visual Basic code might follow the missing End Sub. However, in the above example from ASP.NET, any additional Visual Basic code is outside the visible code block. The contained language can determine this situation by calling the MapSecondaryToPrimarySpan method which fails if the text is outside of the visible range. In that case, the contained language can call the GetNearestVisibleToken method to obtain the span for the nearest visible token to put the squiggles on. In the above example, the squiggles should appear on the </script> tag and that is the span the editor returns from the GetNearestVisibleToken method.

.NET Framework Security

See Also

Reference

IVsContainedLanguageHost Interface

IVsContainedLanguageHost Members

Microsoft.VisualStudio.TextManager.Interop Namespace