mirror of
https://github.com/sigmasternchen/xtext-core
synced 2025-03-16 08:48:55 +00:00
493672: Junit4Fragment2
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672 Signed-off-by: Lorenzo Bettini <lorenzo.bettini@gmail.com>
This commit is contained in:
parent
d78a808933
commit
2b997fc251
1 changed files with 20 additions and 1 deletions
|
@ -96,6 +96,8 @@ class Junit4Fragment2 extends AbstractStubGeneratingFragment {
|
|||
val globalRegistries = new TypeReference("org.eclipse.xtext.junit4.GlobalRegistries")
|
||||
val globalStateMemento = new TypeReference("org.eclipse.xtext.junit4", "GlobalRegistries.GlobalStateMemento")
|
||||
val iRegistryConfigurator = new TypeReference("org.eclipse.xtext.junit4.IRegistryConfigurator")
|
||||
val classLoader = new TypeReference("java.lang.ClassLoader")
|
||||
val guice = new TypeReference("com.google.inject.Guice")
|
||||
file.content = '''
|
||||
public class «injectorProvider.simpleName» implements «iInjectorProvider», «iRegistryConfigurator» {
|
||||
|
||||
|
@ -118,7 +120,24 @@ class Junit4Fragment2 extends AbstractStubGeneratingFragment {
|
|||
}
|
||||
|
||||
protected «Injector» internalCreateInjector() {
|
||||
return new «grammar.runtimeSetup»().createInjectorAndDoEMFRegistration();
|
||||
return new «grammar.runtimeSetup»() {
|
||||
@Override
|
||||
public Injector createInjector() {
|
||||
return «guice».createInjector(createRuntimeModule());
|
||||
}
|
||||
}.createInjectorAndDoEMFRegistration();
|
||||
}
|
||||
|
||||
protected «grammar.runtimeModule» createRuntimeModule() {
|
||||
// make it work also with Maven/Tycho and OSGI
|
||||
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672
|
||||
return new «grammar.runtimeModule»() {
|
||||
@Override
|
||||
public «classLoader» bindClassLoaderToInstance() {
|
||||
return «injectorProvider.simpleName».class
|
||||
.getClassLoader();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue