Single and Range LineCommenters in same language

SyntaxEditor for WPF Forum

Posted 8 years ago by James Deadman
Version: 11.1.0542
Avatar
Hi,

I am attempting to add the ILineCommenter service to a syntax language (C#). From your examples it demonstrates single-line commenters and line-range commenters.

It seems that if i register both a single-line and line-range commenters to the syntax language, it only ever comments-out using line-range indicators (/* */) rather than single line commenting (//).

Is it possible to use both styles together? Obviously languages such as C# use both styles and so it would be nice for Syntax Editor to intelligently add line-comments depending on whether a single line or multiple lines are selected. How would i implement this please?

Thanks,
James

Comments (2)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi James,

Only one ILineCommenter service can be registered at a time on a language. That way the comment/uncomment lines commands know what can be executed.

Since ILineCommenter is an interface you can write whatever logic you wish in a custom ILineCommenter implementation. You could make a hybrid version that creates instances of the range and single line versions and based on if there is a \n character in the snapshot range passed to the Comment/Uncomment methods, call the appropriate wrapped line commenter.


Actipro Software Support

Posted 8 years ago by James Deadman
Avatar
Hello,

I had a feeling this might be the case. For the moment i'll have to pick one comment-style i think, and then time-depending i will create a custom LineCommenter as you suggest.

Thanks for your help,
James
The latest build of this product (v2019.1 build 0683) 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.