1010 *******************************************************************************/
1111package fr.inria.diverse.trace.gemoc.generator
1212
13- import ecorext.Ecorext
1413import fr.inria.diverse.melange.metamodel.melange.Language
1514import fr.inria.diverse.melange.metamodel.melange.ModelTypingSpace
1615import fr.inria.diverse.melange.ui.internal.MelangeActivator
17- import fr.inria.diverse.trace.commons.EMFUtil
18- import java.util.Set
16+ import fr.inria.diverse.opsemanticsview.gen.OperationalSemanticsViewGenerator
17+ import java.io.IOException
18+ import opsemanticsview.OperationalSemanticsView
1919import org.eclipse.core.resources.IFile
20+ import org.eclipse.core.resources.IProject
21+ import org.eclipse.core.resources.IResource
22+ import org.eclipse.core.resources.ResourcesPlugin
23+ import org.eclipse.core.resources.WorkspaceJob
24+ import org.eclipse.core.runtime.CoreException
2025import org.eclipse.core.runtime.IProgressMonitor
26+ import org.eclipse.core.runtime.IStatus
27+ import org.eclipse.core.runtime.Platform
28+ import org.eclipse.core.runtime.Status
2129import org.eclipse.emf.common.util.URI
22- import org.eclipse.emf.ecore.EPackage
2330import org.eclipse.emf.ecore.resource.Resource
2431import org.eclipse.emf.ecore.resource.ResourceSet
25- import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
2632import org.eclipse.xtext.ui.resource.IResourceSetProvider
2733import org.gemoc.xdsmlframework.ide.ui.xdsml.wizards.MelangeXDSMLProjectHelper
28- import org.eclipse.core.runtime.Platform
29- import org.eclipse.core.resources.IProject
30- import org.eclipse.core.resources.ResourcesPlugin
31- import org.eclipse.core.resources.WorkspaceJob
32- import org.eclipse.core.runtime.IStatus
33- import org.eclipse.core.resources.IResource
34- import org.eclipse.core.runtime.Status
35- import org.eclipse.core.runtime.CoreException
36- import java.io.IOException
3734
3835/**
3936 * Plenty of ways to call the generator in an eclipse context.
@@ -61,37 +58,58 @@ class TraceAddonGeneratorIntegration {
6158 val ModelTypingSpace root = resource. getContents(). get(0 ) as ModelTypingSpace
6259 val Language selection = root. elements. filter(Language ). findFirst[name == selectedLanguage]
6360
64- // Get syntax
65- val ResourceSet rs = new ResourceSetImpl
66- val URI mmUri = URI . createURI(selection. syntax. ecoreUri)
67- // val URI mmUri = URI.createURI("platform:/resource/"+ root.name + "." + selection.name.toLowerCase + "/model/" + selection.name + ".ecore")
68- val Resource syntaxResource = EMFUtil . loadModelURI(mmUri, rs);
69- val Set<EPackage > syntax = syntaxResource. getContents(). filter(EPackage ). toSet
61+ // // Get syntax
62+ // val ResourceSet rs = new ResourceSetImpl
63+ // val URI mmUri = URI.createURI(selection.syntax.ecoreUri)
64+ // //val URI mmUri = URI.createURI("platform:/resource/"+ root.name + "." + selection.name.toLowerCase + "/model/" + selection.name + ".ecore")
65+ // val Resource syntaxResource = EMFUtil.loadModelURI(mmUri, rs);
66+ // val Set<EPackage> syntax = syntaxResource.getContents().filter(EPackage).toSet
7067
7168 // Register all packages in registry
7269 // TODO remove them afterwards?
73- for (EPackage p : syntaxResource. allContents. filter(EPackage ). toSet)
74- EPackage . Registry . INSTANCE. put(p. getNsURI(), p);
70+ // for (EPackage p : syntaxResource.allContents.filter(EPackage).toSet)
71+ // EPackage.Registry.INSTANCE.put(p.getNsURI(), p);
72+
7573
76- // We find all extension points providing fr.inria.diverse.trace.gemoc.generator.integration
77- val config = Platform . getExtensionRegistry(). getConfigurationElementsFor(
78- " fr.inria.diverse.trace.gemoc.generator.integration " );
74+ // We find all extension points providing fr.inria.diverse.trace.gemoc.generator.integration
75+ val configNew = Platform . getExtensionRegistry(). getConfigurationElementsFor(
76+ " fr.inria.diverse.opsemanticsview.gen " );
7977
8078 // Using them, we instantiate TraceAddonGeneratorIntegrationConfiguration objects and look for one that can work with the current selected language
81- val TraceAddonGeneratorIntegrationConfiguration validIntegration = config . map [ e |
79+ val OperationalSemanticsViewGenerator validViewGenerator = configNew . map [ e |
8280 e. createExecutableExtension(" class" )
83- ]. filter(TraceAddonGeneratorIntegrationConfiguration ). findFirst [ conf |
84- conf. canWorkWith (selection, melangeFile. project)
81+ ]. filter(OperationalSemanticsViewGenerator ). findFirst [ conf |
82+ conf. canHandle (selection, melangeFile. project)
8583 ]
86-
87- // If we find one, we generate
88- if (validIntegration != null ) {
89- validIntegration. compute(selection, selectedLanguage, melangeFile. project, syntax, rs);
90- val Set<EPackage > executionMetamodel = validIntegration. executionMetamodel
91- val Ecorext mmextension = validIntegration. getExecutionExtension();
92- generateAddon(selectedLanguage, pluginName, executionMetamodel, replace, monitor, mmextension)
84+
85+ // If we find one, we generate
86+ if (validViewGenerator != null ) {
87+ val OperationalSemanticsView mmextension = validViewGenerator. generate(selection, melangeFile. project);
88+ generateAddon(selectedLanguage, pluginName, replace, monitor, mmextension)
9389
9490 } // Otherwise, we error
91+
92+ // TODO remove what is after
93+ //
94+ // // We find all extension points providing fr.inria.diverse.trace.gemoc.generator.integration
95+ // val config = Platform.getExtensionRegistry().getConfigurationElementsFor(
96+ // "fr.inria.diverse.trace.gemoc.generator.integration");
97+ //
98+ // // Using them, we instantiate TraceAddonGeneratorIntegrationConfiguration objects and look for one that can work with the current selected language
99+ // val TraceAddonGeneratorIntegrationConfiguration validIntegration = config.map [ e |
100+ // e.createExecutableExtension("class")
101+ // ].filter(TraceAddonGeneratorIntegrationConfiguration).findFirst [ conf |
102+ // conf.canWorkWith(selection, melangeFile.project)
103+ // ]
104+ //
105+ // // If we find one, we generate
106+ // if (validIntegration != null) {
107+ // validIntegration.compute(selection, selectedLanguage, melangeFile.project, syntax, rs);
108+ // val Set<EPackage> executionMetamodel = validIntegration.executionMetamodel
109+ // val OperationalSemanticsView mmextension = validIntegration.getExecutionExtension();
110+ // generateAddon(selectedLanguage, pluginName, executionMetamodel, replace, monitor, mmextension)
111+ //
112+ // } // Otherwise, we error
95113 else {
96114 throw new CoreException (
97115 new Status (
@@ -107,8 +125,8 @@ class TraceAddonGeneratorIntegration {
107125 /**
108126 * Central operation of the class, that calls business operations
109127 */
110- public static def void generateAddon (String mmName , String pluginName , Set< EPackage > inputMetamodel ,
111- boolean replace , IProgressMonitor monitor , Ecorext executionExtension ) throws CoreException {
128+ public static def void generateAddon (String mmName , String pluginName ,
129+ boolean replace , IProgressMonitor monitor , OperationalSemanticsView executionExtension ) throws CoreException {
112130
113131 // We look for an existing project with this name
114132 val IProject existingProject = ResourcesPlugin . getWorkspace(). getRoot(). getProject(pluginName);
@@ -142,10 +160,7 @@ class TraceAddonGeneratorIntegration {
142160
143161 // Then we call all our business operations
144162 // TODO handle languages defined with multiple ecores
145- val EPackage extendedMetamodel = inputMetamodel. iterator(). next();
146-
147- val GenericEngineTraceAddonGenerator traceaddgen = new GenericEngineTraceAddonGenerator (extendedMetamodel,
148- executionExtension, pluginName);
163+ val GenericEngineTraceAddonGenerator traceaddgen = new GenericEngineTraceAddonGenerator (executionExtension, pluginName);
149164 traceaddgen. generateCompleteAddon(monitor);
150165 } catch (IOException e) {
151166
0 commit comments