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.:
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?
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.