|Re: Opening Xbase-using Xtext models programmatically [message #778126 is a reply to message #777743]
||Wed, 11 January 2012 12:54
| Sebastian Zarnekow
Registered: July 2009
please make sure that your resource set was configured properly, e.g. by
using the IResourceSetProvider
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 11.01.12 01:07, schrieb Zoltan Ujhelyi:
> 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:
> 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,
|Re: Opening Xbase-using Xtext models programmatically [message #778217 is a reply to message #778126]
||Wed, 11 January 2012 18:23
| Zoltan Ujhelyi
Registered: July 2015
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()
if (file == null)
ResourceSet resourceSet = injector.getInstance(ResourceSet.class);
URI fileURI = URI.createPlatformResourceURI(file.getFullPath()
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,
Powered by FUDForum
. Page generated in 0.02227 seconds