MatchingTokenID property and bracket tokens

SyntaxEditor for Windows Forms Forum

Posted 12 years ago by Alexey Chuikov - Project Tech Leader. Custom Development, Quest Software
Version: 4.0.0253

I use XML for dynamic language definition. Defining bracket tokens in following way

<ExplicitPatternGroup TokenID="1" Key="OpenParenthesisPatternGroup" TokenKey="OpenParenthesisToken" PatternValue="(" EndBracket="CloseParenthesisPatternGroup"/>
        <ExplicitPatternGroup TokenID="2" Key="CloseParenthesisPatternGroup" TokenKey="CloseParenthesisToken" PatternValue=")" StartBracket="OpenParenthesisPatternGroup"/>
I get start and end brackets highlighted, so it seems editor knows about bracket matching. But MatchingTokenID property of bracket tokens remains zero. So, I cannot get information on brackets relations without re-parsing text. Am I missing something? Is there a simple way to match brackets?

Thanks in advance,

Comments (2)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Dynamic language tokens don't use the MatchingTokenID property however you could change the language so that it uses a custom token class (that inherits DynamicToken) and implements that property as you need.

Alternatively the BracketHighlighting class (off of EditorView) has properties for the current bracket and matching bracket tokens. Perhaps that will provide what you need.

Also TextStream has methods like GoToPreviousMatchingToken that you can use, with one overload allowing you to specify the target token ID.

Actipro Software Support

Posted 12 years ago by Alexey Chuikov - Project Tech Leader. Custom Development, Quest Software
Thanks a lot! TextStream's method

bool GoToPreviousMatchingToken(IToken endToken, int startTokenID) 
helped as a simple resolution.

The latest build of this product (v2018.1 build 0341) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.