| /******************************************************************************* |
| * Copyright (c) 2011, 2021 Willink Transformations and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * E.D.Willink - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ocl.examples.xtext.idioms; |
| |
| import com.google.inject.Guice; |
| import com.google.inject.Injector; |
| import org.eclipse.emf.ecore.EPackage; |
| import org.eclipse.emf.ecore.resource.Resource; |
| import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; |
| import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; |
| import org.eclipse.xtext.ISetup; |
| import org.eclipse.xtext.XtextPackage; |
| import org.eclipse.xtext.resource.IResourceFactory; |
| import org.eclipse.xtext.resource.IResourceServiceProvider; |
| import org.eclipse.xtext.resource.impl.BinaryGrammarResourceFactoryImpl; |
| |
| @SuppressWarnings("all") |
| public class IdiomsStandaloneSetupGenerated implements ISetup { |
| |
| @Override |
| public Injector createInjectorAndDoEMFRegistration() { |
| // register default ePackages |
| if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("ecore")) |
| Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( |
| "ecore", new EcoreResourceFactoryImpl()); |
| if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xmi")) |
| Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( |
| "xmi", new XMIResourceFactoryImpl()); |
| if (!Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("xtextbin")) |
| Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put( |
| "xtextbin", new BinaryGrammarResourceFactoryImpl()); |
| if (!EPackage.Registry.INSTANCE.containsKey(XtextPackage.eNS_URI)) |
| EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, XtextPackage.eINSTANCE); |
| |
| Injector injector = createInjector(); |
| register(injector); |
| return injector; |
| } |
| |
| public Injector createInjector() { |
| return Guice.createInjector(new IdiomsRuntimeModule()); |
| } |
| |
| public void register(Injector injector) { |
| IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class); |
| IResourceServiceProvider serviceProvider = injector.getInstance(IResourceServiceProvider.class); |
| |
| Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("idioms", resourceFactory); |
| IResourceServiceProvider.Registry.INSTANCE.getExtensionToFactoryMap().put("idioms", serviceProvider); |
| } |
| } |