ILineCommenter Service

SyntaxEditor for WPF Forum

Posted 3 years ago by Rick - Developer, Visual Software Systems LLC
Version: 21.1.1
Avatar

Does SyntaxEditor support registering multiple ILineCommenter instances? My language supports two different line comment delimiters '--' and '//' and I want the EditorCommands.CommentLines and EditorCommands.UncommentLines commands to support them both, if possible.  I tried registering two and it seems that the last one registered overrode the first.  

Comments (4)

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

Hi Rick,

I'm sorry but a single ILineCommenter language service can only be registered at a time.  So yes, one will override the other.  How did you ideally want to support both comment delimiters?


Actipro Software Support

Posted 3 years ago by Rick - Developer, Visual Software Systems LLC
Avatar

Thanks, I thought as much.  My thought is that when registering an ILineCommenter you could specify a parameter indicating that it is the preferred commenter. EditorCommands.CommentLines it would look for the preferred commenter and use that one, if found.  If no preference found, use the first one registered.  If multiple preferred registered, last one registered wins.  EditorCommands.UncommentLines would uncomment any line that starts with a registered ILineCommenter.

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

Hi Rick,

I see... right now only one comment delimiter is supported in our LineBaseLineCommenter class.  You might be able to override that class and its Uncomment method, and call the base method.  If that ends up changing anything, I think the "snapshot.Document.CurrentSnapshot" would no longer be the "snapshot".  So if the current snapshot remained the same, no change was made, and you could set the commenter's StartDelimiter property to your alternate delimiter.  Then call the base method again.  After that restore the StartDelimiter to your primary delimiter.  It's a little kludgey but might work with the existing code for your needs.

We also will add a suggestion request for enhancing line commenters to support more than one comment kind.


Actipro Software Support

Posted 3 years ago by Rick - Developer, Visual Software Systems LLC
Avatar

Thanks!

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

Add Comment

Please log in to a validated account to post comments.