Error using Derived EMF EAttributes with Sirius and Xtext [message #1774926] |
Sat, 21 October 2017 08:28 |
Alex Lotz Messages: 9 Registered: October 2017 |
Junior Member |
|
|
I have a problem using Derived+Transient+Volatile EMF Attributes within a Sirius-based Editor in combination with an Xtex-based grammar. To be more specific, I have created a simple Ecore metamodel (see attached ecore-metamodel.png figure)
).
Basically, there are "MainEntities" that contain "SubEntities" and "AnotherSubEnties". An "AnotherSubEntity" can create Links to SubEntities. Please note the EAttribute "name" of "LinkToSub" which is unchangeable, volatile, transient and derived. The idea is that I can specify a "LinkToSub" by just giving a reference to a "SubEntity" and the name of "LinkToSub" is directly derived from this reference. This allows to maintain a nice AST without the need to enter arbitrary, not needed names.
From this metamodel, I have derived an Xtext grammar with obvious semantics. The only part I needed to tweak within this grammar is my own IQualifiedNameProvider. Therefore I provide an extended version of DefaultDeclarativeQualifiedNameProvider that basically calculates the name for LinkToSub during the prelinking phase. This works fine for my Xtext grammar.
def QualifiedName qualifiedName(LinkToSub link) {
val nodes = NodeModelUtils.findNodesForFeature(link, MetamodelPackage.Literals.LINK_TO_SUB__SUBENTITY);
if(!nodes.isEmpty()) {
val refname = NodeModelUtils.getTokenText(nodes.get(0));
val parentName = super.getFullyQualifiedName(link.eContainer());
val fqn = parentName.append(refname);
return fqn;
}
return QualifiedName.EMPTY;
}
Moreover, I have also created a Sirius-based model editor where I can model SubEntities, AnotherSubEntities and LinksToSub (as Edges). When I create a LinkToSub, it graphically creates the edge as expected and the properties view shows the right reference to the target SubEntity. The problem now is, when I try to save the model, I get the following error in a popup window:
An internal error occurred during: "Saving Models and Representations for project SiriusBugTest".
Imported namespace must not be null / empty
And here I got stuck. I don't see obvious reasons for what I could have made wrong and the message is too cryptic to guess the cause of the error. So far I could deduce that the problem seems to be related to the derived EAttribute and that it is somehow related to using Sirius in combination with Xtext. The latter became evident because if I create a model not using the Xtext grammar but the generated EMF tree editor, then this error does not appear.
So did anybody had the same problems? Are there obvious mistakes on my side? Or can anybody help me?
I am using Eclipse Oxygen with Sirius 5.0.2 and Xtext 2.12.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03766 seconds