Skip to main content



      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 04:56 Go to next message
Eclipse UserFriend
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 06:48 Go to previous messageGo to next message
Eclipse UserFriend
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 06:51 Go to previous messageGo to next message
Eclipse UserFriend
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 06:56 Go to previous messageGo to next message
Eclipse UserFriend
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 07:18 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 15:35:05 EDT 2025

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

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

Back to the top