Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2015-04-10 06:54:04 +0000
committerHenrik Rentz-Reichert2015-04-17 14:09:56 +0000
commit7cd802923e7efb64bad5fd23250b711ddc4c0c94 (patch)
tree5d9a3ffc32416ab5d440ba7dc56d2c27b4c7326c /plugins/org.eclipse.etrice.core.fsm
parent509c50bfd19ca15421352ca1fc51182031aa3be2 (diff)
downloadorg.eclipse.etrice-7cd802923e7efb64bad5fd23250b711ddc4c0c94.tar.gz
org.eclipse.etrice-7cd802923e7efb64bad5fd23250b711ddc4c0c94.tar.xz
org.eclipse.etrice-7cd802923e7efb64bad5fd23250b711ddc4c0c94.zip
refactorings for abstract FSM interface
Diffstat (limited to 'plugins/org.eclipse.etrice.core.fsm')
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore5
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel1
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java18
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java21
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java4
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java2
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe21
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java10
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend6
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java101
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java86
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java4
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java16
14 files changed, 260 insertions, 18 deletions
diff --git a/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF
index cc542e5ca..b4658f6c3 100644
--- a/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.etrice.core.fsm/META-INF/MANIFEST.MF
@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.etrice.core.common;bundle-version="0.5.0",
org.eclipse.emf.ecore,
org.eclipse.emf.common,
org.antlr.runtime,
- org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional
+ org.objectweb.asm;bundle-version="[5.0.1,6.0.0)";resolution:=optional,
+ com.google.guava
Import-Package: org.apache.log4j,
org.eclipse.xtext.xbase.lib
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore
index f163179ba..631bfa5d7 100644
--- a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore
+++ b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.ecore
@@ -382,6 +382,11 @@
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="&lt;br>An abstract interface item to be overridden in derived grammars.&#xA;"/>
</eAnnotations>
+ <eOperations name="getDisplayName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString">
+ <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
+ <details key="body" value="return getName();&#xA;"/>
+ </eAnnotations>
+ </eOperations>
<eOperations name="getSemantics" eType="#//ProtocolSemantics"/>
<eOperations name="getAllIncomingAbstractMessages" upperBound="-1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
<eOperations name="getAllOutgoingAbstractMessages" upperBound="-1" eType="ecore:EClass http://www.eclipse.org/emf/2002/Ecore#//EObject"/>
diff --git a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel
index 059539ebe..edc632ee8 100644
--- a/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel
+++ b/plugins/org.eclipse.etrice.core.fsm/model/generated/FSM.genmodel
@@ -114,6 +114,7 @@
</genClasses>
<genClasses ecoreClass="FSM.ecore#//AbstractInterfaceItem">
<genFeatures createChild="false" ecoreFeature="ecore:EAttribute FSM.ecore#//AbstractInterfaceItem/name"/>
+ <genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getDisplayName"/>
<genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getSemantics"/>
<genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getAllIncomingAbstractMessages"/>
<genOperations ecoreOperation="FSM.ecore#//AbstractInterfaceItem/getAllOutgoingAbstractMessages"/>
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java
index cbb587717..0c28be60e 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/AbstractInterfaceItem.java
@@ -59,6 +59,15 @@ public interface AbstractInterfaceItem extends EObject
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @model kind="operation"
+ * annotation="http://www.eclipse.org/emf/2002/GenModel body='return getName();\n'"
+ * @generated
+ */
+ String getDisplayName();
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @model kind="operation"
* @generated
*/
ProtocolSemantics getSemantics();
@@ -79,4 +88,13 @@ public interface AbstractInterfaceItem extends EObject
*/
EList<EObject> getAllOutgoingAbstractMessages();
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @model kind="operation"
+ * annotation="http://www.eclipse.org/emf/2002/GenModel body='return true;'"
+ * @generated
+ */
+ boolean isEventDriven();
+
} // AbstractInterfaceItem
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java
index 55a229c4a..0bb61939e 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/AbstractInterfaceItemImpl.java
@@ -100,6 +100,17 @@ public class AbstractInterfaceItemImpl extends MinimalEObjectImpl.Container impl
* <!-- end-user-doc -->
* @generated
*/
+ public String getDisplayName()
+ {
+ return getName();
+
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
public ProtocolSemantics getSemantics()
{
// TODO: implement this method
@@ -136,6 +147,16 @@ public class AbstractInterfaceItemImpl extends MinimalEObjectImpl.Container impl
* <!-- end-user-doc -->
* @generated
*/
+ public boolean isEventDriven()
+ {
+ return true;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java
index e4453e4f0..62d9d5d66 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/fSM/impl/FSMPackageImpl.java
@@ -1589,12 +1589,16 @@ public class FSMPackageImpl extends EPackageImpl implements FSMPackage
initEClass(abstractInterfaceItemEClass, AbstractInterfaceItem.class, "AbstractInterfaceItem", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEAttribute(getAbstractInterfaceItem_Name(), ecorePackage.getEString(), "name", null, 0, 1, AbstractInterfaceItem.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ addEOperation(abstractInterfaceItemEClass, ecorePackage.getEString(), "getDisplayName", 0, 1, IS_UNIQUE, IS_ORDERED);
+
addEOperation(abstractInterfaceItemEClass, this.getProtocolSemantics(), "getSemantics", 0, 1, IS_UNIQUE, IS_ORDERED);
addEOperation(abstractInterfaceItemEClass, ecorePackage.getEObject(), "getAllIncomingAbstractMessages", 0, -1, IS_UNIQUE, IS_ORDERED);
addEOperation(abstractInterfaceItemEClass, ecorePackage.getEObject(), "getAllOutgoingAbstractMessages", 0, -1, IS_UNIQUE, IS_ORDERED);
+ addEOperation(abstractInterfaceItemEClass, ecorePackage.getEBoolean(), "isEventDriven", 0, 1, IS_UNIQUE, IS_ORDERED);
+
initEClass(guardEClass, Guard.class, "Guard", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
initEReference(getGuard_Guard(), this.getDetailCode(), null, "guard", null, 0, 1, Guard.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
diff --git a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java
index dffe9b425..4abc7a50e 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src-gen/org/eclipse/etrice/core/fsm/validation/AbstractFSMJavaValidator.java
@@ -9,7 +9,7 @@ import java.util.List;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.xtext.validation.ComposedChecks;
-@ComposedChecks(validators= {org.eclipse.xtext.validation.ImportUriValidator.class, org.eclipse.xtext.validation.NamesAreUniqueValidator.class})
+@ComposedChecks(validators= {org.eclipse.xtext.validation.ImportUriValidator.class})
public class AbstractFSMJavaValidator extends org.eclipse.etrice.core.common.validation.BaseJavaValidator {
@Override
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2 b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2
index aecba1b99..412df2b89 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/GenerateFSM.mwe2
@@ -87,7 +87,6 @@ Workflow {
// Added for compatibility with existing eTrice subgrammars
fragment = validation.JavaValidatorFragment auto-inject {
composedCheck = "org.eclipse.xtext.validation.ImportUriValidator"
- composedCheck = "org.eclipse.xtext.validation.NamesAreUniqueValidator"
}
// old scoping and exporting API
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java
index ced2df965..0313673ba 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/naming/FSMNameProvider.java
@@ -222,11 +222,19 @@ public class FSMNameProvider {
return result;
}
+ public String getTerminalLabel(TransitionTerminal tt) {
+ return getTerminalName(tt, "/");
+ }
+
/**
* @param tt a {@link TransitionTerminal}
* @return a name for the terminal
*/
private String getTerminalName(TransitionTerminal tt) {
+ return getTerminalName(tt, PATH_SEP);
+ }
+
+ private String getTerminalName(TransitionTerminal tt, String sep) {
if (tt instanceof StateTerminal) {
return getStateName(((StateTerminal) tt).getState());
}
@@ -234,7 +242,7 @@ public class FSMNameProvider {
return ((TrPointTerminal) tt).getTrPoint().getName();
}
else if (tt instanceof SubStateTrPointTerminal) {
- return getStatePathName(((SubStateTrPointTerminal) tt).getState())+PATH_SEP+((SubStateTrPointTerminal) tt).getTrPoint().getName();
+ return getStatePathName(((SubStateTrPointTerminal) tt).getState())+sep+((SubStateTrPointTerminal) tt).getTrPoint().getName();
}
else if (tt instanceof ChoicepointTerminal) {
return ((ChoicepointTerminal) tt).getCp().getName();
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend
index fb2230d8d..20cb892f0 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.xtend
@@ -43,9 +43,15 @@ class ImplPostprocessor {
''')
val ifItem = fsmPackage.getClass("AbstractInterfaceItem")
+ ifItem.addOperation("getDisplayName", EcorePackage::eINSTANCE.getEClassifier("EString"), 1,
+ '''
+ return getName();
+ '''
+ )
ifItem.addOperation("getSemantics", fsmPackage.getEClassifier("ProtocolSemantics"))
ifItem.addOperation("getAllIncomingAbstractMessages", EcorePackage.Literals.EOBJECT, -1, null)
ifItem.addOperation("getAllOutgoingAbstractMessages", EcorePackage.Literals.EOBJECT, -1, null)
+ ifItem.addOperation("isEventDriven", EcorePackage.Literals.EBOOLEAN, 1, "return true;")
val itemOwner = fsmPackage.addClass("IInterfaceItemOwner")
itemOwner.setAbstract(true)
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java
index 67930eecd..55f79201d 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/util/FSMHelpers.java
@@ -24,11 +24,14 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.etrice.core.common.base.util.BaseHelpers;
+import org.eclipse.etrice.core.fsm.fSM.AbstractInterfaceItem;
import org.eclipse.etrice.core.fsm.fSM.ChoicePoint;
import org.eclipse.etrice.core.fsm.fSM.ChoicepointTerminal;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.fsm.fSM.FSMFactory;
import org.eclipse.etrice.core.fsm.fSM.FSMPackage;
+import org.eclipse.etrice.core.fsm.fSM.InitialTransition;
+import org.eclipse.etrice.core.fsm.fSM.MessageFromIf;
import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
import org.eclipse.etrice.core.fsm.fSM.RefinedState;
import org.eclipse.etrice.core.fsm.fSM.RefinedTransition;
@@ -1085,7 +1088,7 @@ public class FSMHelpers extends BaseHelpers {
* Returns the complete action code including base class code of a {@link Transition}.
*
* @param trans the transition
- * @param ac the model component
+ * @param mc the model component
*
* @return the complete action code including base class code of a {@link Transition}
*/
@@ -1122,4 +1125,100 @@ public class FSMHelpers extends BaseHelpers {
return null;
}
+ /**
+ * @param mc an {@link ModelComponent}
+ * @return a list of {@link MessageFromIf} that may come in through one of the
+ * event driven interface items of this actor class (<i>without</i> inherited ones)
+ */
+ public List<MessageFromIf> getMessagesFromInterfaces(ModelComponent mc) {
+ ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
+
+ List<AbstractInterfaceItem> items = mc.getAbstractInterfaceItems();
+ for (AbstractInterfaceItem item : items) {
+ for (EObject msg : item.getAllIncomingAbstractMessages()) {
+ MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
+ mif.setMessage(msg);
+ mif.setFrom(item);
+ result.add(mif);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * @param mc an {@link ModelComponent}
+ * @return a list of {@link MessageFromIf} that may come in through one of the
+ * event driven interface items of this actor class (<i>with</i> inherited ones as far as a base class has its own state machine)
+ */
+ public List<MessageFromIf> getOwnMessagesFromInterfaces(ModelComponent mc) {
+ ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
+
+ result.addAll(getMessagesFromInterfaces(mc));
+ mc = mc.getBase();
+ while (mc!=null) {
+ if (hasNonEmptyStateMachine(mc))
+ break;
+
+ List<AbstractInterfaceItem> items = mc.getAbstractInterfaceItems();
+ for (AbstractInterfaceItem item : items) {
+ for (EObject msg : item.getAllIncomingAbstractMessages()) {
+ MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
+ mif.setMessage(msg);
+ mif.setFrom(item);
+ result.add(mif);
+ }
+ }
+
+ mc = mc.getBase();
+ }
+
+ return result;
+ }
+
+ /**
+ * @param mc an {@link ModelComponent}
+ * @return a list of {@link MessageFromIf} that may come in through one of the
+ * event driven interface items of this actor class(<i>including</i> inherited ones)
+ */
+ public List<MessageFromIf> getAllMessagesFromInterfaces(ModelComponent mc) {
+ ArrayList<MessageFromIf> result = new ArrayList<MessageFromIf>();
+
+ while (mc!=null) {
+ List<AbstractInterfaceItem> items = mc.getAbstractInterfaceItems();
+ for (AbstractInterfaceItem item : items) {
+ for (EObject msg : item.getAllIncomingAbstractMessages()) {
+ MessageFromIf mif = FSMFactory.eINSTANCE.createMessageFromIf();
+ mif.setMessage(msg);
+ mif.setFrom(item);
+ result.add(mif);
+ }
+ }
+
+ mc = mc.getBase();
+ }
+
+ return result;
+ }
+
+ /**
+ * @param sg a {@link StateGraph}
+ * @return the initial transition or <code>null</code> if no such is available
+ */
+ public Transition getInitTransition(StateGraph sg) {
+ for (Transition tr : sg.getTransitions()) {
+ if (tr instanceof InitialTransition)
+ return tr;
+ }
+ return null;
+ }
+
+ /**
+ * @param sg a {@link StateGraph}
+ * @return <code>true</code> if an initial transition is available
+ */
+ public boolean hasInitTransition(StateGraph sg) {
+ return getInitTransition(sg)!=null;
+ }
+
}
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
index 538385c70..79326fb2f 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMJavaValidator.java
@@ -4,9 +4,11 @@
package org.eclipse.etrice.core.fsm.validation;
import java.util.ArrayList;
+import java.util.Collection;
import org.eclipse.emf.common.util.TreeIterator;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.etrice.core.fsm.fSM.ChoicePoint;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.fsm.fSM.FSMPackage;
@@ -17,12 +19,15 @@ import org.eclipse.etrice.core.fsm.fSM.RefinedState;
import org.eclipse.etrice.core.fsm.fSM.RefinedTransition;
import org.eclipse.etrice.core.fsm.fSM.SimpleState;
import org.eclipse.etrice.core.fsm.fSM.StateGraph;
+import org.eclipse.etrice.core.fsm.fSM.StateGraphItem;
import org.eclipse.etrice.core.fsm.fSM.TrPoint;
import org.eclipse.etrice.core.fsm.fSM.Transition;
import org.eclipse.etrice.core.fsm.validation.FSMValidationUtilXtend.Result;
import org.eclipse.xtext.util.Strings;
import org.eclipse.xtext.validation.Check;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
import com.google.inject.Inject;
/**
@@ -55,9 +60,9 @@ public class FSMJavaValidator extends org.eclipse.etrice.core.fsm.validation.Abs
@Check
public void checkStateNameUnique(SimpleState s) {
- Result result = ValidationUtil.isUniqueName(s, s.getName());
- if (!result.isOk())
- error(result.getMsg(), FSMPackage.Literals.SIMPLE_STATE__NAME);
+// Result result = ValidationUtil.isUniqueName(s, s.getName());
+// if (!result.isOk())
+// error(result.getMsg(), FSMPackage.Literals.SIMPLE_STATE__NAME);
}
@Check
@@ -69,8 +74,8 @@ public class FSMJavaValidator extends org.eclipse.etrice.core.fsm.validation.Abs
@Check
public void checkChoicePoint(ChoicePoint cp) {
- if (!ValidationUtil.isUniqueName(cp, cp.getName()).isOk())
- error("name is not unique", FSMPackage.Literals.CHOICE_POINT__NAME);
+// if (!ValidationUtil.isUniqueName(cp, cp.getName()).isOk())
+// error("name is not unique", FSMPackage.Literals.CHOICE_POINT__NAME);
}
@Check
@@ -124,7 +129,76 @@ public class FSMJavaValidator extends org.eclipse.etrice.core.fsm.validation.Abs
}
}
- private void error(Result result) {
+ @Check
+ public void checkUniqueNamesInStateGraph(StateGraph sg) {
+ Multimap<String, StateGraphItem> names2items = ArrayListMultimap.create();
+
+ // fill the multimap with all objects
+ do {
+ for (org.eclipse.etrice.core.fsm.fSM.State st : sg.getStates()) {
+ // the parent state of refined states is in this scope - so we don't add the name now
+ if (!(st instanceof RefinedState)) {
+ names2items.put(st.getName(), st);
+ }
+ }
+ for (TrPoint tp : sg.getTrPoints()) {
+ names2items.put(tp.getName(), tp);
+ }
+ for (ChoicePoint cp : sg.getChPoints()) {
+ names2items.put(cp.getName(), cp);
+ }
+ for (Transition tr : sg.getTransitions()) {
+ names2items.put(tr.getName(), tr);
+ }
+
+ if (sg.eContainer() instanceof RefinedState) {
+ sg = ((RefinedState)sg.eContainer()).getTarget().getSubgraph();
+ }
+ else if (sg.eContainer() instanceof ModelComponent) {
+ ModelComponent base = ((ModelComponent)sg.eContainer()).getBase();
+ sg = base!=null? base.getStateMachine():null;
+ }
+ else {
+ break;
+ }
+ }
+ while (sg!=null);
+
+ // check for duplicates
+ for (String key: names2items.keySet()) {
+ Collection<StateGraphItem> list = names2items.get(key);
+ if (list.size()>1) {
+ for (StateGraphItem item: list) {
+ error("Name is not unique in state graph (including super graph)", item, getNameFeature(item));
+ }
+ }
+ }
+ }
+
+ /**
+ * @param item
+ * @return
+ */
+ private EStructuralFeature getNameFeature(StateGraphItem item) {
+ if (item instanceof SimpleState) {
+ return FSMPackage.Literals.SIMPLE_STATE__NAME;
+ }
+ else if (item instanceof ChoicePoint) {
+ return FSMPackage.Literals.CHOICE_POINT__NAME;
+ }
+ else if (item instanceof TrPoint) {
+ return FSMPackage.Literals.TR_POINT__NAME;
+ }
+ else if (item instanceof Transition) {
+ return FSMPackage.Literals.TRANSITION__NAME;
+ }
+ else {
+ assert(false): "internal error: unexpected sub type";
+ return null;
+ }
+ }
+
+ private void error(Result result) {
error(result.getMsg(), result.getSource(), result.getFeature(), result.getIndex());
}
}
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
index d17bb195f..f8180676d 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/validation/FSMValidationUtil.java
@@ -174,8 +174,8 @@ public class FSMValidationUtil extends FSMValidationUtilXtend {
}
public Result isValid(TrPoint tp) {
- if (!isUniqueName(tp, tp.getName()).isOk())
- return Result.error("name is not unique", tp, FSMPackage.Literals.TR_POINT__NAME);
+// if (!isUniqueName(tp, tp.getName()).isOk())
+// return Result.error("name is not unique", tp, FSMPackage.Literals.TR_POINT__NAME);
if (tp instanceof TransitionPoint)
return Result.ok();
diff --git a/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java b/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java
index ede3a8b47..3c6306ffc 100644
--- a/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java
+++ b/plugins/org.eclipse.etrice.core.fsm/xtend-gen/org/eclipse/etrice/core/fsm/postprocessing/ImplPostprocessor.java
@@ -56,17 +56,23 @@ public class ImplPostprocessor {
_builder_1.newLine();
PostprocessingHelpers.addOperation(stateGraphItem, "getName", _eClassifier, Integer.valueOf(1), _builder_1.toString());
final EClass ifItem = PostprocessingHelpers.getClass(fsmPackage, "AbstractInterfaceItem");
- EClassifier _eClassifier_1 = fsmPackage.getEClassifier("ProtocolSemantics");
- PostprocessingHelpers.addOperation(ifItem, "getSemantics", _eClassifier_1);
+ EClassifier _eClassifier_1 = EcorePackage.eINSTANCE.getEClassifier("EString");
+ StringConcatenation _builder_2 = new StringConcatenation();
+ _builder_2.append("return getName();");
+ _builder_2.newLine();
+ PostprocessingHelpers.addOperation(ifItem, "getDisplayName", _eClassifier_1, Integer.valueOf(1), _builder_2.toString());
+ EClassifier _eClassifier_2 = fsmPackage.getEClassifier("ProtocolSemantics");
+ PostprocessingHelpers.addOperation(ifItem, "getSemantics", _eClassifier_2);
PostprocessingHelpers.addOperation(ifItem, "getAllIncomingAbstractMessages", EcorePackage.Literals.EOBJECT, Integer.valueOf((-1)), null);
PostprocessingHelpers.addOperation(ifItem, "getAllOutgoingAbstractMessages", EcorePackage.Literals.EOBJECT, Integer.valueOf((-1)), null);
+ PostprocessingHelpers.addOperation(ifItem, "isEventDriven", EcorePackage.Literals.EBOOLEAN, Integer.valueOf(1), "return true;");
final EClass itemOwner = PostprocessingHelpers.addClass(fsmPackage, "IInterfaceItemOwner");
itemOwner.setAbstract(true);
itemOwner.setInterface(true);
- EClassifier _eClassifier_2 = fsmPackage.getEClassifier("AbstractInterfaceItem");
- PostprocessingHelpers.addOperation(itemOwner, "getAbstractInterfaceItems", _eClassifier_2, Integer.valueOf((-1)), null);
EClassifier _eClassifier_3 = fsmPackage.getEClassifier("AbstractInterfaceItem");
- PostprocessingHelpers.addOperation(itemOwner, "getAllAbstractInterfaceItems", _eClassifier_3, Integer.valueOf((-1)), null);
+ PostprocessingHelpers.addOperation(itemOwner, "getAbstractInterfaceItems", _eClassifier_3, Integer.valueOf((-1)), null);
+ EClassifier _eClassifier_4 = fsmPackage.getEClassifier("AbstractInterfaceItem");
+ PostprocessingHelpers.addOperation(itemOwner, "getAllAbstractInterfaceItems", _eClassifier_4, Integer.valueOf((-1)), null);
final EClass comp = PostprocessingHelpers.getClass(fsmPackage, "ModelComponent");
EList<EClass> _eSuperTypes = comp.getESuperTypes();
_xblockexpression = _eSuperTypes.add(itemOwner);

Back to the top