Skip to main content



      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 10:29 Go to next message
Eclipse UserFriend
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 10:38 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: How to attatch Comments to the semantic model and serialize them [message #1815636 is a reply to message #1815633] Mon, 07 October 2019 10:38 Go to previous message
Eclipse UserFriend
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: Wed Mar 26 16:43:16 EDT 2025

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

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

Back to the top