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


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

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

public virtual void MatchBraces(
	IVsTextView textView,
	int line,
	int index,
	TokenInfo info


Type: Microsoft.VisualStudio.TextManager.Interop.IVsTextView

An IVsTextView object representing the view on the source file.

Type: System.Int32

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

Type: System.Int32

The offset on the line of the location.

Type: Microsoft.VisualStudio.Package.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.

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 (Managed Package Framework) for examples of how brace matching can be accomplished in a language service.

Return to top