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
‘선언
Function GetNearestVisibleToken ( _
tsSecondaryToken As TextSpan, _
<OutAttribute> ptsPrimaryToken As TextSpan() _
) As Integer
‘사용 방법
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
- tsSecondaryToken
Type: Microsoft.VisualStudio.TextManager.Interop.TextSpan
[in] A TextSpan object describing the position and extent of the token to search near. This position is based on the secondary buffer.
- ptsPrimaryToken
Type: array<Microsoft.VisualStudio.TextManager.Interop.TextSpan[]
[out] Returns a TextSpan object describing the position and extent of the token that is nearest the specified token. The position is based on the primary buffer.
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
IVsContainedLanguageHost Interface