Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Retrieving hidden comments
Retrieving hidden comments [message #1420650] Wed, 10 September 2014 09:14 Go to next message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hello,

I'm pretty sure that this topic has already been covered but I can't find a lot of information about it.
I would like to retrieve comments that the user has entered in the file. These comments have to be added in the generated code. Of course, I can extend my grammar so that all grammar elements have an additional comment, but I would like to leave my grammar as clean as possible.

In the Xtext documentation, they are talking about a comment associator, but this is actually used for serialization (so, in the other direction). Is there a way I could use this for my purpose ?

What would be the easiest way to implement something like this ? Since I do not need to serialize models created programmatically, this might be a bit easier I guess?

Thanks
Re: Retrieving hidden comments [message #1420697 is a reply to message #1420650] Wed, 10 September 2014 10:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6534
Registered: July 2009
Senior Member
Hi Cedric

Xtext has nice support for comments as hidden tokens so you do not need
to change your grammar at all.

Since you're familiar with the OCL code have a look at

org.eclipse.ocl.examples.xtext.base.cs2as.CS2Pivot.getDocumentationNodes().

and

org.eclipse.ocl.examples.xtext.essentialocl.serializer.EssentialOCLHiddenTokenSequencer.emitComments().

Unfortunately there is an outstanding Xtext bug in the
formatting/indentation of multi-line comments leading to the poor
appearance of some comments in OCLinEcore.

Regards

Ed Willink

On 10/09/2014 10:14, Cedric Moonen wrote:
> Hello,
>
> I'm pretty sure that this topic has already been covered but I can't
> find a lot of information about it.
> I would like to retrieve comments that the user has entered in the file.
> These comments have to be added in the generated code. Of course, I can
> extend my grammar so that all grammar elements have an additional
> comment, but I would like to leave my grammar as clean as possible.
>
> In the Xtext documentation, they are talking about a comment associator,
> but this is actually used for serialization (so, in the other
> direction). Is there a way I could use this for my purpose ?
>
> What would be the easiest way to implement something like this ? Since I
> do not need to serialize models created programmatically, this might be
> a bit easier I guess?
>
> Thanks
Re: Retrieving hidden comments [message #1420735 is a reply to message #1420697] Wed, 10 September 2014 11:45 Go to previous message
Cedric Moonen is currently offline Cedric MoonenFriend
Messages: 274
Registered: August 2009
Senior Member
Hi Ed,

Thanks for the reply, this was exactly what I was looking for Razz
Previous Topic:renaming of "declaration-by-reference-objects"
Next Topic:Inconsistent formatting observed in using Xtext formatter
Goto Forum:
  


Current Time: Fri Dec 06 21:06:28 GMT 2019

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

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

Back to the top