ContentDividerType on NonMergableTokenBase

SyntaxEditor for Windows Forms Forum

Posted 17 years ago by Paul Fuller
Version: 4.0.0257

I am trying to implement content dividers in an 'advanced' language.

I have tried setting the ContentDividerType property on tokens derived from NonMergableTokenBase but the value will not alter from the value None. This is whether the change is tried in either the lexical parser phase (when the token is created) or in the semantic parser phase.

For example in the token constructor (called during the lexical parsing) the following code is being encountered and the condition is true. The assignment statement executes but the value is not altered.

if (m_Id == QTokenId.MyCommand)
    this.ContentDividerType = TokenContentDividerType.Before;
NonMergableTokenBase.ContentDividerType is documented as having both Get and Set and it obviously does otherwise the code would not compile.

Is this a bug or am I doing something incorrectly ?


Comments (4)

Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Paul,

NonMergableTokenBase implements that property as a "dummy" property. It will always return no content divider and the setter does nothing. That is just so that you can use NonMergableTokenBase to implement most of IToken without adding memory.

However in your token class that inherits NonMergableTokenBase, simply override ContentDividerType and add a getter/setter that accesses a TokenContentDividerType field on your token class.

Actipro Software Support

Posted 17 years ago by Paul Fuller
Ok. I suggest you note this in the help on NonMergableTokenBase.ContentDividerType. Perhaps also in the general topic on content dividers. There is already some information there on using the dividers with dynamic languages.

Next problem - After implementing the override, the value can now be set properly. However the editor still does not display the dividers. The values are set on the editor and on the renderer.

syntaxEditor.ContentDividersVisible = true;
renderer.ContentDividerColor = Color.CornflowerBlue;
renderer.ContentDividerDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
All of this executes and the properties are set properly.

Tracing through I noticed that the token.ContentDividerType getter is never called. So there must be some reason that the editor is not even examining the property on the tokens.
Posted 17 years ago by Actipro Software Support - Cleveland, OH, USA
Thanks Paul, we'll update the docs on this.

Sorry also when looking at NonMergableTokenBase, the ContentDividerTypeResolved property is returning None all the time whereas if you implemented ContentDividerType, it should be returning the value of the ContentDividerType property. So override ContentDividerTypeResolved to return "this.ContentDividerType". See if that gets you going.

Actipro Software Support

Posted 17 years ago by Paul Fuller
That's it.

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

Add Comment

Please log in to a validated account to post comments.