Dynamic child languages

SyntaxEditor for WPF Forum

Posted 12 years ago by Kasper
Version: 12.1.0561
Avatar

Hi guys,

I'm using the child language possibilites extensively, mainly for the HTML language. I use dynamic, langdef based languages, but for most of the supported languages in my application, I have a language class, which inherits from SyntaxLanguage and then loads the langdef as well as registering various services.

Now, my problem is that while this works just fine for all tha main languages, my classes are not used for child languages. Here's an example of where that is a problem: For SQL, I would like to add keywords and functions in runtime from a datafile. I simply do it in my SqlSyntaxLanguage class and it works very well, but only when SQL is the primary language. When I use it as a child language, the class is not used and therefore my keywords and functions are not added. 

I'm not sure if there's already a solution to this, or if you're working on one, but in my head, it might be as simple as an event on the SyntaxEditor that allows me to instantiate my own class whenever SyntaxEditor tries to use a child language - would something like that be possible? There are many situations where I could see the above being a problem, so I hope you can help me :)

Comments (3)

Answer - Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

You can still get at your child language lexers by running through the DynamicLexer object model.  For instance you'd find the language transition (see the docs on Dynamic Lexers) and that ILexicalStateTransition has a property for a ChildLanguage and ChildLexicalScope/State.  Then just modify the appropriate state in there.


Actipro Software Support

Posted 12 years ago by Kasper
Avatar

That would require me to do the manipulation for both the main language and the language as a child language, which seems a bit redundant. And what about the services I register for each of the languages? :)

Posted 12 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Kasper,

You may be able to swap in the same language/lexer instance post language load by injecting it into the lexical state transitions from your HTML language.  But regardless, that will only affect the lexers.  The editor currently only uses the services on the root language.


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.