Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Hide technical UID in XText editor
Hide technical UID in XText editor [message #1747021] Tue, 08 November 2016 15:27 Go to next message
Steffen Grieser is currently offline Steffen GrieserFriend
Messages: 2
Registered: November 2016
Junior Member
Hi,

I have created a textual DSL using the Xtext framework. The target language of the DSL requires a technical UID for almost every grammar element. Once assigned to an element, the UID must not be modified in subsequent code generations. Therefore, the ID has to be part of the DSL grammar e.g.:

Element:
	uid=UID
	'element' name=ID '{'
	    children+=Element*
        '}'
;

UID: '@ID' '(' value=ID ')' ;


The problem is: this ID spoils the content in the XText editor. Therefore I am looking for a way to hide it in the XText editor. Important: this has nothing to do with 'hidden tokens' as I need the UID value in the AST during code generation but want to not show it in the XText editor.

My first idea was to remove the UID from the node nodel after parsing. Is this a sensible solution? Does anyone know a better solution?

Looking forward for any response!
Re: Hide technical UID in XText editor [message #1747233 is a reply to message #1747021] Fri, 11 November 2016 05:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13637
Registered: July 2009
Senior Member
i dont know a nice way to do this. maybe you can use the folding feature to hide the IDs, but i am not sure if this will work in all cases

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Hide technical UID in XText editor [message #1747518 is a reply to message #1747233] Tue, 15 November 2016 15:36 Go to previous messageGo to next message
Steffen Grieser is currently offline Steffen GrieserFriend
Messages: 2
Registered: November 2016
Junior Member
Folding was my first approach. I successfully hided the uids by building a region of the uid and the name of an Element. When the region is (by default) folded, only the name feature is visible. Basically, this is exactly what I was looking for. A problem arises when the name of the Element is edited. Then, the region is unfolded automatically and the uid is visible again. Moreover, when an element is moved (cut/paste actions), it is not assured that the uid is copied with the name.

I keep the folding in mind as a fallback solution. But I am still searching for a way to solve the problem programmatically.

Anyway, thank you very much for the reply!
Re: Hide technical UID in XText editor [message #1750096 is a reply to message #1747518] Fri, 16 December 2016 06:11 Go to previous messageGo to next message
Puneet Patwari is currently offline Puneet PatwariFriend
Messages: 64
Registered: November 2014
Member
Hi Steffan

Did you find any solution? I am also looking for the same thing. any help will be appreciated.

Puneet
Re: Hide technical UID in XText editor [message #1831366 is a reply to message #1750096] Tue, 18 August 2020 09:16 Go to previous messageGo to next message
Georgiana Ecobici is currently offline Georgiana EcobiciFriend
Messages: 23
Registered: July 2019
Junior Member
Hello,

There are any updates on this topic, how to hide technical details in xtext?

Thanks.
Re: Hide technical UID in XText editor [message #1831368 is a reply to message #1831366] Tue, 18 August 2020 11:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6874
Registered: July 2009
Senior Member
Hi

Xtext has a lot of magic capabilities for hidden nodes/comments.

So one approach might be to contrive a couple of variants of emitComments, one of which serializes the ID and the other serializes it as an empty String.

Another approach might be to have two features for the ID; one for when you want it displayed and one for transient and/or volatile and/or derived variable for when you hide it. You just need to ensure that YourSaveImpl unhides the IDs before a save to disk. You might find that an EAnnotation works here too. You might even find that there is a combination of transient/volatile/derived that EMF persists, but which Xtext does not serialize. NB precise control of transient/volatile/derived will require a manually maintained *.ecore.

If you're prepared to indulge in the equivalent of self-modifying code, you could try dynamically tweaking transient/volatile/derived in the metamodel or perhaps the grammar to suit your prevailing mood.

Regards

Ed Willink
Re: Hide technical UID in XText editor [message #1831466 is a reply to message #1831368] Thu, 20 August 2020 11:06 Go to previous message
Georgiana Ecobici is currently offline Georgiana EcobiciFriend
Messages: 23
Registered: July 2019
Junior Member
I don't understand very well how to approach this.

"Another approach might be to have two features for the ID; one for when you want it displayed and one for transient and/or volatile and/or derived variable for when you hide it"

How can I add a feature that is not displayed?

I manually modify the ecore model of the grammar and add the technical details I need? I need to ad an ID in case I have duplicated elements by name.

[Updated on: Thu, 20 August 2020 11:14]

Report message to a moderator

Previous Topic:Not able to open project files when xtext build runs
Next Topic:How can I use xtext embedded editor as a real editor page?
Goto Forum:
  


Current Time: Mon Oct 26 08:48:19 GMT 2020

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

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

Back to the top