Using the EMF classes and from a new plugin [message #48536] |
Fri, 05 June 2009 11:06  |
Eclipse User |
|
|
|
I am trying to use the EMF classes generated from xtext to save the file to
the text format, but when I save the file it saves as xml. I am not using
the editor plugin that is generated, but instead another hello world plugin
that includes the plugin that has the generated xtext emf model. I must be
missing something simple (some google juice hook maybe).
Here is the code I use to create and save the file.
XtextResourceSet rsrcSet = new XtextResourceSet();
URI uri = URI.createFileURI(file.getAbsolutePath()+".tmp");
Resource theConnRes = rsrcSet.createResource(uri);
ParseStatementsList sl =
Package.eINSTANCE.getFactory().createParseStatementsList();
TerminatedStatement sc =
Package.eINSTANCE.getFactory().createTerminatedStatement();
sl.getStatements().add(sc);
theConnRes.getContents().add(sl);
theConnRes.save(rsrcSet.getURIResourceMap());
|
|
|
|
|
Re: Using the EMF classes and from a new plugin [message #48688 is a reply to message #48601] |
Fri, 05 June 2009 11:45  |
Eclipse User |
|
|
|
Hi Drew,
please find my comment below.
Am 05.06.2009 17:30 Uhr, schrieb drew:
> Got around this by.
>
> a)using the correct file extension for the file.
nice :-)
> b)including the ui text editor generated plugin.
Please have a look at the plugin.xml of your editor plugin and find a
secion <!-- Resource factories -->.
If you want to use your resource without the ui plugin, you'll have to
come up with something similar in your runtime plugin.
Regards,
Sebastian
> Seems odd that I need the UI plugin, but it works for now.
>
> "drew"<drew@acm.org> wrote in message
> news:h0bc98$8ai$1@build.eclipse.org...
>> I am trying to use the EMF classes generated from xtext to save the file to
>> the text format, but when I save the file it saves as xml. I am not using
>> the editor plugin that is generated, but instead another hello world plugin
>> that includes the plugin that has the generated xtext emf model. I must be
>> missing something simple (some google juice hook maybe).
>>
>> Here is the code I use to create and save the file.
>> XtextResourceSet rsrcSet = new XtextResourceSet();
>> URI uri = URI.createFileURI(file.getAbsolutePath()+".tmp");
>>
>> Resource theConnRes = rsrcSet.createResource(uri);
>> ParseStatementsList sl =
>> Package.eINSTANCE.getFactory().createParseStatementsList();
>> TerminatedStatement sc =
>> Package.eINSTANCE.getFactory().createTerminatedStatement();
>>
>> sl.getStatements().add(sc);
>> theConnRes.getContents().add(sl);
>> theConnRes.save(rsrcSet.getURIResourceMap());
>>
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.24883 seconds