Skip to main content



      Home
Home » Modeling » TMF (Xtext) » formatting/serializing of optional attributes
formatting/serializing of optional attributes [message #1067994] Thu, 11 July 2013 11:21 Go to next message
Eclipse UserFriend
Hi,

I have this rule using an optional integer attribute 'time':

PhysicalThread:
(default?='DefaultThread' | 'Thread') name=ID '{'
'execmode' '=' execmode=ExecMode
('interval' '=' time=TIME)?
'prio' '=' prio=PRIO
'stacksize' '=' stacksize=INT
'msgblocksize' '=' msgblocksize=INT
'msgpoolsize' '=' msgpoolsize=INT
'}'
;

Where TIME is a data type rule with a value converter to Integer.

Some execmodes need a time interval specified, others don't.
This is checked by validation and a quick fix is offered for both cases.

When the quick fix should remove the time interval I use an ISemanticModification to set the value to its default of 0.
The result is e.g.

DefaultThread PhysicalThread1 {
execmode = blocked
interval = 0s
prio = 0
stacksize = 1024
msgblocksize = 32
msgpoolsize = 10
}

But I would prefer the equivalent with the optional attribute assignment omitted completely

DefaultThread PhysicalThread1 {
execmode = blocked
prio = 0
stacksize = 1024
msgblocksize = 32
msgpoolsize = 10
}

How can this be achieved?
I already tried to make the attribute unsettable and then unsetting it in the quick fix - same result.

Thanks,
Henrik
Re: formatting/serializing of optional attributes [message #1133037 is a reply to message #1067994] Fri, 11 October 2013 11:10 Go to previous messageGo to next message
Eclipse UserFriend
Hi Henrik,

did you find a solution to your question?

Re: formatting/serializing of optional attributes [message #1410716 is a reply to message #1133037] Thu, 21 August 2014 08:52 Go to previous messageGo to next message
Eclipse UserFriend
Hi Axel,

no, I couldn't find a solution (but didn't investigate with newer versions of Xtext).

-Henrik

Am 11.10.2013 um 17:10 schrieb Axel Guckelsberger:
> Hi Henrik,
>
> did you find a solution to your question?
>
>
Re: formatting/serializing of optional attributes [message #1411048 is a reply to message #1410716] Fri, 22 August 2014 05:03 Go to previous message
Eclipse UserFriend
I'm no expert on this, but just an idea:

In your Quickfix, you use the semantic model approach and set the value to 0.
What about deleting the complete interval instance from the AST?

Previous Topic: Highlighting problem
Next Topic:Referencing elements of one DSL from another DSL
Goto Forum:
  


Current Time: Thu Jul 03 07:08:04 EDT 2025

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

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

Back to the top