Search code examples
eclipse-rcpdslxtext

Use ResourceSet within another Plugin


I use a xtext generated DSL in my project. I now want to generate some files with a wizard. I can currently create these files just by adding some strings to the file. But initially i wanted to create a Model Object of the DSL and add the new generated file to the resource set. I can't find a way accessing this without the StandaloneSetup of the DSL. I'm now unsure if the use of the StandaloneSetup inside the Editor is the correct way, since it seems there should be a better way to access the already build up resource set used by the xtext framework to manage the already known files/sources. If i use the StandaloneSetup shouldn't there be 2 Injectors which could get really bad?


Solution

  • you can use the resource service provider registry to obtain the injector

    http://koehnlein.blogspot.de/2012/11/xtext-tip-how-do-i-get-guice-injector.html

    URI fakeOrRealUri = ...;
    IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(fakeOrRealUri).get()