Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Accessing comments in Xtext grammars(How to get the comments from the original Xtext files)
Accessing comments in Xtext grammars [message #905901] Fri, 31 August 2012 09:30 Go to next message
Mathias Soeken is currently offline Mathias SoekenFriend
Messages: 2
Registered: August 2012
Junior Member
Hello,

I would like to annotate my rules using comments as there are no explicit annotations. I have seen that the comments are not transferred into the XMI model and are also not modeled in the Xtext meta model. However, in the generated *.services.*GrammarAccess.java file the comments are present.

Is there a way to access the comments in the Xtext grammar files e.g. to write them into a separate file using the MWE2 workflow?

Regards,
Mathias
Re: Accessing comments in Xtext grammars [message #905910 is a reply to message #905901] Fri, 31 August 2012 09:47 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
Hi,

(a) use them explicit in the grammar (unhide them + assign them to a feature)
(b) use the NodeModelUtils to access the node model. you find hidden leaf nodes for the comments there.

~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing comments in Xtext grammars [message #905970 is a reply to message #905910] Fri, 31 August 2012 11:49 Go to previous messageGo to next message
Mathias Soeken is currently offline Mathias SoekenFriend
Messages: 2
Registered: August 2012
Junior Member
Hi,

thanks for the reply but I am not completely understanding you. I do not mean the Xtext comments ML_COMMENT and SL_COMMENT. I mean the actual user comments that you can put into an Xtext file with '//' or '/* */'. So, it does not add anything to the language as it is only a comment. However, since it is copied to the *.services.*GrammarAccess.java it must have been parsed somehow.

Regards,
Mathias
Re: Accessing comments in Xtext grammars [message #905978 is a reply to message #905970] Fri, 31 August 2012 12:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
Hi the parsed text is the node model and you can access it using the
nodemodelutil class

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Accessing comments in Xtext grammars [message #905981 is a reply to message #905970] Fri, 31 August 2012 12:06 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13359
Registered: July 2009
Senior Member
PS have a look at the class (I think it is called)
multilinecommentdocumentationprovider

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:StyledTextXtextAdapter and minimum required extension-points
Next Topic:errors from 2.3.1
Goto Forum:
  


Current Time: Fri Feb 21 13:34:10 GMT 2020

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

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

Back to the top