blob: e9d889c46c9535b1f2d3b37a2f461fba1815e0a1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.language.web.tests;
import org.eclipse.xtext.ide.ExecutorServiceProvider;
import org.eclipse.xtext.util.DisposableRegistry;
import org.eclipse.xtext.util.Modules2;
import com.google.inject.Guice;
import com.google.inject.Injector;
import tools.refinery.language.ide.ProblemIdeModule;
import tools.refinery.language.tests.ProblemInjectorProvider;
import tools.refinery.language.web.ProblemWebModule;
import tools.refinery.language.web.ProblemWebSetup;
public class ProblemWebInjectorProvider extends ProblemInjectorProvider {
protected Injector internalCreateInjector() {
return new ProblemWebSetup() {
@Override
public Injector createInjector() {
return Guice.createInjector(
Modules2.mixin(createRuntimeModule(), new ProblemIdeModule(), createWebModule()));
}
}.createInjectorAndDoEMFRegistration();
}
protected ProblemWebModule createWebModule() {
// Await termination of the executor service to avoid race conditions between
// the tasks in the service and the {@link
// org.eclipse.xtext.testing.extensions.InjectionExtension}.
return new ProblemWebModule() {
@Override
@SuppressWarnings("unused")
public Class<? extends ExecutorServiceProvider> bindExecutorServiceProvider() {
return AwaitTerminationExecutorServiceProvider.class;
}
};
}
@Override
public void restoreRegistry() {
// Also make sure to dispose any IDisposable instances (that may depend on the
// global state) created by Xtext before restoring the global state.
var disposableRegistry = getInjector().getInstance(DisposableRegistry.class);
disposableRegistry.dispose();
super.restoreRegistry();
}
}
|