Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Error using Derived EMF EAttributes with Sirius and Xtext(An Ecore Metamodel specifies attributes defined as Derived+Transient+Volatile Features causes an Error when trying to save a Model in a Sirius-based Editor)
Error using Derived EMF EAttributes with Sirius and Xtext [message #1774926] Sat, 21 October 2017 08:28 Go to next message
Alex Lotz is currently offline Alex LotzFriend
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)

index.php/fa/31079/0/).

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.
Re: Error using Derived EMF EAttributes with Sirius and Xtext [message #1774992 is a reply to message #1774926] Mon, 23 October 2017 10:00 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
Hi,

It is hard to tell without the complete stack.
Have you installed the Sirius-Xtext bridge ? (feature org.eclipse.sirius.runtime.ide.xtext "Sirius Integration with Xtext")

Regards,

Pierre


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Error using Derived EMF EAttributes with Sirius and Xtext [message #1774995 is a reply to message #1774992] Mon, 23 October 2017 10:22 Go to previous messageGo to next message
Alex Lotz is currently offline Alex LotzFriend
Messages: 9
Registered: October 2017
Junior Member
I did so now, this did not solve the problem. Here is the error stack:

Exception:java.lang.IllegalArgumentException: Imported namespace must not be null / empty
	 at org.eclipse.xtext.scoping.impl.ImportNormalizer.<init>(ImportNormalizer.java:27)
	 at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.doCreateImportNormalizer(ImportedNamespaceAwareLocalScopeProvider.java:190)
	 at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getLocalElementsScope(ImportedNamespaceAwareLocalScopeProvider.java:208)
	 at org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getScope(ImportedNamespaceAwareLocalScopeProvider.java:99)
	 at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.delegateGetScope(DelegatingScopeProvider.java:42)
	 at org.eclipse.xtext.scoping.impl.DelegatingScopeProvider.getScope(DelegatingScopeProvider.java:38)
	 at org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:90)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:481)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:238)
	 at HIDDEN.HIDDEN(HIDDEN:-1)
	 at HIDDEN.HIDDEN(HIDDEN:-1)
	 at org.eclipse.xtext.serializer.sequencer.AbstractSemanticSequencer.createSequence(AbstractSemanticSequencer.java:67)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:325)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:352)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:263)
	 at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:434)
	 at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:501)
	 at HIDDEN.HIDDEN(HIDDEN:-1)
	 at HIDDEN.HIDDEN(HIDDEN:-1)
	 at org.eclipse.xtext.serializer.sequencer.AbstractSemanticSequencer.createSequence(AbstractSemanticSequencer.java:67)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:325)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:352)
	 at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:263)
	 at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:434)
	 at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:501)
	 at HIDDEN.HIDDEN(HIDDEN:-1)
	 at HIDDEN.HIDDEN(HIDDEN:-1)
	 at org.eclipse.xtext.serializer.sequencer.AbstractSemanticSequencer.createSequence(AbstractSemanticSequencer.java:67)
	 at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:115)
	 at org.eclipse.xtext.serializer.impl.Serializer.serializeToRegions(Serializer.java:136)
	 at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:142)
	 at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:189)
	 at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:386)
	 at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1430)
	 at org.eclipse.sirius.business.internal.session.danalysis.ResourceSaveDiagnose.hasDifferentSerialization(ResourceSaveDiagnose.java:84)
	 at org.eclipse.sirius.business.internal.session.IsModifiedSavingPolicy.hasDifferentSerialization(IsModifiedSavingPolicy.java:210)
	 at org.eclipse.sirius.business.internal.session.IsModifiedSavingPolicy.computeResourcesToSave(IsModifiedSavingPolicy.java:191)
	 at org.eclipse.sirius.business.api.session.AbstractSavingPolicy.save(AbstractSavingPolicy.java:57)
	 at org.eclipse.sirius.common.xtext.internal.XtextSavingPolicy.save(XtextSavingPolicy.java:68)
	 at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl$1.run(DAnalysisSessionImpl.java:802)
	 at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328)
	 at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.doSave(DAnalysisSessionImpl.java:811)
	 at org.eclipse.sirius.business.internal.session.danalysis.Saver.wrappedSave(Saver.java:145)
	 at org.eclipse.sirius.business.internal.session.danalysis.Saver.access$0(Saver.java:134)
	 at org.eclipse.sirius.business.internal.session.danalysis.Saver$1.run(Saver.java:122)
	 at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
	 at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2262)
	 at org.eclipse.sirius.business.internal.session.danalysis.Saver.saveNow(Saver.java:119)
	 at org.eclipse.sirius.business.internal.session.danalysis.Saver.save(Saver.java:95)
	 at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.save(DAnalysisSessionImpl.java:775)
	 at org.eclipse.sirius.business.internal.session.danalysis.DAnalysisSessionImpl.save(DAnalysisSessionImpl.java:770)
	 at org.eclipse.sirius.diagram.ui.tools.internal.resource.CustomSiriusDocumentProvider.doSaveDocument(CustomSiriusDocumentProvider.java:283)
	 at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider$1SaveOperation.execute(AbstractDocumentProvider.java:596)
	 at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider$DocumentProviderOperation.run(AbstractDocumentProvider.java:66)
	 at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider.executeOperation(AbstractDocumentProvider.java:530)
	 at org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.AbstractDocumentProvider.saveDocument(AbstractDocumentProvider.java:579)
	 at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.performSave(DiagramDocumentEditor.java:864)
	 at org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor.doSave(DiagramDocumentEditor.java:684)
	 at org.eclipse.sirius.ui.business.internal.session.SaveSessionRunnable.run(SaveSessionRunnable.java:62)
	 at org.eclipse.ui.internal.SaveableHelper$2.run(SaveableHelper.java:370)
	 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)


BUNDLES

name                org.eclipse.core.jobs
version             3.9.1.v20170714-0547

name                org.eclipse.core.resources
version             3.12.0.v20170417-1558

name                org.eclipse.emf.ecore
version             2.13.0.v20170609-0707

name                org.eclipse.emf
version             2.6.0.v20170609-0928

name                org.eclipse.emf.transaction
version             1.9.0.201706061339

name                org.eclipse.gmf.runtime.diagram.ui.resources.editor
version             1.7.0.201706061437

name                org.eclipse.gmf.runtime.diagram.ui
version             1.8.0.201706061437

name                org.eclipse.gmf
version             1.11.0.201706061437

name                org.eclipse.sirius
version             5.0.2.201708291328

name                org.eclipse.sirius.common.xtext
version             5.0.2.201708291328

name                org.eclipse.sirius.common
version             5.0.2.201708291328

name                org.eclipse.sirius.diagram.ui
version             5.0.2.201708291328

name                org.eclipse.sirius.diagram
version             5.0.2.201708291328

name                org.eclipse.sirius.ui
version             5.0.2.201708291328

name                org.eclipse.ui
version             3.109.0.v20170411-1742

name                org.eclipse.xtext
version             2.12.0.v20170518-0959

name                org.xtext.example.mydsl
version             1.0.0.qualifier
Re: Error using Derived EMF EAttributes with Sirius and Xtext [message #1775097 is a reply to message #1774995] Tue, 24 October 2017 14:15 Go to previous messageGo to next message
Pierre Guilet is currently offline Pierre GuiletFriend
Messages: 250
Registered: June 2017
Senior Member
I think the problem is related to your qualifiedNameProvider returning an empty qualified name when called from org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider.getLocalElementsScope(IScope, EObject, EReference) .
In this situation the import cannot be determined.

I suggest to debug this method code to see what object cannot have its qualified name computed and why.

Regards,


Pierre Guilet - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

[Updated on: Tue, 24 October 2017 14:47]

Report message to a moderator

Re: Error using Derived EMF EAttributes with Sirius and Xtext [message #1778046 is a reply to message #1775097] Fri, 08 December 2017 14:38 Go to previous message
Alex Lotz is currently offline Alex LotzFriend
Messages: 9
Registered: October 2017
Junior Member
Hi,

it seems that my problem indeed is related to my implementation of the qualified name provider. When I add a new "LinkToSub" and try to save the model, then the qualified name provider returns an empty name (as correctly assumed by Pierre Guilet). More precisely, the call:
NodeModelUtils.findNodesForFeature(...)
returns an empty node-set. I did some debugging and figured out that the method "ICompositeNode getNode(EObject)" from NodeModelUtils is not able to find a composite node in my specific case. It is hard for me to guess where the cause of the problem is. For instance, I am not quite sure what is the actual context from where the qualified name provider and thus the NodeModelUtils is called. It seems that at the calling point, the feature "subentity" is not (yet) set correctly. So far I have not found a solution to overcome this problem.

The question also is, is there any other way to implement the qualified name provider, e.g. without using the NodeModelUtils at all? Or maybe is there any other way to realize my use-case (with the derived feature) without using a custom qualified name provider?

Can anybody help me?

Thanks in advance,
Alex
Previous Topic:[ANN] Sirius 4.1.8
Next Topic:Issues with Sirius Install
Goto Forum:
  


Current Time: Tue Apr 07 05:09:08 GMT 2020

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

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

Back to the top