diff options
Diffstat (limited to 'Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.language.ui/src-gen/ca/mcgill/ecse/dslreasoner/vampire/language/ui/internal/LanguageActivator.java')
-rw-r--r-- | Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.language.ui/src-gen/ca/mcgill/ecse/dslreasoner/vampire/language/ui/internal/LanguageActivator.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.language.ui/src-gen/ca/mcgill/ecse/dslreasoner/vampire/language/ui/internal/LanguageActivator.java b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.language.ui/src-gen/ca/mcgill/ecse/dslreasoner/vampire/language/ui/internal/LanguageActivator.java new file mode 100644 index 00000000..b25ea8a3 --- /dev/null +++ b/Solvers/Vampire-Solver/ca.mcgill.ecse.dslreasoner.vampire.language.ui/src-gen/ca/mcgill/ecse/dslreasoner/vampire/language/ui/internal/LanguageActivator.java | |||
@@ -0,0 +1,94 @@ | |||
1 | /* | ||
2 | * generated by Xtext 2.14.0 | ||
3 | */ | ||
4 | package ca.mcgill.ecse.dslreasoner.vampire.language.ui.internal; | ||
5 | |||
6 | import ca.mcgill.ecse.dslreasoner.VampireLanguageRuntimeModule; | ||
7 | import ca.mcgill.ecse.dslreasoner.ui.VampireLanguageUiModule; | ||
8 | import com.google.common.collect.Maps; | ||
9 | import com.google.inject.Guice; | ||
10 | import com.google.inject.Injector; | ||
11 | import java.util.Collections; | ||
12 | import java.util.Map; | ||
13 | import org.apache.log4j.Logger; | ||
14 | import org.eclipse.ui.plugin.AbstractUIPlugin; | ||
15 | import org.eclipse.xtext.ui.shared.SharedStateModule; | ||
16 | import org.eclipse.xtext.util.Modules2; | ||
17 | import org.osgi.framework.BundleContext; | ||
18 | |||
19 | /** | ||
20 | * This class was generated. Customizations should only happen in a newly | ||
21 | * introduced subclass. | ||
22 | */ | ||
23 | public class LanguageActivator extends AbstractUIPlugin { | ||
24 | |||
25 | public static final String PLUGIN_ID = "ca.mcgill.ecse.dslreasoner.vampire.language.ui"; | ||
26 | public static final String CA_MCGILL_ECSE_DSLREASONER_VAMPIRELANGUAGE = "ca.mcgill.ecse.dslreasoner.VampireLanguage"; | ||
27 | |||
28 | private static final Logger logger = Logger.getLogger(LanguageActivator.class); | ||
29 | |||
30 | private static LanguageActivator INSTANCE; | ||
31 | |||
32 | private Map<String, Injector> injectors = Collections.synchronizedMap(Maps.<String, Injector> newHashMapWithExpectedSize(1)); | ||
33 | |||
34 | @Override | ||
35 | public void start(BundleContext context) throws Exception { | ||
36 | super.start(context); | ||
37 | INSTANCE = this; | ||
38 | } | ||
39 | |||
40 | @Override | ||
41 | public void stop(BundleContext context) throws Exception { | ||
42 | injectors.clear(); | ||
43 | INSTANCE = null; | ||
44 | super.stop(context); | ||
45 | } | ||
46 | |||
47 | public static LanguageActivator getInstance() { | ||
48 | return INSTANCE; | ||
49 | } | ||
50 | |||
51 | public Injector getInjector(String language) { | ||
52 | synchronized (injectors) { | ||
53 | Injector injector = injectors.get(language); | ||
54 | if (injector == null) { | ||
55 | injectors.put(language, injector = createInjector(language)); | ||
56 | } | ||
57 | return injector; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | protected Injector createInjector(String language) { | ||
62 | try { | ||
63 | com.google.inject.Module runtimeModule = getRuntimeModule(language); | ||
64 | com.google.inject.Module sharedStateModule = getSharedStateModule(); | ||
65 | com.google.inject.Module uiModule = getUiModule(language); | ||
66 | com.google.inject.Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule); | ||
67 | return Guice.createInjector(mergedModule); | ||
68 | } catch (Exception e) { | ||
69 | logger.error("Failed to create injector for " + language); | ||
70 | logger.error(e.getMessage(), e); | ||
71 | throw new RuntimeException("Failed to create injector for " + language, e); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | protected com.google.inject.Module getRuntimeModule(String grammar) { | ||
76 | if (CA_MCGILL_ECSE_DSLREASONER_VAMPIRELANGUAGE.equals(grammar)) { | ||
77 | return new VampireLanguageRuntimeModule(); | ||
78 | } | ||
79 | throw new IllegalArgumentException(grammar); | ||
80 | } | ||
81 | |||
82 | protected com.google.inject.Module getUiModule(String grammar) { | ||
83 | if (CA_MCGILL_ECSE_DSLREASONER_VAMPIRELANGUAGE.equals(grammar)) { | ||
84 | return new VampireLanguageUiModule(this); | ||
85 | } | ||
86 | throw new IllegalArgumentException(grammar); | ||
87 | } | ||
88 | |||
89 | protected com.google.inject.Module getSharedStateModule() { | ||
90 | return new SharedStateModule(); | ||
91 | } | ||
92 | |||
93 | |||
94 | } | ||