From 25a4b1b53add70e268c3083682f8a3508c618ec2 Mon Sep 17 00:00:00 2001 From: ArenBabikian Date: Fri, 25 Oct 2019 04:15:39 -0400 Subject: VAMPIRE: post-submission push --- .../ui/internal/AlloyLanguageActivator.java | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 Solvers/Alloy-Solver2/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java (limited to 'Solvers/Alloy-Solver2/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal') diff --git a/Solvers/Alloy-Solver2/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java b/Solvers/Alloy-Solver2/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java new file mode 100644 index 00000000..5eab6f1f --- /dev/null +++ b/Solvers/Alloy-Solver2/hu.bme.mit.inf.dslreasoner.alloy.language.ui/src-gen/hu/bme/mit/inf/dslreasoner/ui/internal/AlloyLanguageActivator.java @@ -0,0 +1,95 @@ +/* + * generated by Xtext + */ +package hu.bme.mit.inf.dslreasoner.ui.internal; + +import java.util.Collections; +import java.util.Map; + +import org.apache.log4j.Logger; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.eclipse.xtext.ui.shared.SharedStateModule; +import org.eclipse.xtext.util.Modules2; +import org.osgi.framework.BundleContext; + +import com.google.common.collect.Maps; +import com.google.inject.Guice; +import com.google.inject.Injector; +import com.google.inject.Module; + +/** + * This class was generated. Customizations should only happen in a newly + * introduced subclass. + */ +public class AlloyLanguageActivator extends AbstractUIPlugin { + + public static final String HU_BME_MIT_INF_DSLREASONER_ALLOYLANGUAGE = "hu.bme.mit.inf.dslreasoner.AlloyLanguage"; + + private static final Logger logger = Logger.getLogger(AlloyLanguageActivator.class); + + private static AlloyLanguageActivator INSTANCE; + + private Map injectors = Collections.synchronizedMap(Maps. newHashMapWithExpectedSize(1)); + + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + INSTANCE = this; + } + + @Override + public void stop(BundleContext context) throws Exception { + injectors.clear(); + INSTANCE = null; + super.stop(context); + } + + public static AlloyLanguageActivator getInstance() { + return INSTANCE; + } + + public Injector getInjector(String language) { + synchronized (injectors) { + Injector injector = injectors.get(language); + if (injector == null) { + injectors.put(language, injector = createInjector(language)); + } + return injector; + } + } + + protected Injector createInjector(String language) { + try { + Module runtimeModule = getRuntimeModule(language); + Module sharedStateModule = getSharedStateModule(); + Module uiModule = getUiModule(language); + Module mergedModule = Modules2.mixin(runtimeModule, sharedStateModule, uiModule); + return Guice.createInjector(mergedModule); + } catch (Exception e) { + logger.error("Failed to create injector for " + language); + logger.error(e.getMessage(), e); + throw new RuntimeException("Failed to create injector for " + language, e); + } + } + + protected Module getRuntimeModule(String grammar) { + if (HU_BME_MIT_INF_DSLREASONER_ALLOYLANGUAGE.equals(grammar)) { + return new hu.bme.mit.inf.dslreasoner.AlloyLanguageRuntimeModule(); + } + + throw new IllegalArgumentException(grammar); + } + + protected Module getUiModule(String grammar) { + if (HU_BME_MIT_INF_DSLREASONER_ALLOYLANGUAGE.equals(grammar)) { + return new hu.bme.mit.inf.dslreasoner.ui.AlloyLanguageUiModule(this); + } + + throw new IllegalArgumentException(grammar); + } + + protected Module getSharedStateModule() { + return new SharedStateModule(); + } + +} -- cgit v1.2.3-54-g00ecf