Compartilhar via


AuthoringSink.MatchTriple(TextSpan, TextSpan, TextSpan, Int32) Method

Definition

Matching tripples are used to highlight in bold a completed statement. For example when you type the closing brace on a foreach statement VS highlights in bold the statement that was closed. The first two source contexts are the beginning and ending of the statement that opens the block (for example, the span of the "foreach(...){" and the third source context is the closing brace for the block (e.g., the "}"). A priority can also be given so that multiple overlapping pairs can be prioritized for brace matching.
The matching pair with the highest priority (largest integer value) wins.

public:
 virtual void MatchTriple(Microsoft::VisualStudio::TextManager::Interop::TextSpan startSpan, Microsoft::VisualStudio::TextManager::Interop::TextSpan middleSpan, Microsoft::VisualStudio::TextManager::Interop::TextSpan endSpan, int priority);
public:
 virtual void MatchTriple(Microsoft::VisualStudio::TextManager::Interop::TextSpan startSpan, Microsoft::VisualStudio::TextManager::Interop::TextSpan middleSpan, Microsoft::VisualStudio::TextManager::Interop::TextSpan endSpan, int priority);
 virtual void MatchTriple(Microsoft::VisualStudio::TextManager::Interop::TextSpan startSpan, Microsoft::VisualStudio::TextManager::Interop::TextSpan middleSpan, Microsoft::VisualStudio::TextManager::Interop::TextSpan endSpan, int priority);
public virtual void MatchTriple (Microsoft.VisualStudio.TextManager.Interop.TextSpan startSpan, Microsoft.VisualStudio.TextManager.Interop.TextSpan middleSpan, Microsoft.VisualStudio.TextManager.Interop.TextSpan endSpan, int priority);
abstract member MatchTriple : Microsoft.VisualStudio.TextManager.Interop.TextSpan * Microsoft.VisualStudio.TextManager.Interop.TextSpan * Microsoft.VisualStudio.TextManager.Interop.TextSpan * int -> unit
override this.MatchTriple : Microsoft.VisualStudio.TextManager.Interop.TextSpan * Microsoft.VisualStudio.TextManager.Interop.TextSpan * Microsoft.VisualStudio.TextManager.Interop.TextSpan * int -> unit
Public Overridable Sub MatchTriple (startSpan As TextSpan, middleSpan As TextSpan, endSpan As TextSpan, priority As Integer)

Parameters

startSpan
TextSpan

[in] A TextSpan object indicating the starting element.

middleSpan
TextSpan

[in] A TextSpan object indicating the middle element.

endSpan
TextSpan

[in] A TextSpan Span object indicating the ending element.

priority
Int32

[in] A priority value used to sort overlapping triples.

Examples

The following structure is used by the managed package framework to contain a prioritized set of three language elements (for example, "foreach()", "{", and "}"). Note that this structure derives from the BraceMatch structure as described in the Example section for the MatchPair method.

internal class TripleMatch : BraceMatch  
{  
    internal TextSpan c;  

    public TripleMatch(TextSpan a, TextSpan b, TextSpan c, int priority)  
        : base(a, b, priority)  
    {  
        this.c = c;  
    }  
}  

Remarks

If the BraceMatching property returns true, this method is called to add the triple to an internal list that describes matching triples, sorted in priority order (typically the highest priority for overlapping triples wins) that is used for overlapping triples. Two examples of a matching triple in C# is "foreach(...)", "{", "}"; and "while (...)", "{", "}".

One way where matching triples overlap is with nested loops. In this scheme, the innermost loop has the highest priority and the outermost loop has the lowest priority.

The base method determines if any of the spans include the parse operation's starting point (as given by the Line and Column properties). If any of the spans include the starting point, the spans are normalized, added to an internal list of spans, and are then bundled into a TripleMatch structure that is added to another internal list. The internal list is an array of TripleMatch structures and is called Braces. See the example for the internal definition of the TripleMatch structure.

Applies to