|
Re: Opening Xbase-using Xtext models programmatically [message #778126 is a reply to message #777743] |
Wed, 11 January 2012 12:54 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Zoltan,
please make sure that your resource set was configured properly, e.g. by
using the IResourceSetProvider
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 11.01.12 01:07, schrieb Zoltan Ujhelyi:
> Hi,
>
> we are creating an Xbase-using DSL that we would like to open outside
> the builder. However, opening the file using the traditional EMF
> Resource API results in a "java.net.MalformedURLException: unknown
> protocol: java" exception. I also tried to open the model using the
> Sample Reflective Editor (as suggested in the Xtext FAQ:
> http://wiki.eclipse.org/Xtext/FAQ#How_can_I_load_my_model_in_the_EMF_reflective_model_editor.C2.A0.3F),
> with similar results.
>
> The exception is thrown, when my model inferrer tries to ask for the
> JVMType of a Java class. The code generator works as expected, it finds
> the referenced type and the generated class looks as expected.
>
> I could reproduce the same issue using the domain model example as well
> (without any modification).
>
> My question is how to open an Xbase-using DSL both programmatically
> (e.g. what needs to be registered for the Java type resolving to work)
> and also in the Sample Reflective Editor (if possible).
>
> Thank you for your help,
> Zoltan
|
|
|
Re: Opening Xbase-using Xtext models programmatically [message #778217 is a reply to message #778126] |
Wed, 11 January 2012 18:23 |
Zoltan Ujhelyi Messages: 392 Registered: July 2015 |
Senior Member |
|
|
Hi Sebastian,
thanks for your quick answer. Using IResourceSetProvider I managed to open the model; however, the resulting code depends on UI projects (the interface itself is defined in the org.eclipse.xtext.ui project).
For our usage this is not the best direction, we also want to use the parser in a headless environment, but with Eclipse plug-ins available (so e.g. EMF packages are registered using activators; eclipse extensions are available).
Following the direction I initialized a standalone setup, and then asked for the corresponding resource set using the following code:
Injector injector = new EMFPatternLanguageStandaloneSetup()
.createInjectorAndDoEMFRegistration();
if (file == null)
return null;
ResourceSet resourceSet = injector.getInstance(ResourceSet.class);
URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
.toString(), false);
Resource resource = resourceSet.getResource(fileURI, true);
My question would be whether this shall work in all cases, or this setup might cause some issues in the future (e.g. is it any problem that the createInjectorAndDoEMFRegistration method are called multiple times?
Thank you again,
Zoltán Ujhelyi
|
|
|
|
Powered by
FUDForum. Page generated in 0.03518 seconds