Partager via


Source.MatchBraces Method

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

Namespace:  Microsoft.VisualStudio.Package
Assemblies:   Microsoft.VisualStudio.Package.LanguageService.9.0 (in Microsoft.VisualStudio.Package.LanguageService.9.0.dll)
  Microsoft.VisualStudio.Package.LanguageService (in Microsoft.VisualStudio.Package.LanguageService.dll)
  Microsoft.VisualStudio.Package.LanguageService.10.0 (in Microsoft.VisualStudio.Package.LanguageService.10.0.dll)

Syntax

'Déclaration
Public Overridable Sub MatchBraces ( _
    textView As IVsTextView, _
    line As Integer, _
    index As Integer, _
    info As TokenInfo _
)
'Utilisation
Dim instance As Source
Dim textView As IVsTextView
Dim line As Integer
Dim index As Integer
Dim info As TokenInfo

instance.MatchBraces(textView, line, index, _
    info)
public virtual void MatchBraces(
    IVsTextView textView,
    int line,
    int index,
    TokenInfo info
)
public:
virtual void MatchBraces(
    IVsTextView^ textView, 
    int line, 
    int index, 
    TokenInfo^ info
)
abstract MatchBraces : 
        textView:IVsTextView * 
        line:int * 
        index:int * 
        info:TokenInfo -> unit 
override MatchBraces : 
        textView:IVsTextView * 
        line:int * 
        index:int * 
        info:TokenInfo -> unit 
public function MatchBraces(
    textView : IVsTextView, 
    line : int, 
    index : int, 
    info : TokenInfo
)

Parameters

  • line
    Type: System.Int32
    The line number of the language element for which to find a match.
  • index
    Type: System.Int32
    The offset on the line of the 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 (Managed Package Framework) for examples of how brace matching can be accomplished in a language service.

.NET Framework Security

See Also

Reference

Source Class

Source Members

Microsoft.VisualStudio.Package Namespace

Other Resources

Brace Matching (Managed Package Framework)