From 83d359b5adb4cc6282f719d85e3d6e7cb0fcdacb Mon Sep 17 00:00:00 2001 From: Erwan Bousse Date: Mon, 17 Jul 2017 12:11:28 +0200 Subject: [PATCH 1/3] [TraceAddon] Add 'getTrace' public operation --- .../api/IMultiDimensionalTraceAddon.java | 3 + .../gemoc/traceaddon/AbstractTraceAddon.xtend | 60 ++++++++++++------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/trace/commons/plugins/fr.inria.diverse.trace.gemoc.api/src/fr/inria/diverse/trace/gemoc/api/IMultiDimensionalTraceAddon.java b/trace/commons/plugins/fr.inria.diverse.trace.gemoc.api/src/fr/inria/diverse/trace/gemoc/api/IMultiDimensionalTraceAddon.java index b4037783d..2c3c408b3 100644 --- a/trace/commons/plugins/fr.inria.diverse.trace.gemoc.api/src/fr/inria/diverse/trace/gemoc/api/IMultiDimensionalTraceAddon.java +++ b/trace/commons/plugins/fr.inria.diverse.trace.gemoc.api/src/fr/inria/diverse/trace/gemoc/api/IMultiDimensionalTraceAddon.java @@ -17,6 +17,7 @@ import fr.inria.diverse.trace.commons.model.trace.Dimension; import fr.inria.diverse.trace.commons.model.trace.State; import fr.inria.diverse.trace.commons.model.trace.Step; +import fr.inria.diverse.trace.commons.model.trace.Trace; import fr.inria.diverse.trace.commons.model.trace.TracedObject; import fr.inria.diverse.trace.commons.model.trace.Value; @@ -35,4 +36,6 @@ public interface IMultiDimensionalTraceAddon, StateS void load(Resource traceResource); boolean isAddonForTrace(EObject traceRoot); + + Trace getTrace(); } diff --git a/trace/generator/plugins/fr.inria.diverse.trace.gemoc/src/fr/inria/diverse/trace/gemoc/traceaddon/AbstractTraceAddon.xtend b/trace/generator/plugins/fr.inria.diverse.trace.gemoc/src/fr/inria/diverse/trace/gemoc/traceaddon/AbstractTraceAddon.xtend index 70f6e9e10..4aaf97bed 100644 --- a/trace/generator/plugins/fr.inria.diverse.trace.gemoc/src/fr/inria/diverse/trace/gemoc/traceaddon/AbstractTraceAddon.xtend +++ b/trace/generator/plugins/fr.inria.diverse.trace.gemoc/src/fr/inria/diverse/trace/gemoc/traceaddon/AbstractTraceAddon.xtend @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Inria - initial API and implementation *******************************************************************************/ @@ -12,7 +12,14 @@ package fr.inria.diverse.trace.gemoc.traceaddon import com.google.common.collect.BiMap import com.google.common.collect.HashBiMap +import fr.inria.diverse.melange.resource.MelangeResource +import fr.inria.diverse.trace.commons.model.generictrace.GenericDimension +import fr.inria.diverse.trace.commons.model.generictrace.GenericTracedObject +import fr.inria.diverse.trace.commons.model.generictrace.ManyReferenceValue +import fr.inria.diverse.trace.commons.model.generictrace.SingleReferenceValue import fr.inria.diverse.trace.commons.model.trace.Dimension +import fr.inria.diverse.trace.commons.model.trace.GenericMSE +import fr.inria.diverse.trace.commons.model.trace.MSEModel import fr.inria.diverse.trace.commons.model.trace.State import fr.inria.diverse.trace.commons.model.trace.Step import fr.inria.diverse.trace.commons.model.trace.Trace @@ -46,21 +53,23 @@ import org.gemoc.xdsmlframework.api.engine_addon.IEngineAddon import org.gemoc.xdsmlframework.api.engine_addon.modelchangelistener.BatchModelChangeListener import org.gemoc.xdsmlframework.api.extensions.engine_addon.EngineAddonSpecificationExtensionPoint -abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDimensionalTraceAddon, State, TracedObject, Dimension, Value> { +abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDimensionalTraceAddon, State, TracedObject, Dimension, Value> { private IExecutionContext _executionContext - private ITraceExplorer, State, TracedObject, Dimension, Value> traceExplorer - private ITraceExtractor, State, TracedObject, Dimension, Value> traceExtractor + private ITraceExplorer, State, TracedObject, Dimension, Value> traceExplorer + private ITraceExtractor, State, TracedObject, Dimension, Value> traceExtractor private ITraceConstructor traceConstructor private ITraceNotifier traceNotifier private BatchModelChangeListener traceListener - private boolean shouldSave = true private var boolean needTransaction = true private BatchModelChangeListener listenerAddon - - protected abstract def ITraceConstructor constructTraceConstructor(Resource modelResource, Resource traceResource, Map> exeToTraced) - - protected abstract def IStateManager> constructStateManager(Resource modelResource, Map, EObject> tracedToExe) + private Trace, TracedObject, State> trace + + protected abstract def ITraceConstructor constructTraceConstructor(Resource modelResource, Resource traceResource, + Map> exeToTraced) + + protected abstract def IStateManager> constructStateManager(Resource modelResource, + Map, EObject> tracedToExe) override getTraceExplorer() { return traceExplorer @@ -73,15 +82,15 @@ abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDi override getTraceExtractor() { return traceExtractor } - + override getTraceNotifier() { return traceNotifier } - + public override void load(Resource traceResource) { val root = traceResource.contents.head - if (root instanceof Trace) { - val trace = root as Trace,TracedObject,State> + if (root instanceof Trace) { + trace = root as Trace, TracedObject, State> traceExplorer = new GenericTraceExplorer(trace) traceExtractor = new GenericTraceExtractor(trace) } else { @@ -111,13 +120,13 @@ abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDi if (step != null) { modifyTrace([ traceConstructor.addState(listenerAddon.getChanges(this)) - + if (add) { traceConstructor.addStep(step) } else { traceConstructor.endStep(step) } - + // Updating the trace extractor and explorer with the last changes traceNotifier.notifyListener(traceExtractor) traceNotifier.notifyListener(traceExplorer) @@ -127,9 +136,10 @@ abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDi traceExplorer.updateCallStack(step) ]) - if (shouldSave) { -// traceConstructor.save() - } + /*try { + traceConstructor.save() + } catch (Throwable t) { + }*/ } } @@ -155,7 +165,8 @@ abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDi val Resource traceResource = rs.createResource(traceModelURI) // We construct a new listener addon if required - this.listenerAddon = new BatchModelChangeListener(EMFResource.getRelatedResources(engine.executionContext.resourceModel)) + this.listenerAddon = new BatchModelChangeListener( + EMFResource.getRelatedResources(engine.executionContext.resourceModel)) listenerAddon.registerObserver(this) val launchConfiguration = engine.extractLaunchConfiguration @@ -170,8 +181,8 @@ abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDi // And we enable trace exploration by loading it in a new trace explorer val root = traceResource.contents.head - if (root instanceof Trace) { - val trace = root as Trace,TracedObject,State> + if (root instanceof Trace) { + trace = root as Trace, TracedObject, State> val stateManager = constructStateManager(modelResource, exeToTraced.inverse) traceExplorer = new GenericTraceExplorer(trace, stateManager) traceExtractor = new GenericTraceExtractor(trace) @@ -235,4 +246,11 @@ abstract class AbstractTraceAddon extends DefaultEngineAddon implements IMultiDi return errors } + override getTrace() { + return trace + } + + override engineStopped(IExecutionEngine engine) { + } + } From fa44011a8ae80ba444a6eacdf234a177284be88d Mon Sep 17 00:00:00 2001 From: Erwan Bousse Date: Mon, 17 Jul 2017 12:12:02 +0200 Subject: [PATCH 2/3] [EMFCompareUtil] Make it usable without assertions --- .../diverse/trace/commons/EMFCompareUtil.xtend | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/trace/commons/plugins/fr.inria.diverse.trace.commons/src/fr/inria/diverse/trace/commons/EMFCompareUtil.xtend b/trace/commons/plugins/fr.inria.diverse.trace.commons/src/fr/inria/diverse/trace/commons/EMFCompareUtil.xtend index 6c9f21095..c930325a7 100644 --- a/trace/commons/plugins/fr.inria.diverse.trace.commons/src/fr/inria/diverse/trace/commons/EMFCompareUtil.xtend +++ b/trace/commons/plugins/fr.inria.diverse.trace.commons/src/fr/inria/diverse/trace/commons/EMFCompareUtil.xtend @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Inria - initial API and implementation *******************************************************************************/ @@ -22,22 +22,27 @@ import static org.junit.Assert.* class EMFCompareUtil { - public def static void assertEqualsEMF(String message, EObject rootCurrent, EObject rootExpected) { - val DefaultComparisonScope _defaultComparisonScope = new DefaultComparisonScope(rootCurrent, rootExpected, null); + public def static List compare(EObject rootCurrent, EObject rootExpected) { + val DefaultComparisonScope _defaultComparisonScope = new DefaultComparisonScope(rootCurrent, rootExpected, + null); val IComparisonScope scope = _defaultComparisonScope; val _builder = EMFCompare.builder(); val EMFCompare _build = _builder.build(); val Comparison comparison = _build.compare(scope); - val List differences = comparison.getDifferences(); + return comparison.differences + + } + + public def static void assertEqualsEMF(String message, EObject rootCurrent, EObject rootExpected) { + val List differences = compare(rootCurrent, rootExpected); for (d : differences) { val String _string = d.toString(); val String _plus = ("Checking:[" + _string); val String _plus_1 = (_plus + "]"); val DifferenceKind _kind = d.getKind(); println(_plus_1) - assertEquals(message+" - "+_plus_1, DifferenceKind.MOVE, _kind); + assertEquals(message + " - " + _plus_1, DifferenceKind.MOVE, _kind); } - } } From e7f9773b59c3b27d26fe8a26ece588ef97929439 Mon Sep 17 00:00:00 2001 From: Erwan Bousse Date: Mon, 17 Jul 2017 14:31:15 +0200 Subject: [PATCH 3/3] Replace several "fr.inria.diverse" by "org.eclipse.gemoc" --- .../model/GemocExecutionEngineTrace.aird | 22 ++-- .../model/GemocExecutionEngineTrace.ecore | 4 +- .../model/GemocExecutionEngineTrace.genmodel | 2 +- .../JavaEngineTests.launch | 2 +- .../model/GenericTrace.genmodel | 4 +- .../model/GenericTraceImpl.genmodel | 4 +- .../model/LaunchConfiguration.genmodel | 4 +- .../model/base.aird | 118 +++++++++--------- .../model/base.ecore | 18 +-- .../model/base.genmodel | 2 +- 10 files changed, 90 insertions(+), 90 deletions(-) diff --git a/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.aird b/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.aird index 8ff0c774d..40338cfa6 100644 --- a/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.aird +++ b/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.aird @@ -1,7 +1,7 @@ GemocExecutionEngineTrace.ecore - platform:/resource/fr.inria.diverse.trace.commons.model/model/GenericTrace.ecore + platform:/resource/org.eclipse.gemoc.trace.commons.model/model/GenericTrace.ecore http://www.eclipse.org/emf/2002/Ecore platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore @@ -575,8 +575,8 @@ - - + + @@ -588,16 +588,16 @@ - - + + - - + + @@ -605,8 +605,8 @@ - - + + @@ -647,8 +647,8 @@ - - + + labelSize diff --git a/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.ecore b/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.ecore index 1e4ddcc54..618a3c0cd 100644 --- a/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.ecore +++ b/framework/framework_commons/plugins/org.eclipse.gemoc.executionframework.reflectivetrace.model/model/GemocExecutionEngineTrace.ecore @@ -6,9 +6,9 @@ - + GemocExecutionEngineTrace.ecore - + diff --git a/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTrace.genmodel b/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTrace.genmodel index 42c7c957b..c0e605f5b 100644 --- a/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTrace.genmodel +++ b/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTrace.genmodel @@ -1,12 +1,12 @@ GenericTrace.ecore - diff --git a/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTraceImpl.genmodel b/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTraceImpl.genmodel index 0872efdde..e07d2f170 100644 --- a/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTraceImpl.genmodel +++ b/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/GenericTraceImpl.genmodel @@ -1,12 +1,12 @@ GenericTraceImpl.ecore - diff --git a/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/LaunchConfiguration.genmodel b/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/LaunchConfiguration.genmodel index d05c54c03..129920f1e 100644 --- a/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/LaunchConfiguration.genmodel +++ b/trace/commons/plugins/org.eclipse.gemoc.trace.commons.model/model/LaunchConfiguration.genmodel @@ -1,11 +1,11 @@ LaunchConfiguration.ecore - diff --git a/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.aird b/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.aird index 7e151f9c2..18625232f 100644 --- a/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.aird +++ b/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.aird @@ -2,10 +2,10 @@ base.ecore - platform:/resource/fr.inria.diverse.trace.commons.model/model/GenericTrace.ecore + platform:/resource/org.eclipse.gemoc.trace.commons.model/model/GenericTrace.ecore platform:/resource/org.eclipse.emf.ecore/model/Ecore.ecore http://www.eclipse.org/emf/2002/Ecore - platform:/resource/fr.inria.diverse.trace.commons.model/model/LaunchConfiguration.ecore + platform:/resource/org.eclipse.gemoc.trace.commons.model/model/LaunchConfiguration.ecore @@ -799,14 +799,14 @@ - - + + - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -816,8 +816,8 @@ - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -827,8 +827,8 @@ - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -846,8 +846,8 @@ - - + + bold @@ -855,8 +855,8 @@ - - + + labelSize @@ -869,8 +869,8 @@ - - + + @@ -878,8 +878,8 @@ - - + + labelSize @@ -907,14 +907,14 @@ - - + + - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -932,8 +932,8 @@ - - + + @@ -941,8 +941,8 @@ - - + + @@ -967,14 +967,14 @@ - - + + - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -993,8 +993,8 @@ - - + + labelSize @@ -1023,14 +1023,14 @@ - - + + - - + + @@ -1046,14 +1046,14 @@ - - + + - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -1063,8 +1063,8 @@ - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -1163,14 +1163,14 @@ - - + + - - + + KEEP_LOCATION KEEP_SIZE KEEP_RATIO @@ -1188,8 +1188,8 @@ - - + + @@ -1242,8 +1242,8 @@ - - + + italic @@ -1282,9 +1282,9 @@ - - - + + + routingStyle @@ -1294,9 +1294,9 @@ - - - + + + @@ -1305,9 +1305,9 @@ - - - + + + diff --git a/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.ecore b/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.ecore index c09a76ff7..2cf771b85 100644 --- a/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.ecore +++ b/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.ecore @@ -2,8 +2,8 @@ - - + + @@ -25,17 +25,17 @@ - + - + - + @@ -44,7 +44,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -67,7 +67,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.genmodel b/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.genmodel index 6092c9546..cfcc145cb 100644 --- a/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.genmodel +++ b/trace/generator/plugins/org.eclipse.gemoc.trace.metamodel.generator/model/base.genmodel @@ -3,7 +3,7 @@ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/fr.inria.diverse.trace.metamodel.generator/src" modelPluginID="fr.inria.diverse.trace.metamodel.generator" modelName="Base" rootExtendsClass="org.eclipse.emf.ecore.impl.MinimalEObjectImpl$Container" importerID="org.eclipse.emf.importer.ecore" complianceLevel="8.0" copyrightFields="false" - usedGenPackages="../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore ../../fr.inria.diverse.trace.commons.model/model/GenericTrace.genmodel#//trace" + usedGenPackages="../../org.eclipse.emf.ecore/model/Ecore.genmodel#//ecore ../../org.eclipse.gemoc.trace.commons.model/model/GenericTrace.genmodel#//trace" operationReflection="true" importOrganizing="true"> base.ecore