Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » No EObjectDescription could be found in Scope when saving a model
No EObjectDescription could be found in Scope when saving a model [message #1395779] Mon, 07 July 2014 11:41 Go to next message
Mary P. is currently offline Mary P.Friend
Messages: 48
Registered: November 2012
Member
Hello,
When I try to save my model, I get the following exception: java.lang.RuntimeException: No EObjectDescription could be found in Scope

Here are some details:

-From my model, I have a cross-reference to UML Operations.
-I implemented my QualifiedNameProvider such that it produces "simple" names for the UML Operations, i.e. the names that do not include the container of an operation, but only its own name. For example, for an operation "Op" of a class "Cl", it will generate a Qualified Name "Op" instead of "Cl.Op". I understand, that in this case the Qualified Names of the Operations are not unique.
- I implemented my ScopeProvider such that in a given context the scope will include only Operations with unique names. I.e. among several Operations with the same names it will add to the scope only one of them depending on the context.

The problem occurs when I have two UML Operations with the same names. In this case, if I refer to one of them from my Xtext Editor, everything works fine. But when I try to save the model, I get the following exception:

!ENTRY org.obeonetwork.dsl.viewpoint.xtext.support 4 0 2014-07-07 11:40:50.487
!MESSAGE No EObjectDescription could be found in Scope [..]
Semantic Object: [..]
!STACK 0
java.lang.RuntimeException: No EObjectDescription could be found in Scope [..]
Semantic Object: [..]
	at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:70)
	at org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.getCrossReferenceNameFromScope(CrossReferenceSerializer.java:147)
	at org.eclipse.xtext.serializer.tokens.CrossReferenceSerializer.serializeCrossRef(CrossReferenceSerializer.java:120)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.getToken(SequenceFeeder.java:453)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:220)
	at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:401)
	at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:439)
	at mypackage.xtext.serializer.MyModelSemanticSequencer.sequence_MCall(MyModelSemanticSequencer.java:164)
	at mypackage.xtext.serializer.VceXSemanticSequencer.createSequence(MyModelSemanticSequencer.java:76)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
	at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:394)
	at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:439)
	at mypackage.xtext.serializer.MyModelSemanticSequencer.sequence_MyObject(MyModelSemanticSequencer.java:198)
	at mypackage.xtext.serializer.MyModelSemanticSequencer.createSequence(MyModelSemanticSequencer.java:95)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptEObjectRuleCall(SequenceFeeder.java:299)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.acceptRuleCall(SequenceFeeder.java:325)
	at org.eclipse.xtext.serializer.acceptor.SequenceFeeder.accept(SequenceFeeder.java:239)
	at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.accept(BacktrackingSemanticSequencer.java:394)
	at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:439)
	at mypackage.serializer.MyModelSemanticSequencer.sequence_MyObject2(MyModelSemanticSequencer.java:173)
	at mypackage.xtext.serializer.MyModelSemanticSequencer.createSequence(MyModelSemanticSequencer.java:82)
	at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:85)
	at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:108)
	at org.eclipse.xtext.serializer.impl.Serializer.serialize(Serializer.java:130)
	at org.eclipse.xtext.resource.XtextResource.doSave(XtextResource.java:330)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:1417)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(ResourceImpl.java:986)
	at org.obeonetwork.dsl.viewpoint.xtext.support.XtextEmbeddedEditor.saveVceXToMainFile(XtextEmbeddedEditor.java:354)
	at org.obeonetwork.dsl.viewpoint.xtext.support.XtextEmbeddedEditor.closeEditor(XtextEmbeddedEditor.java:296)
	at org.obeonetwork.dsl.viewpoint.xtext.support.XtextEmbeddedEditor$5.keyPressed(XtextEmbeddedEditor.java:592)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:167)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1300)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1285)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1312)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:748)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3050)
	at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:741)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1773)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5116)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4377)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8317)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1193)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2342)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3184)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)


In all other cases everything works fine.
If anyone has any idea of how to solve my issue, I will be very thankful.

Best regards,
Mary
Re: No EObjectDescription could be found in Scope when saving a model [message #1396432 is a reply to message #1395779] Tue, 08 July 2014 09:32 Go to previous message
Mary P. is currently offline Mary P.Friend
Messages: 48
Registered: November 2012
Member
I found a solution.
When I saved my model containing a reference to an Operation, Xtext executed getLocalElementsByEObject(EObject input, final URI uri) method of AbstractScope in order to find the corresponding Operation in my project. Here is its code:

protected Iterable<IEObjectDescription> getLocalElementsByEObject(final EObject object, final URI uri) {
		Iterable<IEObjectDescription> localElements = getAllLocalElements();
		Iterable<IEObjectDescription> result = Iterables.filter(localElements, new Predicate<IEObjectDescription>() {
			public boolean apply(IEObjectDescription input) {
				if (input.getEObjectOrProxy() == object)
					return canBeFoundByName(input);
				if (uri.equals(input.getEObjectURI())) {
					return canBeFoundByName(input);
				}
				return false;
			}
			
			public boolean canBeFoundByName(IEObjectDescription input) {
				IEObjectDescription lookUp = getSingleLocalElementByName(input.getName());
				if (lookUp != null) {
					if (lookUp == input)
						return true;
					if (lookUp.getEObjectOrProxy() == object)
						return true;
					if (uri.equals(lookUp.getEObjectURI()))
						return true;
				}
				return false;
			}
		});
		return result;
	}



My problem was that getSingleLocalElementByName(String name) operation returns the FIRST object from the collection of the local objects with the given name, even if the collection contains more than one object. Then, "lookUp == input" expression will will be evaluated to "false", if "input" was not the first object in the collection, even if it was in the collection.

I implemented my own Scope and overorde getLocalElementsByEObject(EObject input, final URI uri) in the following way:


@Override
	protected Iterable<IEObjectDescription> getLocalElementsByEObject(final EObject object, final URI uri) {
		Iterable<IEObjectDescription> localElements = getAllLocalElements();
		Iterable<IEObjectDescription> result = Iterables.filter(localElements, new Predicate<IEObjectDescription>() {
			public boolean apply(IEObjectDescription input) {
				if (input.getEObjectOrProxy() == object)
					return canBeFoundByName(input);
				if (uri.equals(input.getEObjectURI())) {
					return canBeFoundByName(input);
				}
				return false;
			}
			
			public boolean canBeFoundByName(IEObjectDescription input) {
				
				Iterable<IEObjectDescription> result = getLocalElementsByName(input.getName());
				Iterator<IEObjectDescription> iterator = result.iterator();
				for (IEObjectDescription cur : result) {
					if(cur == input)
						return true;
					else if(cur.getEObjectOrProxy() == object)
						return true;
					else if(uri.equals(cur.getEObjectURI()))
						return true;
				}			
				return false;
			}
		});
		return result;
	}



So, that now it checks for all the objects with the same name as input, but not only for the first one.

But I guess, there should be some easier solution, and I will be very thankful if someone could share it with me.
Previous Topic:Serializing partial model
Next Topic:XtextResource.save() containing strings with carriage return
Goto Forum:
  


Current Time: Wed Dec 11 16:27:39 GMT 2019

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

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

Back to the top