Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2018-09-28 04:37:35 -0400
committerJan Belle2018-09-28 07:52:11 -0400
commitcb1b76052fbc2f85f4db45a3caf08cdf96b5b502 (patch)
treed7abafb363608ab8635089190d52c5977e2987de
parentf8f82d046d2b781b44af7c418e1d30c12e329e5b (diff)
downloadorg.eclipse.etrice-cb1b76052fbc2f85f4db45a3caf08cdf96b5b502.tar.gz
org.eclipse.etrice-cb1b76052fbc2f85f4db45a3caf08cdf96b5b502.tar.xz
org.eclipse.etrice-cb1b76052fbc2f85f4db45a3caf08cdf96b5b502.zip
[core] Avoid repeated injector creation
* Create custom validator extensions using dependeny injection. * Add factories for generator model builders. Change-Id: I8d72e336ab981c0c218f17aca9d38688c46ac3fe
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java18
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java19
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionRuntimeModule.java26
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionUtil.java73
-rw-r--r--plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/DummyDataCalculator.java28
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.xtend13
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilderFactory.java31
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend20
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilderFactory.java39
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/RoomGenmodelValidator.java8
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java13
-rw-r--r--plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilderFactory.java33
-rw-r--r--plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/util/UIExpressionUtil.xtend5
-rw-r--r--plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF1
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java19
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java24
-rw-r--r--plugins/org.eclipse.etrice.dctools/src/org/eclipse/etrice/dctools/GenModelAccess.xtend37
-rw-r--r--plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend3
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java6
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java3
-rw-r--r--plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend3
-rw-r--r--tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java14
-rw-r--r--tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend10
-rw-r--r--tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java5
-rw-r--r--tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend5
26 files changed, 223 insertions, 236 deletions
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF
index 68fe8cc0b..8e07fe8fd 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/META-INF/MANIFEST.MF
@@ -15,5 +15,4 @@ Require-Bundle: org.eclipse.etrice.core.fsm;bundle-version="2.0.0",
org.eclipse.etrice.generator.base;bundle-version="2.0.0"
Bundle-Activator: org.eclipse.etrice.abstractexec.behavior.Activator
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.etrice.abstractexec.behavior,
- org.eclipse.etrice.abstractexec.behavior.util;x-friends:="org.eclipse.etrice.abstractexec.behavior.tests"
+Export-Package: org.eclipse.etrice.abstractexec.behavior
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
index b4c18ecec..7f941beb7 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/AbstractExecutionValidator.java
@@ -22,8 +22,6 @@ import java.util.Set;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.abstractexec.behavior.util.AbstractExecutionRuntimeModule;
-import org.eclipse.etrice.abstractexec.behavior.util.AbstractExecutionUtil;
import org.eclipse.etrice.core.common.validation.ICustomValidator;
import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
@@ -34,7 +32,9 @@ import org.eclipse.etrice.core.fsm.fSM.State;
import org.eclipse.etrice.core.fsm.fSM.Trigger;
import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition;
import org.eclipse.etrice.core.fsm.naming.FSMNameProvider;
+import org.eclipse.etrice.core.fsm.util.FSMHelpers;
import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder;
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory;
import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions;
import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician;
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.CommonTrigger;
@@ -45,8 +45,7 @@ import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
import org.eclipse.xtext.xbase.lib.IteratorExtensions;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
+import com.google.inject.Inject;
/**
* @author rentzhnr
@@ -60,6 +59,12 @@ public class AbstractExecutionValidator implements ICustomValidator {
public static final String DIAG_CODE_MISSING_TRIGGER = "etrice.receive_message";
public static final String DIAG_CODE_MISSING_MESSAGESEND = "etrice.send_message";
+ @Inject
+ private FSMHelpers fsmHelpers;
+
+ @Inject
+ private ExtendedFsmGenBuilderFactory fsmGenBuilderFactory;
+
private static final Set<EClass> classesToCheck = new HashSet<EClass>();
private static boolean traceExec = false;
private static String traceName = "";
@@ -101,7 +106,7 @@ public class AbstractExecutionValidator implements ICustomValidator {
if (mc.isAbstract())
return;
- if (AbstractExecutionUtil.getInstance().getRoomHelpers().isCircularClassHierarchy(mc))
+ if (fsmHelpers.isCircularClassHierarchy(mc))
// is checked elsewhere
return;
@@ -122,9 +127,8 @@ public class AbstractExecutionValidator implements ICustomValidator {
if (traceExec) {
System.out.println(" Reached where at least one interface items has semantics");
}
- Injector injector = Guice.createInjector(new AbstractExecutionRuntimeModule());
NullDiagnostician diagnostician = new NullDiagnostician();
- ExtendedFsmGenBuilder builder = new ExtendedFsmGenBuilder(injector, diagnostician);
+ ExtendedFsmGenBuilder builder = fsmGenBuilderFactory.create(diagnostician);
GraphContainer gc;
try {
gc = builder.createTransformedModel(mc);
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java
index 0017907f3..80cf52d32 100644
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java
+++ b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/ReachabilityValidator.java
@@ -22,12 +22,12 @@ import java.util.Set;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.abstractexec.behavior.util.AbstractExecutionRuntimeModule;
-import org.eclipse.etrice.abstractexec.behavior.util.AbstractExecutionUtil;
import org.eclipse.etrice.core.common.validation.ICustomValidator;
import org.eclipse.etrice.core.fsm.fSM.FSMPackage;
import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
+import org.eclipse.etrice.core.fsm.util.FSMHelpers;
import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder;
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory;
import org.eclipse.etrice.core.genmodel.fsm.FsmGenChecker;
import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions;
import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician;
@@ -38,9 +38,7 @@ import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node;
import org.eclipse.etrice.generator.base.logging.NullLogger;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
+import com.google.inject.Inject;
public class ReachabilityValidator implements ICustomValidator {
@@ -51,6 +49,12 @@ public class ReachabilityValidator implements ICustomValidator {
classesToCheck.add(FSMPackage.Literals.MODEL_COMPONENT);
}
+ @Inject
+ private FSMHelpers fsmHelpers;
+
+ @Inject
+ private ExtendedFsmGenBuilderFactory fsmGenBuilderFactory;
+
@Override
public void validate(EObject object, ValidationMessageAcceptor messageAcceptor, ICustomValidator.ValidationContext context) {
@@ -65,13 +69,12 @@ public class ReachabilityValidator implements ICustomValidator {
if (mc.isAbstract())
return;
- if (AbstractExecutionUtil.getInstance().getRoomHelpers().isCircularClassHierarchy(mc))
+ if (fsmHelpers.isCircularClassHierarchy(mc))
// is checked elsewhere
return;
- Injector injector = Guice.createInjector(new AbstractExecutionRuntimeModule());
NullDiagnostician diagnostician = new NullDiagnostician();
- ExtendedFsmGenBuilder builder = new ExtendedFsmGenBuilder(injector, diagnostician);
+ ExtendedFsmGenBuilder builder = fsmGenBuilderFactory.create(diagnostician);
GraphContainer gc;
try {
gc = builder.createTransformedModel(mc);
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionRuntimeModule.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionRuntimeModule.java
deleted file mode 100644
index 91e33cd92..000000000
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionRuntimeModule.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.abstractexec.behavior.util;
-
-import org.eclipse.etrice.core.fsm.FSMRuntimeModule;
-import org.eclipse.etrice.core.genmodel.fsm.ICommonDataCalculator;
-
-public class AbstractExecutionRuntimeModule extends FSMRuntimeModule {
-
- public Class<? extends ICommonDataCalculator> bindICommonDataCalculator() {
- return DummyDataCalculator.class;
- }
-
-}
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionUtil.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionUtil.java
deleted file mode 100644
index 833c7c1b0..000000000
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/AbstractExecutionUtil.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.abstractexec.behavior.util;
-
-import org.eclipse.etrice.core.fsm.FSMStandaloneSetupGenerated;
-import org.eclipse.etrice.core.fsm.naming.FSMNameProvider;
-import org.eclipse.etrice.core.fsm.util.FSMHelpers;
-import org.eclipse.etrice.core.fsm.validation.FSMValidationUtil;
-
-import com.google.inject.Inject;
-import com.google.inject.Injector;
-
-/**
- * @author Henrik Rentz-Reichert
- *
- */
-public class AbstractExecutionUtil {
-
- private static AbstractExecutionUtil instance = null;
-
- /**
- * @return the instance
- */
- public static AbstractExecutionUtil getInstance() {
- if (instance==null) {
- Injector injector = new FSMStandaloneSetupGenerated().createInjector();
- instance = injector.getInstance(AbstractExecutionUtil.class);
- }
- return instance;
- }
-
- @Inject
- private FSMValidationUtil validationUtil;
-
- @Inject
- private FSMHelpers fsmHelpers;
-
- @Inject
- private FSMNameProvider fsmNameProvider;
-
- /**
- * @return the validationUtil
- */
- public FSMValidationUtil getValidationUtil() {
- return validationUtil;
- }
-
- /**
- * @return the fsmHelpers
- */
- public FSMHelpers getRoomHelpers() {
- return fsmHelpers;
- }
-
- /**
- * @return the fsmNameProvider
- */
- public FSMNameProvider getRoomNameProvider() {
- return fsmNameProvider;
- }
-}
diff --git a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/DummyDataCalculator.java b/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/DummyDataCalculator.java
deleted file mode 100644
index ead9424f4..000000000
--- a/plugins/org.eclipse.etrice.abstractexec.behavior/src/org/eclipse/etrice/abstractexec/behavior/util/DummyDataCalculator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * CONTRIBUTORS:
- * Henrik Rentz-Reichert (initial contribution)
- *
- *******************************************************************************/
-
-package org.eclipse.etrice.abstractexec.behavior.util;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.core.genmodel.fsm.ICommonDataCalculator;
-import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link;
-
-public class DummyDataCalculator implements ICommonDataCalculator {
-
- @Override
- public EObject calculateCommonData(Link l) {
- return null;
- }
-
-}
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.xtend b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.xtend
index 1ff86c736..7123acb5a 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.xtend
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilder.xtend
@@ -14,8 +14,6 @@
package org.eclipse.etrice.core.genmodel.fsm
-import com.google.inject.Inject
-import com.google.inject.Injector
import org.eclipse.etrice.core.fsm.fSM.ChoicepointTerminal
import org.eclipse.etrice.core.fsm.fSM.ModelComponent
import org.eclipse.etrice.core.fsm.fSM.NonInitialTransition
@@ -38,20 +36,15 @@ import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node
class BasicFsmGenBuilder {
- @Inject
protected extension FSMHelpers fsmHelpers
protected val factory = FsmGenFactory.eINSTANCE
private var int inheritanceLevel = 0
- new(Injector injector) {
- injector.injectMembers(this)
+ new(FSMHelpers fsmHelpers) {
+ this.fsmHelpers = fsmHelpers
}
-
- // protected constructor leaves injection to super class
- protected new() {
- }
-
+
def GraphContainer createTransformedModel(ModelComponent mc) {
mc.createContainer
}
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilderFactory.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilderFactory.java
new file mode 100644
index 000000000..48695f742
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/BasicFsmGenBuilderFactory.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+* Copyright (c) 2018 protos software gmbh (http://www.protos.de).
+* All rights reserved.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* CONTRIBUTORS:
+* Jan Belle (initial contribution)
+*
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.genmodel.fsm;
+
+import org.eclipse.etrice.core.fsm.util.FSMHelpers;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public class BasicFsmGenBuilderFactory {
+
+ @Inject
+ protected Provider<FSMHelpers> fsmHelperProvider;
+
+ public BasicFsmGenBuilder create() {
+ return new BasicFsmGenBuilder(fsmHelperProvider.get());
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
index 88fa1a24b..5dd9c54f9 100644
--- a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilder.xtend
@@ -14,8 +14,6 @@
package org.eclipse.etrice.core.genmodel.fsm
-import com.google.inject.Inject
-import com.google.inject.Injector
import java.util.HashMap
import java.util.List
import org.eclipse.emf.ecore.EObject
@@ -33,25 +31,21 @@ import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Link
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.Node
import static extension org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions.*
+import org.eclipse.etrice.core.fsm.util.FSMHelpers
class ExtendedFsmGenBuilder extends BasicFsmGenBuilder {
- @Inject
- protected extension ICommonDataCalculator
- @Inject
- protected extension TriggerExtensions
+ protected extension ICommonDataCalculator commonDataCalculator
+ protected extension TriggerExtensions triggerExtensions
protected IDiagnostician validator
val factory = FsmGenFactory.eINSTANCE
- new(Injector injector) {
- this(injector, null)
- }
-
- new(Injector injector, IDiagnostician validator) {
- super()
- injector.injectMembers(this)
+ new(FSMHelpers fsmHelpers, ICommonDataCalculator commonDataCalculator, TriggerExtensions triggerExtensions, IDiagnostician validator) {
+ super(fsmHelpers)
+ this.commonDataCalculator = commonDataCalculator
+ this.triggerExtensions = triggerExtensions
this.validator = if(validator === null) new NullDiagnostician else validator
}
diff --git a/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilderFactory.java b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilderFactory.java
new file mode 100644
index 000000000..7e8cd6ca8
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.genmodel.fsm/src/org/eclipse/etrice/core/genmodel/fsm/ExtendedFsmGenBuilderFactory.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+* Copyright (c) 2018 protos software gmbh (http://www.protos.de).
+* All rights reserved.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* CONTRIBUTORS:
+* Jan Belle (initial contribution)
+*
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.genmodel.fsm;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public class ExtendedFsmGenBuilderFactory extends BasicFsmGenBuilderFactory {
+
+ @Inject
+ private Provider<ICommonDataCalculator> commonDataCalculatorProvider;
+
+ @Inject
+ private Provider<TriggerExtensions> triggerExtensionsProvider;
+
+ public ExtendedFsmGenBuilder create(IDiagnostician diagnostician) {
+ return new ExtendedFsmGenBuilder(fsmHelperProvider.get(),
+ commonDataCalculatorProvider.get(),
+ triggerExtensionsProvider.get(),
+ diagnostician);
+ }
+
+ public ExtendedFsmGenBuilder create() {
+ return create(new NullDiagnostician());
+ }
+}
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/RoomGenmodelValidator.java b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/RoomGenmodelValidator.java
index 353b8a027..94bbf53d5 100644
--- a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/RoomGenmodelValidator.java
+++ b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/RoomGenmodelValidator.java
@@ -26,6 +26,7 @@ import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.etrice.core.common.validation.ICustomValidator;
import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilder;
+import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilderFactory;
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.RoomPackage;
@@ -33,6 +34,8 @@ import org.eclipse.etrice.generator.base.logging.NullLogger;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+import com.google.inject.Inject;
+
public class RoomGenmodelValidator implements ICustomValidator {
@@ -74,6 +77,9 @@ public class RoomGenmodelValidator implements ICustomValidator {
}
}
+ @Inject
+ private GeneratorModelBuilderFactory genModelBuilderFactory;
+
@Override
public String getName() {
@@ -125,7 +131,7 @@ public class RoomGenmodelValidator implements ICustomValidator {
}
Diag diagnostician = new Diag(messageAcceptor);
- GeneratorModelBuilder builder = new GeneratorModelBuilder(new NullLogger(), diagnostician);
+ GeneratorModelBuilder builder = genModelBuilderFactory.create(new NullLogger(), diagnostician);
builder.createGeneratorModel(models, importedModels, true);
// System.out.println("done checking model " + model.getName() + " with result: "
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java
index 0b46ce978..b7619f31e 100644
--- a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java
+++ b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilder.java
@@ -28,7 +28,6 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.etrice.core.RoomStandaloneSetup;
import org.eclipse.etrice.core.genmodel.etricegen.AbstractInstance;
import org.eclipse.etrice.core.genmodel.etricegen.ActorInstance;
import org.eclipse.etrice.core.genmodel.etricegen.ActorInterfaceInstance;
@@ -51,6 +50,7 @@ import org.eclipse.etrice.core.genmodel.etricegen.SystemInstance;
import org.eclipse.etrice.core.genmodel.etricegen.impl.AbstractInstanceImpl;
import org.eclipse.etrice.core.genmodel.etricegen.impl.StructureInstanceImpl;
import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder;
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory;
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician;
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer;
import org.eclipse.etrice.core.room.ActorClass;
@@ -79,8 +79,6 @@ import org.eclipse.etrice.core.room.SubSystemRef;
import org.eclipse.etrice.core.room.util.RoomHelpers;
import org.eclipse.etrice.generator.base.logging.ILogger;
-import com.google.inject.Injector;
-
/**
* A class for the creation of an intermediate model combining all information needed by
* the code generator.
@@ -129,18 +127,19 @@ public class GeneratorModelBuilder {
*/
private IDiagnostician diagnostician;
+ private ExtendedFsmGenBuilderFactory fsmGenBuilderFactory;
+
private boolean debug;
- private Injector roomInjector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration();
-
/**
* the only constructor takes a logger and a diagnostician as arguments
* @param logger
* @param diagnostician
*/
- public GeneratorModelBuilder(ILogger logger, IDiagnostician diagnostician) {
+ public GeneratorModelBuilder(ExtendedFsmGenBuilderFactory fsmGenBuilderFactory, ILogger logger, IDiagnostician diagnostician) {
this.logger = logger;
this.diagnostician = diagnostician;
+ this.fsmGenBuilderFactory = fsmGenBuilderFactory;
}
public Root createGeneratorModel(List<RoomModel> mainModels, List<RoomModel> importedModels, boolean asLibrary) {
@@ -1265,7 +1264,7 @@ public class GeneratorModelBuilder {
+" of "+((RoomModel)ac.eContainer()).getName());
ExpandedActorClass xpac = ETriceGenFactory.eINSTANCE.createExpandedActorClass();
- ExtendedFsmGenBuilder fsmGenBuilder = new ExtendedFsmGenBuilder(roomInjector, diagnostician);
+ ExtendedFsmGenBuilder fsmGenBuilder = fsmGenBuilderFactory.create(diagnostician);
GraphContainer gc = fsmGenBuilder.createTransformedModel(ac);
fsmGenBuilder.withChainHeads(gc);
fsmGenBuilder.withCommonData(gc);
diff --git a/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilderFactory.java b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilderFactory.java
new file mode 100644
index 000000000..7e64d1801
--- /dev/null
+++ b/plugins/org.eclipse.etrice.core.genmodel/src/org/eclipse/etrice/core/genmodel/builder/GeneratorModelBuilderFactory.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+* Copyright (c) 2018 protos software gmbh (http://www.protos.de).
+* All rights reserved.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* CONTRIBUTORS:
+* Jan Belle (initial contribution)
+*
+ *******************************************************************************/
+
+package org.eclipse.etrice.core.genmodel.builder;
+
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory;
+import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician;
+import org.eclipse.etrice.generator.base.logging.ILogger;
+
+import com.google.inject.Inject;
+
+public class GeneratorModelBuilderFactory {
+
+ @Inject
+ private ExtendedFsmGenBuilderFactory fsmGenBuilderFactory;
+
+ public GeneratorModelBuilder create(ILogger logger, IDiagnostician diagnostician) {
+ return new GeneratorModelBuilder(fsmGenBuilderFactory, logger, diagnostician);
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/util/UIExpressionUtil.xtend b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/util/UIExpressionUtil.xtend
index 6b0265fd8..ea60f789a 100644
--- a/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/util/UIExpressionUtil.xtend
+++ b/plugins/org.eclipse.etrice.core.room.ui/src/org/eclipse/etrice/core/ui/util/UIExpressionUtil.xtend
@@ -21,7 +21,6 @@ import org.eclipse.emf.ecore.EReference
import org.eclipse.etrice.core.fsm.fSM.DetailCode
import org.eclipse.etrice.core.fsm.fSM.ModelComponent
import org.eclipse.etrice.core.fsm.fSM.TransitionBase
-import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder
import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
import org.eclipse.etrice.core.room.ActorClass
@@ -37,6 +36,7 @@ import org.eclipse.jface.text.Document
import org.eclipse.xtext.nodemodel.ILeafNode
import static org.eclipse.xtext.EcoreUtil2.getContainerOfType
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
/**
* Utility to create and cache DetailExpressionProvider
@@ -50,11 +50,12 @@ class UIExpressionUtil {
static class GenModelAccess {
+ val fsmGenBuilderFactory = RoomUiModule.injector.getInstance(ExtendedFsmGenBuilderFactory)
Map<ModelComponent, GraphContainer> cache = newHashMap
def public GraphContainer get(ModelComponent mc) {
if(!cache.containsKey(mc)) {
- val builder = new ExtendedFsmGenBuilder(RoomUiModule.injector);
+ val builder = fsmGenBuilderFactory.create()
val gc = builder.createTransformedModel(mc)
builder.withCommonData(gc)
cache.put(mc, gc)
diff --git a/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
index d3b25bc6f..7c73ad2d9 100644
--- a/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.room/META-INF/MANIFEST.MF
@@ -39,4 +39,3 @@ Export-Package: org.eclipse.etrice.core,
org.eclipse.etrice.core.serializer,
org.eclipse.etrice.core.services,
org.eclipse.etrice.core.validation
-Bundle-Activator: org.eclipse.etrice.core.RoomActivator
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java
deleted file mode 100644
index 6144705cf..000000000
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/RoomActivator.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.eclipse.etrice.core;
-
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.etrice.core.validation.ValidatorExtensionManager;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-
-public class RoomActivator extends Plugin implements BundleActivator {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
-
- ValidatorExtensionManager.Registry.getInstance().loadValidatorExtensions();
- }
-}
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java
index aa2d33069..074ad5034 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidatorExtensionManager.java
@@ -21,7 +21,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.common.EMFPlugin;
@@ -37,6 +36,10 @@ import org.eclipse.xtext.validation.Check;
import org.eclipse.xtext.validation.CheckMode;
import org.eclipse.xtext.validation.CheckType;
import org.eclipse.xtext.validation.ValidationMessageAcceptor;
+import org.osgi.framework.Bundle;
+
+import com.google.inject.Inject;
+import com.google.inject.Injector;
/**
* Custom validator manager for room language, that provides registration via an
@@ -97,7 +100,7 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
&& Platform.getExtensionRegistry().getExtensionPoint(IVALIDATOR_ID) != null;
}
- public void loadValidatorExtensions() {
+ public void loadValidatorExtensions(Injector injector) {
IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(IVALIDATOR_ID);
// we use parent-package.class-name as key in our tables
@@ -120,7 +123,11 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
// now we add each extension to our maps
for (IConfigurationElement e : config) {
try {
- final Object ext = e.createExecutableExtension("class");
+ final String extContributor = e.getContributor().getName();
+ final Bundle extBundle = Platform.getBundle(extContributor);
+ final String extClassName = e.getAttribute("class");
+ final Class<?> extClass = extBundle.loadClass(extClassName);
+ final Object ext = injector.getInstance(extClass);
if (ext instanceof ICustomValidator) {
ICustomValidator validator = (ICustomValidator) ext;
infos.add(new ValidatorInfo(validator, e.getName() + ValidatorInfo.SEP
@@ -148,8 +155,8 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
System.out.println("ValidatorExtensionManager: unexpected extension");
}
}
- catch (CoreException ex) {
- System.out.println(ex.getMessage());
+ catch (ClassNotFoundException ex) {
+ System.out.println(ex.toString());
}
}
}
@@ -255,6 +262,13 @@ public class ValidatorExtensionManager extends CustomValidatorManager {
isRegistryAvailable = Registry.isAvailable();
}
+ @Inject
+ public void registerExtensionValidators(Injector injector) {
+ if(isRegistryAvailable) {
+ Registry.getInstance().loadValidatorExtensions(injector);
+ }
+ }
+
@Check
public void checkObject(EObject object) {
if (isRegistryAvailable) {
diff --git a/plugins/org.eclipse.etrice.dctools/src/org/eclipse/etrice/dctools/GenModelAccess.xtend b/plugins/org.eclipse.etrice.dctools/src/org/eclipse/etrice/dctools/GenModelAccess.xtend
index 2ee75e9b4..e39ec1fdd 100644
--- a/plugins/org.eclipse.etrice.dctools/src/org/eclipse/etrice/dctools/GenModelAccess.xtend
+++ b/plugins/org.eclipse.etrice.dctools/src/org/eclipse/etrice/dctools/GenModelAccess.xtend
@@ -15,28 +15,31 @@
package org.eclipse.etrice.dctools
import java.util.Map
-import org.eclipse.etrice.core.RoomStandaloneSetup
import org.eclipse.etrice.core.fsm.fSM.ModelComponent
-import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
+import com.google.inject.Inject
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
+import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician
class GenModelAccess {
- Map<ModelComponent, GraphContainer> cache = newHashMap
-
- def public clearCache() {
- cache.clear
+ @Inject
+ private ExtendedFsmGenBuilderFactory fsmGenBuilderFactory
+
+ Map<ModelComponent, GraphContainer> cache = newHashMap
+
+ def public clearCache() {
+ cache.clear
+ }
+
+ def public GraphContainer get(ModelComponent mc) {
+ if(!cache.containsKey(mc)) {
+ val builder = fsmGenBuilderFactory.create(new NullDiagnostician)
+ val gc = builder.createTransformedModel(mc)
+ builder.withCommonData(gc)
+ cache.put(mc, gc)
}
- def public GraphContainer get(ModelComponent mc) {
- if(!cache.containsKey(mc)) {
- val injector = new RoomStandaloneSetup().createInjector
- val builder = new ExtendedFsmGenBuilder(injector);
- val gc = builder.createTransformedModel(mc)
- builder.withCommonData(gc)
- cache.put(mc, gc)
- }
-
- return cache.get(mc)
- }
+ return cache.get(mc)
+ }
} \ No newline at end of file
diff --git a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
index da261eacf..d34e5375a 100644
--- a/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.cpp/src/org/eclipse/etrice/generator/cpp/gen/DataClassGen.xtend
@@ -18,7 +18,6 @@ import com.google.inject.Inject
import com.google.inject.Singleton
import java.util.List
import org.eclipse.etrice.core.genmodel.etricegen.Root
-import org.eclipse.etrice.generator.base.logging.ILogger
import org.eclipse.etrice.core.room.Attribute
import org.eclipse.etrice.core.room.ComplexType
import org.eclipse.etrice.core.room.DataClass
@@ -36,10 +35,8 @@ class DataClassGen {
// @Inject extension TypeHelpers typeHelpers
@Inject Initialization initHelper
@Inject extension RoomHelpers
- @Inject ILogger logger
def doGenerate(Root root) {
- logger.logInfo("generating code")
for (dc: root.dataClasses) {
var path = dc.getPath
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index ca59d6376..ba2fe6774 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -29,6 +29,7 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilder;
+import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilderFactory;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.fsm.FsmGenExtensions;
@@ -140,6 +141,9 @@ public abstract class AbstractGenerator implements IGenerator, IDetailCodeTransl
@Inject
protected ITranslationProvider translationProvider;
+ @Inject
+ private GeneratorModelBuilderFactory genModelBuilderFactory;
+
private HashMap<DetailCode, String> detailcode2string = new HashMap<DetailCode, String>();
private ResourceSet resourceSet = null;
@@ -238,7 +242,7 @@ public abstract class AbstractGenerator implements IGenerator, IDetailCodeTransl
}
else {
logger.logInfo("-- creating generator model");
- GeneratorModelBuilder gmb = new GeneratorModelBuilder(logger, diagnostician);
+ GeneratorModelBuilder gmb = genModelBuilderFactory.create(logger, diagnostician);
Root gmRoot = gmb.createGeneratorModel(mainModels, importedModels, asLibrary);
if (diagnostician.isFailed()) {
logger.logError("validation failed during build of generator model");
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
index cb1f266a8..8f4cec30b 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
@@ -16,7 +16,9 @@ package org.eclipse.etrice.generator.base;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.etrice.core.genmodel.fsm.ICommonDataCalculator;
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician;
+import org.eclipse.etrice.core.room.util.CommonDataCalculator;
import org.eclipse.etrice.generator.base.io.GeneratorFileIO;
import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup;
import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader;
@@ -84,6 +86,7 @@ public abstract class AbstractGeneratorBaseModule implements Module {
binder.bind(IIfItemIdGenerator.class).to(GenericActorClassGenerator.class);
binder.bind(IDetailCodeTranslator.class).to(AbstractGenerator.class);
+ binder.bind(ICommonDataCalculator.class).to(CommonDataCalculator.class);
if(bindAbstractGenerator() != null)
binder.bind(AbstractGenerator.class).to(bindAbstractGenerator());
diff --git a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend
index 5c7a56d06..0d4c303e9 100644
--- a/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend
+++ b/plugins/org.eclipse.etrice.ui.behavior.fsm/src/org/eclipse/etrice/ui/behavior/fsm/provider/GenModelProvider.xtend
@@ -26,6 +26,7 @@ import org.eclipse.etrice.ui.behavior.fsm.editor.AbstractFSMDiagramTypeProvider
import org.eclipse.graphiti.dt.IDiagramTypeProvider
import org.eclipse.graphiti.services.Graphiti
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.FSMGenElement
+import org.eclipse.etrice.core.genmodel.fsm.BasicFsmGenBuilderFactory
class GenModelProvider {
@@ -37,7 +38,7 @@ class GenModelProvider {
new(AbstractFSMDiagramTypeProvider fsmDiagramProvider) {
this.fsmDiagramProvider = fsmDiagramProvider
- builder = new BasicFsmGenBuilder(fsmDiagramProvider.injector)
+ builder = fsmDiagramProvider.injector.getInstance(BasicFsmGenBuilderFactory).create
}
def updateModel() {
diff --git a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java
index eb38f62ad..9283ef249 100644
--- a/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java
+++ b/tests/org.eclipse.etrice.abstractexec.behavior.tests/src/org/eclipse/etrice/abstractexec/behavior/tests/TestSemantics.java
@@ -20,14 +20,14 @@ import java.util.Set;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
-import org.eclipse.etrice.abstractexec.behavior.AbstractExecutionValidator;
-import org.eclipse.etrice.abstractexec.behavior.util.AbstractExecutionUtil;
import org.eclipse.etrice.core.room.ActorClass;
+import org.eclipse.etrice.abstractexec.behavior.AbstractExecutionValidator;
import org.eclipse.etrice.core.fsm.fSM.State;
import org.eclipse.etrice.core.fsm.fSM.StateGraph;
import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
import org.eclipse.etrice.core.fsm.fSM.Transition;
import org.eclipse.etrice.core.fsm.fSM.Trigger;
+import org.eclipse.etrice.core.fsm.naming.FSMNameProvider;
import org.eclipse.xtext.validation.AbstractValidationDiagnostic;
import org.eclipse.xtext.validation.FeatureBasedDiagnostic;
import org.junit.Assert;
@@ -60,6 +60,8 @@ public class TestSemantics {
TestBase basic, cashTerminal, current = null;
+ private FSMNameProvider fsmNameProvider = new FSMNameProvider();
+
@Before
public void setUp() {
basic = new TestBase();
@@ -113,7 +115,7 @@ public class TestSemantics {
Object source = list.get(d.getIndex());
if (source instanceof StateGraphItem) {
StateGraphItem sgi = (StateGraphItem) source;
- checkItem(sgi.getName(), AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(sgi), marker);
+ checkItem(sgi.getName(), fsmNameProvider.getName(sgi), marker);
items.remove(source);
}
}
@@ -121,7 +123,7 @@ public class TestSemantics {
if (container.eContainer() instanceof Transition) {
Transition transition = (Transition) container.eContainer();
checkItem(transition.getName(),
- AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(transition),
+ fsmNameProvider.getName(transition),
marker);
items.remove(container.eContainer());
} else
@@ -129,13 +131,13 @@ public class TestSemantics {
} else if (container instanceof Transition) {
Transition transition = (Transition) container;
checkItem(transition.getName(),
- AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(transition),
+ fsmNameProvider.getName(transition),
marker);
items.remove(container);
} else if (container instanceof State) {
State state = (State) container;
checkItem(state.getName(),
- AbstractExecutionUtil.getInstance().getRoomNameProvider().getName(state),
+ fsmNameProvider.getName(state),
marker);
items.remove(container);
} else
diff --git a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend
index 1ffd72ab8..2c5432e29 100644
--- a/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend
+++ b/tests/org.eclipse.etrice.core.genmodel.fsm.tests/src/org/eclipse/etrice/core/genmodel/fsm/tests/FsmGenTestBase.xtend
@@ -19,12 +19,13 @@ import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.etrice.core.RoomStandaloneSetup
import org.eclipse.etrice.core.TestBase
-import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician
import org.eclipse.etrice.core.genmodel.fsm.NullDiagnostician
import org.eclipse.etrice.core.genmodel.fsm.fsmgen.GraphContainer
import org.eclipse.etrice.core.room.ActorClass
import org.eclipse.etrice.core.room.RoomModel
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilder
class FsmGenTestBase extends TestBase {
@@ -32,13 +33,16 @@ class FsmGenTestBase extends TestBase {
protected ActorClass actor
protected IDiagnostician diagnostician = new NullDiagnostician
protected extension ExtendedFsmGenBuilder builder
+
+ new() {
+ val injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration()
+ builder = injector.getInstance(ExtendedFsmGenBuilderFactory).create(diagnostician)
+ }
protected def getGraphContainer(String roomFile, String actorName) {
prepare(FSMGenModelTestsActivator.getInstance().getBundle())
res = getResource(roomFile)
actor = (res.contents.get(0) as RoomModel).actorClasses.findFirst[name.equals(actorName)]
- val injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration()
- builder = new ExtendedFsmGenBuilder(injector, diagnostician)
builder.createTransformedModel(actor)
}
diff --git a/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java b/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java
index 68425382b..bf1422389 100644
--- a/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java
+++ b/tests/org.eclipse.etrice.core.genmodel.tests/src/org/eclipse/etrice/core/genmodel/TestInstanceModelBuilderBase.java
@@ -31,8 +31,10 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.etrice.core.RoomStandaloneSetup;
import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilder;
+import org.eclipse.etrice.core.genmodel.builder.GeneratorModelBuilderFactory;
import org.eclipse.etrice.core.genmodel.etricegen.InstanceBase;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.fsm.IDiagnostician;
@@ -74,6 +76,7 @@ public class TestInstanceModelBuilderBase {
private String basePath;
protected HashMap<EClass, ArrayList<EObject>> instances;
private RoomNameProvider roomNameProvider = new RoomNameProvider();
+ private GeneratorModelBuilderFactory genModelFactory = new RoomStandaloneSetup().createInjector().getInstance(GeneratorModelBuilderFactory.class);
protected void prepare() {
try {
@@ -102,7 +105,7 @@ public class TestInstanceModelBuilderBase {
}
protected Root buildInstanceModel(String modelName) {
- GeneratorModelBuilder builder = new GeneratorModelBuilder(new NullLogger(), new Diagnostician());
+ GeneratorModelBuilder builder = genModelFactory.create(new NullLogger(), new Diagnostician());
LinkedList<RoomModel> models = getModels(modelName);
ArrayList<RoomModel> importedModels = new ArrayList<>();
Root root = builder.createGeneratorModel(models, importedModels, false);
diff --git a/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend b/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend
index 2c5b6f990..dc4c947b1 100644
--- a/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend
+++ b/tests/org.eclipse.etrice.ui.behavior.tests/src/org/eclipse/etrice/ui/behavior/commands/TestFSMGenModel.xtend
@@ -39,12 +39,13 @@ import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertNotNull
import static org.junit.Assert.assertTrue
import org.eclipse.etrice.generator.base.logging.NullLogger
+import org.eclipse.etrice.core.genmodel.fsm.ExtendedFsmGenBuilderFactory
class TestFSMGenModel extends TestBase {
val injector = new RoomStandaloneSetup().createInjectorAndDoEMFRegistration()
protected IDiagnostician diagnostician = new NullDiagnostician
- protected extension ExtendedFsmGenBuilder builder = new ExtendedFsmGenBuilder(injector, diagnostician)
+ protected extension ExtendedFsmGenBuilder builder = injector.getInstance(ExtendedFsmGenBuilderFactory).create(diagnostician)
protected def createResourceSetWithGc(String roomFile, String actorName) {
prepare(BehaviorTestActivator.^default.getBundle())
@@ -116,7 +117,7 @@ class TestFSMGenModel extends TestBase {
assertEquals(stateGraphItemsNames, namesFromGenModel)
}
- private def <T extends Comparable> toSortedSet(Iterable<T> iterable) {
+ private def <T extends Comparable<?>> toSortedSet(Iterable<T> iterable) {
Sets.<T>newTreeSet(iterable)
}

Back to the top