diff options
author | 2020-04-28 20:43:04 +0200 | |
---|---|---|
committer | 2020-04-28 20:43:04 +0200 | |
commit | 8a7b9b436b31e6d2f5a0521a077c960ebdeb4cbe (patch) | |
tree | d525bef75519f364d637e0779f8e63d4199dee31 /Application/org.eclipse.viatra.solver.language.tests/src-gen | |
parent | check expressions are mapped to WF constraints (diff) | |
download | VIATRA-Generator-8a7b9b436b31e6d2f5a0521a077c960ebdeb4cbe.tar.gz VIATRA-Generator-8a7b9b436b31e6d2f5a0521a077c960ebdeb4cbe.tar.zst VIATRA-Generator-8a7b9b436b31e6d2f5a0521a077c960ebdeb4cbe.zip |
initial commit
Diffstat (limited to 'Application/org.eclipse.viatra.solver.language.tests/src-gen')
-rw-r--r-- | Application/org.eclipse.viatra.solver.language.tests/src-gen/org/eclipse/viatra/solver/language/tests/SolverLanguageInjectorProvider.java | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/Application/org.eclipse.viatra.solver.language.tests/src-gen/org/eclipse/viatra/solver/language/tests/SolverLanguageInjectorProvider.java b/Application/org.eclipse.viatra.solver.language.tests/src-gen/org/eclipse/viatra/solver/language/tests/SolverLanguageInjectorProvider.java new file mode 100644 index 00000000..f6f7cc26 --- /dev/null +++ b/Application/org.eclipse.viatra.solver.language.tests/src-gen/org/eclipse/viatra/solver/language/tests/SolverLanguageInjectorProvider.java | |||
@@ -0,0 +1,69 @@ | |||
1 | /* | ||
2 | * generated by Xtext 2.18.0.M3 | ||
3 | */ | ||
4 | package org.eclipse.viatra.solver.language.tests; | ||
5 | |||
6 | import com.google.inject.Guice; | ||
7 | import com.google.inject.Injector; | ||
8 | import org.eclipse.viatra.solver.language.SolverLanguageRuntimeModule; | ||
9 | import org.eclipse.viatra.solver.language.SolverLanguageStandaloneSetup; | ||
10 | import org.eclipse.xtext.testing.GlobalRegistries; | ||
11 | import org.eclipse.xtext.testing.GlobalRegistries.GlobalStateMemento; | ||
12 | import org.eclipse.xtext.testing.IInjectorProvider; | ||
13 | import org.eclipse.xtext.testing.IRegistryConfigurator; | ||
14 | |||
15 | public class SolverLanguageInjectorProvider implements IInjectorProvider, IRegistryConfigurator { | ||
16 | |||
17 | protected GlobalStateMemento stateBeforeInjectorCreation; | ||
18 | protected GlobalStateMemento stateAfterInjectorCreation; | ||
19 | protected Injector injector; | ||
20 | |||
21 | static { | ||
22 | GlobalRegistries.initializeDefaults(); | ||
23 | } | ||
24 | |||
25 | @Override | ||
26 | public Injector getInjector() { | ||
27 | if (injector == null) { | ||
28 | this.injector = internalCreateInjector(); | ||
29 | stateAfterInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); | ||
30 | } | ||
31 | return injector; | ||
32 | } | ||
33 | |||
34 | protected Injector internalCreateInjector() { | ||
35 | return new SolverLanguageStandaloneSetup() { | ||
36 | @Override | ||
37 | public Injector createInjector() { | ||
38 | return Guice.createInjector(createRuntimeModule()); | ||
39 | } | ||
40 | }.createInjectorAndDoEMFRegistration(); | ||
41 | } | ||
42 | |||
43 | protected SolverLanguageRuntimeModule createRuntimeModule() { | ||
44 | // make it work also with Maven/Tycho and OSGI | ||
45 | // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=493672 | ||
46 | return new SolverLanguageRuntimeModule() { | ||
47 | @Override | ||
48 | public ClassLoader bindClassLoaderToInstance() { | ||
49 | return SolverLanguageInjectorProvider.class | ||
50 | .getClassLoader(); | ||
51 | } | ||
52 | }; | ||
53 | } | ||
54 | |||
55 | @Override | ||
56 | public void restoreRegistry() { | ||
57 | stateBeforeInjectorCreation.restoreGlobalState(); | ||
58 | stateBeforeInjectorCreation = null; | ||
59 | } | ||
60 | |||
61 | @Override | ||
62 | public void setupRegistry() { | ||
63 | stateBeforeInjectorCreation = GlobalRegistries.makeCopyOfGlobalState(); | ||
64 | if (injector == null) { | ||
65 | getInjector(); | ||
66 | } | ||
67 | stateAfterInjectorCreation.restoreGlobalState(); | ||
68 | } | ||
69 | } | ||