Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to attatch Comments to the semantic model and serialize them
How to attatch Comments to the semantic model and serialize them [message #1815633] Mon, 07 October 2019 14:29 Go to next message
Lukas Schaus is currently offline Lukas SchausFriend
Messages: 37
Registered: October 2016
Member
Hello Everyone,

I am creating a text file from a semantic model, that i create programatically via serialization.

Now I would like to attatch comments to some elements of the semantic model and would like to find these as single line comments above the textual representation of the semantic element.

This example should elaborate my use case:

Consider this file for the greetings dsl
Hello Christian!
Hello Sebastian!
Hello Lukas!


def addCommentsToGreeting(Resource greetingDslResource)
val Model =  greetingDslResource.allContents.head as Model
model.greetings.forEach[elem|
    elem.addComment('This is a greeting')
]

greetingDslResource.save(null)


The resulting file should look like this
//This is a greeting
Hello Christian!
//This is a greeting
Hello Sebastian!
//This is a greeting
Hello Lukas!


If this cant be done while serializing it would also be interesting to add comments using the formatter.

i would prefere not to unhide the comments in the grammar.

Is there a way to achieve that?

Thanks in advance for your help.
Re: How to attatch Comments to the semantic model and serialize them [message #1815635 is a reply to message #1815633] Mon, 07 October 2019 14:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14677
Registered: July 2009
Senior Member
i have no idea if there is a facility for that but

maybe you can simply customize the HiddenTokenSequencer and add some calls to delegate.acceptComment
with comments attached as/with adapters to the EObjects


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: How to attatch Comments to the semantic model and serialize them [message #1815636 is a reply to message #1815633] Mon, 07 October 2019 14:38 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Why do you want to physically change the file? This meta information could also be shown by using so-called code minings.
Previous Topic:How to define dsl to call static field constant
Next Topic:Mwe2Launcher - Resource does not exist
Goto Forum:
  


Current Time: Mon May 06 19:36:07 GMT 2024

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

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

Back to the top