Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Preserve representation of primitives after code formatting.
Preserve representation of primitives after code formatting. [message #1705495] Mon, 17 August 2015 07:52 Go to next message
Stephan Hildebrandt is currently offline Stephan HildebrandtFriend
Messages: 25
Registered: July 2015
Junior Member
Hi,

I have the following extension of the basic Xtext terminal definitions:

Integer returns ecore::ELong:
HEX | ('-')? INT;

terminal HEX:
'0x' ('0'..'9' | 'A'..'F')+;

I.e. integer values can be either represented as normal numbers or as hexadecimal numbers. However, in the corresponding value converter's toString() method, I want decide whether to print a number as a hexadecimal number depending on how that value was represented before, i.e. how the user chose to represent it. How can I achieve that? Currently, I always return the normal (base 10) representation, which leads to the code formatter replacing all hexadecimal values with their base 10 representations.


Best regards,

Stephan

P.S.: In my domain model, I do not want any distinction between hexadecimal numbers and normal numbers. Every number in the domain model is a long value.
Re: Preserve representation of primitives after code formatting. [message #1705497 is a reply to message #1705495] Mon, 17 August 2015 07:58 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

The original text is stored in the node model. You might be interested to evaluate it during serialization.
Re: Preserve representation of primitives after code formatting. [message #1705498 is a reply to message #1705497] Mon, 17 August 2015 08:01 Go to previous message
Stephan Hildebrandt is currently offline Stephan HildebrandtFriend
Messages: 25
Registered: July 2015
Junior Member
Thanks. But how can I access the node model during serialization? The value converter's toString() method only gets the value to be serialized as a parameter and by implementing the RuleSpecific interface I can access the grammar rule. But I do not know how to get a hold of the node model.
Previous Topic:setting org.eclipse.emf.ecore.factory_override
Next Topic:Grammar debugging
Goto Forum:
  


Current Time: Thu Apr 25 11:42:44 GMT 2024

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

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

Back to the top