I have iplemented a 'code behind' Dynamic language to support automatic Outlining.
The simple matches are working fine but I have one case that is condfitional.
I want to outline a block that starts with an open paren, but only if it is immediately followed by the word 'Select'.
That part works fine. The problem is determining which close paren represents the end of the outline block since there can be many sets of parens within the block.
I thought that the MatchingTokenId property could somehow be used, but when I debug the app I'm not seing this value set, and I dont know what I would be comparing it to anyway.
My language defines:
<ExplicitPatternGroup Key="OpenParen" TokenKey="OpenParen" PatternValue="(" EndBracket="CloseParen" />
<ExplicitPatternGroup Key="CloseParen" TokenKey="CloseParen" PatternValue=")" StartBracket="OpenParen" />
And the rellevant section of my override function is:
Case "OpenParen" 'set as Start if followed by 'Select'
Dim streamCopy As TokenStream = tokenStream.Clone()
streamCopy.FindNonWhitespace(True) 'Move to next token
token = streamCopy.Peek()
If token.AutoCaseCorrectText = "SELECT" Then
outliningKey = "DerivedTable"
tokenAction = OutliningNodeAction.Start
EndIf
Case "CloseParen" 'set as End if the token is paired with my start token
If token.IsPaired Then '<<< this is where the decision needs to be made
outliningKey = "DerivedTable"
tokenAction = OutliningNodeAction.End
EndIf
I'm new to the product so there may be a faster way to check the next token than cloning the stream ... but that part works.
The question is how do I determine that the current ')' token is the correct one that matches the '(' that started the outline?
Thanks
Mike