Freigeben über


AuthoringSink.MatchPair Method

Called to add the spans of the two paired elements in an internal list.

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

Syntax

'Declaration
Public Overridable Sub MatchPair ( _
    span As TextSpan, _
    endContext As TextSpan, _
    priority As Integer _
)
'Usage
Dim instance As AuthoringSink
Dim span As TextSpan
Dim endContext As TextSpan
Dim priority As Integer

instance.MatchPair(span, endContext, priority)
public virtual void MatchPair(
    TextSpan span,
    TextSpan endContext,
    int priority
)
public:
virtual void MatchPair(
    TextSpan span, 
    TextSpan endContext, 
    int priority
)
abstract MatchPair : 
        span:TextSpan * 
        endContext:TextSpan * 
        priority:int -> unit 
override MatchPair : 
        span:TextSpan * 
        endContext:TextSpan * 
        priority:int -> unit 
public function MatchPair(
    span : TextSpan, 
    endContext : TextSpan, 
    priority : int
)

Parameters

  • priority
    Type: System.Int32
    [in] A priority value used to sort overlapping pairs.

Remarks

If the BraceMatching property returns true, this method is called to add the two spans to an internal list that describes matching pairs, sorted in priority order (typically the highest priority for overlapping pairs wins) that is used for overlapping pairs. Some examples of matching pairs are "(", ")"; "{", "}"; and "<", ">".

One way where matching pairs overlap is with nested braces. In this scheme, the innermost pair of braces has the highest priority and the outermost pair has the lowest priority.

The base method normalizes the spans and then determines if the spans include the parse operation's starting point (as given by the Line and Column properties). If either span includes the starting point, the spans are first added to an internal list of spans and are then bundled into a BraceMatch structure added to another internal list, sorted in priority order. The internal list is an array of BraceMatch structures and is called Braces. See the example below for the internal definition of the BraceMatch structure.

Examples

The following structure is used by the managed package framework to contain a prioritized pair of language elements (for example, "(" and ")").

internal class BraceMatch
{
    internal TextSpan a;
    internal TextSpan b;
    internal int priority;

    public BraceMatch(TextSpan a, TextSpan b, int priority)
    {
        this.a = a;
        this.b = b;
        this.priority = priority;
    }
}

.NET Framework Security

See Also

Reference

AuthoringSink Class

AuthoringSink Members

Microsoft.VisualStudio.Package Namespace