Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » What'S EStructucalFeature and how to convert enum grammar defintions to it?
What'S EStructucalFeature and how to convert enum grammar defintions to it? [message #1836067] Sat, 19 December 2020 15:41 Go to next message
Nils K. is currently offline Nils K.Friend
Messages: 13
Registered: November 2020
Junior Member
Hi there,

today, I have the issue that some existing code accepts grammar definitions that belong to type EStructuralFeature only (see filter below).

Can someone please explain me what that actually is and how to define a grammar type to fit that definition?

For instance, I created an enum property consisting of the three values and would like to include it in the generated code later:

enum mode:
off |
on |

In some other files/classes it appears that all grammar definitions get filtered before the actual code generation (xtend to java)

... source.eClass.getEAllContainments.filter(EStructuralFeature f | ... ) ...

and it appears that my mode definition is not of type EStructuralFeature. Also, please notice that I'm not allowed to change that function here that much. The only idea I could think of is adding that enum type as another parameter..... what Etype is enum?

Or, convert enum to an EStructuralFeature. How can I achieve that?

Re: What'S EStructucalFeature and how to convert enum grammar defintions to it? [message #1836074 is a reply to message #1836067] Sat, 19 December 2020 18:19 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7594
Registered: July 2009
Senior Member

Your code most certainly is of type EStructuralFeature. In the jargon you have confused metalevels. Your grammar uses an EClassifier(EClass/EDatasType/...) for each of your types, and an EStructiralFeature(EAttribute/EReferemce) for each of the properties/features of those types. Thus in Java your code is (meta-)modelled by Java's Class and Java's Field classes. Your filter is iterating all the contrainment features, which are necessarily EStructuralFeature.

You might want to study a UML or Ecore (meta)modeling tutorial. In UML there are Class and Property whereas in Ecore there are EClass and EStructuralFeature. The names differ but the principles are very similar.

An EEnum is an EClassifier; a type. It cannot be converted to an EStructuralFeature; a relationship.


Ed Willink
Previous Topic:grammar to permit zipfiles in a string
Next Topic:ID and Fully Qualified name problem
Goto Forum:

Current Time: Thu Jun 01 21:57:13 GMT 2023

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

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

Back to the top