Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to customizing single line comment
How to customizing single line comment [message #1700126] Tue, 30 June 2015 10:15 Go to next message
Jiang Li is currently offline Jiang LiFriend
Messages: 27
Registered: November 2014
Junior Member
Because of the restriction of our dsl language we cannot use SL_COMMENT terminal directly. We have own rule of "Comment" which is defined as a parser rule.

// '..' is the identifier of our comment rule just like '//'
Comment:
    '.' '.' (ID|INT|ANY_OTHER)*
;


Now we have a problem:
How can we insert/remove '..' with standard shortcut "Ctrl+/" ? Could we reimplement this feature anywhere in XText ?

Has anybody any idea for it? Rolling Eyes

Re: How to customizing single line comment [message #1700151 is a reply to message #1700126] Tue, 30 June 2015 12:32 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
org.eclipse.xtext.ui.editor.toggleComments.ISingleLineCommentHelper.getDefaultPrefixes(ISourceViewer, String)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to customizing single line comment [message #1700187 is a reply to message #1700151] Tue, 30 June 2015 14:49 Go to previous messageGo to next message
Jiang Li is currently offline Jiang LiFriend
Messages: 27
Registered: November 2014
Junior Member
Christian Dietrich wrote on Tue, 30 June 2015 12:32
org.eclipse.xtext.ui.editor.toggleComments.ISingleLineCommentHelper.getDefaultPrefixes(ISourceViewer, String)


Thanks for your useful hints. It helps me so much.

But still a problem could not be solved. We have following grammar:
// this is not comment
..!meta foo bar

//following 2 line are comments
..!foo bar
..foo bar


It means that every line which begins with '..' is a comment except that begins with '..!meta'.

Now the problem is:
When I type 'ctrl+/' at line '..!meta foo bar', it removes the prefix '..'. But I want to insert '..' before '..!meta'.

How can I do it? Should I reimplement ToggleSLCommentAction? If yes, where is this Action called or injected?
Re: How to customizing single line comment [message #1700194 is a reply to message #1700187] Tue, 30 June 2015 15:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Try it. Bind your own Toggleslcommentaction.factory in ui module

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to customizing single line comment [message #1700247 is a reply to message #1700194] Wed, 01 July 2015 07:46 Go to previous message
Jiang Li is currently offline Jiang LiFriend
Messages: 27
Registered: November 2014
Junior Member
It works, very easy! Really cool Very Happy
Thank your very much.
Previous Topic:How to disable formatter?
Next Topic:Xtext 2.9
Goto Forum:
  


Current Time: Thu Apr 25 00:10:26 GMT 2024

Powered by FUDForum. Page generated in 0.02723 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top