Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » createInjectorAndDoEMFRegistration Vs Guice.createInjector
createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1400707] Mon, 14 July 2014 15:58 Go to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
Hi,
I was trying to serialize my model using a resource that i get by using this injector:
Injector injector = new MDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
bu i got this error Quote:
java.lang.IllegalStateException: Passed org.eclipse.xtext.builder.clustering.CurrentDescriptions not of type org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions


So i found latter that i must use this injector instead
Injector injector = Guice.createInjector(new MDSLRuntimeModule())


The problem that i have by using this is that the top node of my resource is now
Quote:
MMC.impl.PackagesImpl@1ec16bfb (name: racine)
instead of Quote:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@51103d14 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@5c33a5f5 (name: Packages) (instanceClassName: null) (abstract: false, interface: false))


Is there a way to get back the dynamicEobject by using the guice injector?

Thanks in advance
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1400721 is a reply to message #1400707] Mon, 14 July 2014 16:15 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
new MDSLStandaloneSetup().createInjectorAndDoEMFRegistration(); should dio the very same.
sure you dont have any strange customizations there?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1400738 is a reply to message #1400721] Mon, 14 July 2014 16:47 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
Yes im sure
                Injector injector = Guice.createInjector(new M2CDSLRuntimeModule());
	       //Injector injector = new M2CDSLStandaloneSetup().createInjectorAndDoEMFRegistration();
		XtextResourceSet resourceSet = injector.getInstance(XtextResourceSet.class);
		resourceSet.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		 resource = resourceSet.getResource(
		//URI.createURI("platform:/resource/POCModel_v2/model/rr.m2c"), true);
		URI.createURI("platform:/resource/"+racine+"/"+fileName), true);
		 EcoreUtil.resolveAll(resource);
		modelRoot =  resource.getContents().get(0);


My modelRoot is different depending only on what injector i use. Isnt there an alternative solution like for exemple to convert the packageImpl to dynamicEObject
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1400748 is a reply to message #1400738] Mon, 14 July 2014 17:01 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Here is what xxxdslStandalonesetup does:

	public Injector createInjectorAndDoEMFRegistration() {
		org.eclipse.xtext.common.TerminalsStandaloneSetup.doSetup();

		Injector injector = createInjector();
		register(injector);
		return injector;
	}
	
	public Injector createInjector() {
		return Guice.createInjector(new org.xtext.example.mydsl.MyDslRuntimeModule());
	}


there is no difference

are you sure you did not touch xxxdslStandalonesetup???

and what is the difference in the model????
and where do you call the code.

can you share a grammar + a unit test reproducing the problem?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1400784 is a reply to message #1400748] Mon, 14 July 2014 18:08 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
Its the same implementation, i really dont understand why i got this in my debug.
https://www.dropbox.com/s/dy0l3esb85onf1v/Injector%20debug.jpg
Here is my grammar and the resource i try to load
https://www.dropbox.com/sh/91d5qmf0ycblv13/AAD9niHwUjXt_zL3172mdenYa
Thanks a lot Christian,
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1400787 is a reply to message #1400784] Mon, 14 July 2014 18:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
very strange.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1401009 is a reply to message #1400787] Tue, 15 July 2014 02:25 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
Thinks Christian, i'm glad I did not do something stupid. So i think that i will just keep using the createInjectorAndDoEMFRegistration(). In this case is there a way to solve the first issue related resource serialization
[Worker-3] ERROR org.eclipse.xtext.buil der.impl.XtextBuilder  - Passed org.eclipse.xtext.builder.clustering.CurrentDescriptions is not based on a resource set
java.lang.IllegalStateException: Passed org.eclipse.xtext.builder.clustering.CurrentDescriptions is not based on a resource set


May i ask another question plz. Sometimes i got this error even if in my grammar the gathersC has 0..* multiplicity

org.eclipse.xtext.validation.IConcreteSyntaxValidator$InvalidConcreteSyntaxException: These errors need to be fixed before the model can be serialized.
Packages: Feature Packages.name must be set.
Packages: Feature Packages.gathersC holds 0 non-transient value(s), but at least 1 are required.

[Updated on: Tue, 15 July 2014 02:31]

Report message to a moderator

Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1401088 is a reply to message #1401009] Tue, 15 July 2014 05:34 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

sorry i have no idea what you are actually doing in your code. XtextBuilder is for IDE so i wonder it is mentioned in an environment where you use standalonesetup which should never never never ever be used in eclipse


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 15 July 2014 05:34]

Report message to a moderator

Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1401241 is a reply to message #1401088] Tue, 15 July 2014 10:35 Go to previous messageGo to next message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
I will dig deeper. Thanks a lot Christian
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1401244 is a reply to message #1401241] Tue, 15 July 2014 10:36 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
so pßlease answer: from where are you calling this code?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: createInjectorAndDoEMFRegistration Vs Guice.createInjector [message #1401731 is a reply to message #1401244] Wed, 16 July 2014 02:51 Go to previous message
Elhamlaoui Mahmoud is currently offline Elhamlaoui MahmoudFriend
Messages: 268
Registered: March 2010
Senior Member
I solved the problem. In fact you previous question is the hint. I had two projects one with the xtext nature and another without. In the runtime i was calling the resource by using methods from first projects and apply the save in the second project. I merged the two projects and the problem appears to be solved. Thanks chritian
Previous Topic:Integer-based qualified IDs
Next Topic:[Xtext] managing large numbers of rules
Goto Forum:
  


Current Time: Fri Mar 29 11:42:07 GMT 2024

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

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

Back to the top