From 62c89e585d94b51eae4cbaa3abd795b9a79ae69c Mon Sep 17 00:00:00 2001 From: Thomas Degueule Date: Wed, 26 Aug 2015 00:40:03 +0200 Subject: [PATCH] Back to ModelUtils for EPackageProvider --- .../melange/utils/EPackageProvider.xtend | 38 ++----------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/plugins/fr.inria.diverse.melange/src/main/java/fr/inria/diverse/melange/utils/EPackageProvider.xtend b/plugins/fr.inria.diverse.melange/src/main/java/fr/inria/diverse/melange/utils/EPackageProvider.xtend index db1e51fe9..31688b371 100644 --- a/plugins/fr.inria.diverse.melange/src/main/java/fr/inria/diverse/melange/utils/EPackageProvider.xtend +++ b/plugins/fr.inria.diverse.melange/src/main/java/fr/inria/diverse/melange/utils/EPackageProvider.xtend @@ -8,24 +8,21 @@ import fr.inria.diverse.melange.ast.LanguageExtensions import fr.inria.diverse.melange.ast.ModelTypeExtensions import fr.inria.diverse.melange.eclipse.EclipseProjectHelper import fr.inria.diverse.melange.lib.EcoreExtensions +import fr.inria.diverse.melange.lib.ModelUtils import fr.inria.diverse.melange.metamodel.melange.Inheritance import fr.inria.diverse.melange.metamodel.melange.Metamodel import fr.inria.diverse.melange.metamodel.melange.ModelType import fr.inria.diverse.melange.metamodel.melange.ModelingElement import java.util.List -import org.apache.log4j.Logger import org.eclipse.emf.codegen.ecore.genmodel.GenModel -import org.eclipse.emf.common.util.URI import org.eclipse.emf.ecore.EPackage -import org.eclipse.emf.ecore.resource.ResourceSet -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl import org.eclipse.emf.ecore.util.EcoreUtil import org.eclipse.xtext.naming.IQualifiedNameProvider @Singleton class EPackageProvider { - ResourceSet rs = new ResourceSetImpl + @Inject ModelUtils modelUtils @Inject extension EcoreExtensions @Inject extension ModelTypeExtensions @Inject extension LanguageExtensions @@ -33,7 +30,6 @@ class EPackageProvider @Inject extension IQualifiedNameProvider private ListMultimap packages = ArrayListMultimap.create private ListMultimap genmodels = ArrayListMultimap.create - private final Logger log = Logger.getLogger(EPackageProvider) def void reset() { packages = ArrayListMultimap.create @@ -53,7 +49,7 @@ class EPackageProvider switch (m) { case m.ecoreUri !== null: { - val root = loadPkg(m.ecoreUri.toPlatformURI) + val root = modelUtils.loadPkg(m.ecoreUri.toPlatformURI) if (root !== null) { val pkgs = newArrayList @@ -109,7 +105,7 @@ class EPackageProvider mm.genmodelUris += mm.owningLanguage.externalGenmodelUri } mm.genmodelUris.forEach[ - val gm = loadGenmodel(it.toPlatformURI) + val gm = modelUtils.loadGenmodel(it.toPlatformURI) if (gm !== null) genmodels.put(mm.fqn, gm) @@ -143,32 +139,6 @@ class EPackageProvider return mt.fullyQualifiedName?.toString } - private def EPackage loadPkg(String path) { - try { - val uri = URI.createURI(path) - val pkg = rs.getResource(uri, true) - - return pkg.contents.head as EPackage - } catch (Exception e) { - log.error(e) - } - - return null - } - - private def GenModel loadGenmodel(String path) { - try { - val uri = URI.createURI(path) - val pkg = rs.getResource(uri, true) - - return pkg.contents.head as GenModel - } catch (Exception e) { - log.error(e) - } - - return null - } - private def String toPlatformURI(String uri) { return '''«IF uri.startsWith("/")»platform:/resource«ENDIF»«uri»''' }