Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » While Parsing the xtext models,Getting Resource factory needed(When trying to parse the xtext models I was getting resource factory not found...I am not sure about the problem correctly why it is happening.)
While Parsing the xtext models,Getting Resource factory needed [message #1216053] Thu, 28 November 2013 09:56 Go to next message
raju ak is currently offline raju ak
Messages: 10
Registered: October 2013
Junior Member
I am started working on xtext, I have created some DSL grammer and Generated the artifacts,After that i ran that as eclipse application and created the sample.dmodel (example), In the editor i have added some langauge realted stuff which grammer accepts.

problem:
once the dmodel is created i need to read that particular file and get the contents from them..I have tried using loading the Resource concept. but it is not working.. I am getting resource factory is needed.

new DomainModelStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = new ResourceSetImpl();

Resource resource = rs.getResource(URI.createURI("C:\\Users\\runtime-EclipseXtext\\sampleprj\\src\\mymodel.dmodel"), true);


DomainModel model = (DomainModel) resource.getContents().get(0);
System.out.println(model.getElements().size());

can you guys please help me how to do it.
Re: While Parsing the xtext models,Getting Resource factory needed [message #1216264 is a reply to message #1216053] Thu, 28 November 2013 11:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6302
Registered: July 2009
Senior Member
Never call standalonesetup from eclipse
http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html

how/from where do you try to read the model?
Re: While Parsing the xtext models,Getting Resource factory needed [message #1218708 is a reply to message #1216264] Fri, 29 November 2013 11:51 Go to previous messageGo to next message
raju ak is currently offline raju ak
Messages: 10
Registered: October 2013
Junior Member
Hi Christian Dietrich

Thanks for your Response...From your response i need to use google juice injector. But in the xtext document to load the model they are doing from the dosetup method inside the StandloneSetup. when iam trying to load resource i was getting resource factory needed. And more over iam not very sure how to use google injector. if you have any sample code..please help me out,
Thanks in advance.
Re: While Parsing the xtext models,Getting Resource factory needed [message #1218709 is a reply to message #1218708] Fri, 29 November 2013 11:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6302
Registered: July 2009
Senior Member
Hi,

i still do not know in what context do you want to execute this code. can you please elaborate
Re: While Parsing the xtext models,Getting Resource factory needed [message #1218754 is a reply to message #1218709] Fri, 29 November 2013 12:18 Go to previous message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6302
Registered: July 2009
Senior Member
P.S: if you execute this from a java main the following will work

Injector i = new DomainmodelStandaloneSetup().createInjectorAndDoEMFRegistration();
ResourceSet rs = i.getInstance(ResourceSet.class);
Resource r = rs.getResource(URI.createURI("model/test.dmodel"), true);
r.load(null);
System.out.println(r.getContents().get(0));
Previous Topic:Formatter on files with different line-endings
Next Topic:Two DSLs in one Eclipse project, only one is active
Goto Forum:
  


Current Time: Thu Sep 18 21:59:11 GMT 2014

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

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