Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Post process transient attributes from comments
Post process transient attributes from comments [message #1832467] Fri, 18 September 2020 12:42 Go to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
Hello,

Here is an example of what I want to achieve :

test.myDsl:
/*
 * description of cls
 *
 * @author yan
 */
class cls
{
    ...
}

In the corresponding Ecore model, the EClass of class defines 2 transients attributes : description and author.

When the text file is parsed I would like to populate the description (" description of cls") and author("yan") of the class EObject from the comment.

On the other side, when the EMF objects are serialized (e.g if edited in ecore editor), I would like to associate the comment from the description and author attributes.

How can I do this ?

Thanks

Yannick

Re: Post process transient attributes from comments [message #1832468 is a reply to message #1832467] Fri, 18 September 2020 12:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

please have a look at IDerivedStateComputer
http://xtextcasts.org/episodes/18-model-optimization


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Post process transient attributes from comments [message #1832469 is a reply to message #1832468] Fri, 18 September 2020 13:04 Go to previous messageGo to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
Thanks, it seems perfect for parsing phase.

I implement this part first then I will have a look on how to override the comments during the serialization phase.

Yannick
Re: Post process transient attributes from comments [message #1832565 is a reply to message #1832469] Mon, 21 September 2020 08:18 Go to previous messageGo to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
Hello,

The IDerivedStateComputer works fine for retrieving the derived attributes from the documentation extracted with MultiLineCommentDocumentationProvider.

Now, how can I serialize a custom comment for an EObject ?

Yannick
Re: Post process transient attributes from comments [message #1832568 is a reply to message #1832565] Mon, 21 September 2020 08:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
no idea, you have to digg into serializer

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Post process transient attributes from comments [message #1832593 is a reply to message #1832568] Mon, 21 September 2020 13:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The Xtext design provides first class modeling of the model but relegates whitespace and comments to Node model magic from which the serializer can rescue whatever you want by a customized HiddenTokenSequencer. org.eclipse.ocl.xtext.base.serializer.BaseHiddenTokenSequencer might give you some ideas.

Regards

Ed Willink
Re: Post process transient attributes from comments [message #1832598 is a reply to message #1832593] Mon, 21 September 2020 14:52 Go to previous message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 39
Registered: July 2020
Member
Hi Ed,

Thanks for your reply.

I'me working on a workaround by using a custom non hidden MY_ML_COMMENT terminal rules.

The grammar and the processing of derived attributes (parsing+serialization) are ok. On the UI side, I lost all the default behaviour with default documention, syntax highlighting of comments, code folding,...
I will have a look to the HiddenTokenSequencer.

I can't find the org.eclipse.ocl.xtext.base.serializer.BaseHiddenTokenSequencer class. Where is it defined ?

Thanks

Yannick
Previous Topic:Problems with installing Xtext from update site
Next Topic:EObjectDescription userData and information from other Resources
Goto Forum:
  


Current Time: Tue Apr 23 14:07:06 GMT 2024

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

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

Back to the top