Posted 17 years ago by Ernesto Obregon
Version: 4.0.0262
Avatar
Is there a way to force a text value into a token or itoken in code (VB.NET)? I have a collection of key words in a structure I use for intellisense. When typing in the document even if I only type a single letter I pull up commands in the memberlist, however a single letter is not a keyword yet so I can not check it against the token collection to find out what the current token.key is. So I need to force a keyword (string value) on the fly into a token object so I can check what that tokens key is as defined in the XML Language.

Or is there another way to check my string value against the keywords in my language file?

thanks
teamels

Comments (3)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
If you are using a dynamic language you can iterate through the whole object model and even down to pattern level. So you can find the lexical pattern group for your keywords and iterate through the patterns to do comparisons. Just compare your string against those.


Actipro Software Support

Posted 17 years ago by Ernesto Obregon
Avatar
I have been looking to find a way down to this information, but am having trouble understanding the way down the path.

I can see the LexicalPatterGroups if I look at:

editor.document.language.DefaultLexicalState.ActipSoftwareSyntaxEditor.Addons.Dynamic.DynamicLexicalState.LexicalPattergroup
But I am not sure how to really get there to iterate through them any ideas?
Am I even on the right path here?

thanks
teamels
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
ILexicalState is returned by DefaultLexicalState and for your scenario you need to cast it to a DynamicLexicalState like this:
((DynamicLexicalState)editor.Document.Language.DefaultLexicalState).LexicalPatternGroups["ReservedWords"]
That example also assumes that your pattern group with the keywords in them have a Key="ReservedWords" attribute on them. Note that Key is different from TokenKey.

Once you have the above, you can iterate through the pattern group, which is what is returned by that code.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.