Share via


Source.MatchBraces(IVsTextView, Int32, Int32, TokenInfo) Method

Definition

Highlights the spans of a pair of language elements, given the position of one of the elements.

public:
 virtual void MatchBraces(Microsoft::VisualStudio::TextManager::Interop::IVsTextView ^ textView, int line, int index, Microsoft::VisualStudio::Package::TokenInfo ^ info);
 virtual void MatchBraces(Microsoft::VisualStudio::TextManager::Interop::IVsTextView const & textView, int line, int index, Microsoft::VisualStudio::Package::TokenInfo const & info);
public virtual void MatchBraces (Microsoft.VisualStudio.TextManager.Interop.IVsTextView textView, int line, int index, Microsoft.VisualStudio.Package.TokenInfo info);
abstract member MatchBraces : Microsoft.VisualStudio.TextManager.Interop.IVsTextView * int * int * Microsoft.VisualStudio.Package.TokenInfo -> unit
override this.MatchBraces : Microsoft.VisualStudio.TextManager.Interop.IVsTextView * int * int * Microsoft.VisualStudio.Package.TokenInfo -> unit
Public Overridable Sub MatchBraces (textView As IVsTextView, line As Integer, index As Integer, info As TokenInfo)

Parameters

textView
IVsTextView

An IVsTextView object representing the view on the source file.

line
Int32

The line number of the language element for which to find a match.

index
Int32

The offset on the line of the location.

info
TokenInfo

A TokenInfo object containing the information about the token (that is, the language element for which to find a match) under the given location.

Remarks

This method is called to highlight the innermost matching language element to the character at the given position. A matching pair of elements might include, for example, { and }, ( and ), or < and >, or whatever the language determines is a matching pair.

The base method executes a parse starting at the given location with the reason HighlightBraces. The result of the parse, typically two spans specifying the two language elements, is highlighted in the given view. If the EnableShowMatchingBrace property is true, then the first 80 characters of the matching language element are shown in the status bar. The EnableShowMatchingBrace explains this in detail.

This method is typically called from the OnCommand method after a matching pair character is found before the current caret position and the EnableMatchBraces property is true and either a character other than a backspace is typed or the EnableMatchBracesAtCaret property is true.

See Brace Matching in a Legacy Language Service for examples of how brace matching can be accomplished in a language service.

Applies to