Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2016-11-28 10:10:43 -0500
committerHenrik Rentz-Reichert2016-11-28 10:45:31 -0500
commit39ebaa939c2f2a1e8521bbc64ab8f7d924a97332 (patch)
tree0caaeefb18ff9cb2adbeec9291b4c18bf509aab3
parent84c90477299b193084af9462eb4f32b0615deef5 (diff)
downloadorg.eclipse.etrice-39ebaa939c2f2a1e8521bbc64ab8f7d924a97332.tar.gz
org.eclipse.etrice-39ebaa939c2f2a1e8521bbc64ab8f7d924a97332.tar.xz
org.eclipse.etrice-39ebaa939c2f2a1e8521bbc64ab8f7d924a97332.zip
Bug 507512 - [CGenerator] attributes, operations and handlers of port classes should be generated in derived protocol classes
* Java generator test can be executed locally in an Oomph created environment Change-Id: I2209e573fecd998110837fc35a33289804fd22f5
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend39
-rw-r--r--plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java61
-rw-r--r--tests/org.eclipse.etrice.generator.java.tests/org.eclipse.etrice.generator.java.tests make.xml.launch21
3 files changed, 84 insertions, 37 deletions
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
index b33fd9333..10c9933a1 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/RoomExtensions.xtend
@@ -40,6 +40,7 @@ import org.eclipse.etrice.core.room.ServiceImplementation
import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers
import org.eclipse.etrice.generator.fsm.generic.FSMExtensions
+import java.util.Collections
/**
collection of convenience functions for code generation
@@ -328,8 +329,9 @@ class RoomExtensions extends FSMExtensions {
if (pc.getPortClass(conj)==null)
return false
else {
- for (hdlr : pc.getPortClass(conj).msgHandlers)
- if (pc.getAllMessages(conj).contains(hdlr.msg))
+ val allMessages = pc.getAllMessages(conj)
+ for (hdlr : getSafeList(pc.getPortClass(conj).msgHandlers))
+ if (allMessages.contains(hdlr.msg))
return true;
}
return false;
@@ -344,8 +346,9 @@ class RoomExtensions extends FSMExtensions {
if (pc.getPortClass(conj)==null)
return false
else {
- for (hdlr : pc.getPortClass(conj).msgHandlers)
- if (pc.getAllMessages(!conj).contains(hdlr.msg))
+ val allMessages = pc.getAllMessages(!conj)
+ for (hdlr : getSafeList(pc.getPortClass(conj).msgHandlers))
+ if (allMessages.contains(hdlr.msg))
return true;
}
return false;
@@ -358,9 +361,10 @@ class RoomExtensions extends FSMExtensions {
*/
def boolean handlesReceiveIncludingSuper(ProtocolClass pc, boolean conj) {
val allPortClasses = pc.getAllPortClasses(conj)
+ val allMessages = pc.getAllMessages(!conj)
for (p : allPortClasses)
- for (hdlr : pc.getPortClass(conj).msgHandlers)
- if (pc.getAllMessages(!conj).contains(hdlr.msg))
+ for (hdlr : getSafeList(p.msgHandlers))
+ if (allMessages.contains(hdlr.msg))
return true;
return false;
}
@@ -393,8 +397,9 @@ class RoomExtensions extends FSMExtensions {
def List<MessageHandler> getReceiveHandlers(ProtocolClass pc, boolean conj) {
val res = new ArrayList<MessageHandler>()
if (pc.getPortClass(conj)!=null) {
- for (hdlr : pc.getPortClass(conj).msgHandlers) {
- if (pc.getAllMessages(!conj).contains(hdlr.msg))
+ val allMessages = pc.getAllMessages(!conj)
+ for (hdlr : getSafeList(pc.getPortClass(conj).msgHandlers)) {
+ if (allMessages.contains(hdlr.msg))
res.add(hdlr)
}
}
@@ -409,9 +414,10 @@ class RoomExtensions extends FSMExtensions {
def List<MessageHandler> getReceiveHandlersIncludingSuper(ProtocolClass pc, boolean conj) {
val res = new ArrayList<MessageHandler>()
val allPortClasses = pc.getAllPortClasses(conj)
+ val allMsgs = pc.getAllMessages(!conj)
for (p : allPortClasses) {
- for (hdlr : p.msgHandlers) {
- if (pc.getAllMessages(!conj).contains(hdlr.msg))
+ for (hdlr : getSafeList(p.msgHandlers)) {
+ if (allMsgs.contains(hdlr.msg))
res.add(hdlr)
}
}
@@ -425,11 +431,12 @@ class RoomExtensions extends FSMExtensions {
*/
def List<MessageHandler> getSendHandlers(ProtocolClass pc, boolean conj) {
if (pc.getPortClass(conj)==null)
- return new ArrayList<MessageHandler>()
+ return Collections.emptyList
else {
- var res = new ArrayList<MessageHandler>()
- for (hdlr : pc.getPortClass(conj).msgHandlers) {
- if (pc.getAllMessages(conj).contains(hdlr.msg))
+ val res = new ArrayList<MessageHandler>()
+ val allMessages = pc.getAllMessages(conj)
+ for (hdlr : getSafeList(pc.getPortClass(conj).msgHandlers)) {
+ if (allMessages.contains(hdlr.msg))
res.add(hdlr)
}
return res
@@ -486,6 +493,8 @@ class RoomExtensions extends FSMExtensions {
return result;
}
-
+ def static List<MessageHandler> getSafeList(List<MessageHandler> msgHandlers) {
+ return if (msgHandlers==null) Collections.emptyList else msgHandlers
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
index 2a2c67767..1095bc38b 100644
--- a/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
+++ b/plugins/org.eclipse.etrice.generator/xtend-gen/org/eclipse/etrice/generator/generic/RoomExtensions.java
@@ -15,6 +15,7 @@ import com.google.common.collect.Iterables;
import com.google.inject.Singleton;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.emf.common.util.BasicEList;
@@ -393,12 +394,13 @@ public class RoomExtensions extends FSMExtensions {
if (_equals) {
return false;
} else {
+ final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, conj);
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, conj);
+ List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
+ for (final MessageHandler hdlr : _safeList) {
Message _msg = hdlr.getMsg();
- boolean _contains = _allMessages.contains(_msg);
+ boolean _contains = allMessages.contains(_msg);
if (_contains) {
return true;
}
@@ -418,12 +420,13 @@ public class RoomExtensions extends FSMExtensions {
if (_equals) {
return false;
} else {
+ final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
+ List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
+ for (final MessageHandler hdlr : _safeList) {
Message _msg = hdlr.getMsg();
- boolean _contains = _allMessages.contains(_msg);
+ boolean _contains = allMessages.contains(_msg);
if (_contains) {
return true;
}
@@ -439,13 +442,13 @@ public class RoomExtensions extends FSMExtensions {
*/
public boolean handlesReceiveIncludingSuper(final ProtocolClass pc, final boolean conj) {
final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj);
+ final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
for (final PortClass p : allPortClasses) {
- PortClass _portClass = this.getPortClass(pc, conj);
- EList<MessageHandler> _msgHandlers = _portClass.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
+ EList<MessageHandler> _msgHandlers = p.getMsgHandlers();
+ List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
+ for (final MessageHandler hdlr : _safeList) {
Message _msg = hdlr.getMsg();
- boolean _contains = _allMessages.contains(_msg);
+ boolean _contains = allMessages.contains(_msg);
if (_contains) {
return true;
}
@@ -485,12 +488,13 @@ public class RoomExtensions extends FSMExtensions {
PortClass _portClass = this.getPortClass(pc, conj);
boolean _notEquals = (!Objects.equal(_portClass, null));
if (_notEquals) {
+ final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
+ List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
+ for (final MessageHandler hdlr : _safeList) {
Message _msg = hdlr.getMsg();
- boolean _contains = _allMessages.contains(_msg);
+ boolean _contains = allMessages.contains(_msg);
if (_contains) {
res.add(hdlr);
}
@@ -507,12 +511,13 @@ public class RoomExtensions extends FSMExtensions {
public List<MessageHandler> getReceiveHandlersIncludingSuper(final ProtocolClass pc, final boolean conj) {
final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
final List<PortClass> allPortClasses = this.getAllPortClasses(pc, conj);
+ final List<Message> allMsgs = this._roomHelpers.getAllMessages(pc, (!conj));
for (final PortClass p : allPortClasses) {
EList<MessageHandler> _msgHandlers = p.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, (!conj));
+ List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
+ for (final MessageHandler hdlr : _safeList) {
Message _msg = hdlr.getMsg();
- boolean _contains = _allMessages.contains(_msg);
+ boolean _contains = allMsgs.contains(_msg);
if (_contains) {
res.add(hdlr);
}
@@ -530,15 +535,16 @@ public class RoomExtensions extends FSMExtensions {
PortClass _portClass = this.getPortClass(pc, conj);
boolean _equals = Objects.equal(_portClass, null);
if (_equals) {
- return new ArrayList<MessageHandler>();
+ return Collections.<MessageHandler>emptyList();
} else {
- ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
+ final ArrayList<MessageHandler> res = new ArrayList<MessageHandler>();
+ final List<Message> allMessages = this._roomHelpers.getAllMessages(pc, conj);
PortClass _portClass_1 = this.getPortClass(pc, conj);
EList<MessageHandler> _msgHandlers = _portClass_1.getMsgHandlers();
- for (final MessageHandler hdlr : _msgHandlers) {
- List<Message> _allMessages = this._roomHelpers.getAllMessages(pc, conj);
+ List<MessageHandler> _safeList = RoomExtensions.getSafeList(_msgHandlers);
+ for (final MessageHandler hdlr : _safeList) {
Message _msg = hdlr.getMsg();
- boolean _contains = _allMessages.contains(_msg);
+ boolean _contains = allMessages.contains(_msg);
if (_contains) {
res.add(hdlr);
}
@@ -619,6 +625,17 @@ public class RoomExtensions extends FSMExtensions {
return result;
}
+ public static List<MessageHandler> getSafeList(final List<MessageHandler> msgHandlers) {
+ List<MessageHandler> _xifexpression = null;
+ boolean _equals = Objects.equal(msgHandlers, null);
+ if (_equals) {
+ _xifexpression = Collections.<MessageHandler>emptyList();
+ } else {
+ _xifexpression = msgHandlers;
+ }
+ return _xifexpression;
+ }
+
public String getPortClassName(final EObject p) {
if (p instanceof Port) {
return _getPortClassName((Port)p);
diff --git a/tests/org.eclipse.etrice.generator.java.tests/org.eclipse.etrice.generator.java.tests make.xml.launch b/tests/org.eclipse.etrice.generator.java.tests/org.eclipse.etrice.generator.java.tests make.xml.launch
index 1f479ce03..7ad38f90f 100644
--- a/tests/org.eclipse.etrice.generator.java.tests/org.eclipse.etrice.generator.java.tests make.xml.launch
+++ b/tests/org.eclipse.etrice.generator.java.tests/org.eclipse.etrice.generator.java.tests make.xml.launch
@@ -18,4 +18,25 @@
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/org.eclipse.etrice.generator.java.tests/make.xml}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-v"/>
<stringAttribute key="process_factory_id" value="org.eclipse.ant.ui.remoteAntProcessFactory"/>
+<mapAttribute key="org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES">
+<mapEntry key="eclipse.home" value="${eclipse_home}"/>
+<mapEntry key="eclipse.pdebuild.home" value="${target_platform_plugin_location:org.eclipse.pde.build}"/>
+<mapEntry key="eclipse.pdebuild.scripts" value="${target_platform_plugin_location:org.eclipse.pde.build}/scripts/"/>
+<mapEntry key="eclipse.pdebuild.templates" value="${target_platform_plugin_location:org.eclipse.pde.build}/templates/"/>
+<mapEntry key="eclipse.running" value="true"/>
+<mapEntry key="com.google.guava" value="${target_platform_plugin_location:com.google.guava}"/>
+<mapEntry key="com.google.inject" value="${target_platform_plugin_location:com.google.inject}"/>
+<mapEntry key="javax.inject" value="${target_platform_plugin_location:javax.inject}"/>
+<mapEntry key="org.antlr.runtime" value="${target_platform_plugin_location:org.antlr.runtime}"/>
+<mapEntry key="org.apache.log4j" value="${target_platform_plugin_location:org.apache.log4j}"/>
+<mapEntry key="org.eclipse.emf.common" value="${target_platform_plugin_location:org.eclipse.emf.common}"/>
+<mapEntry key="org.eclipse.emf.ecore" value="${target_platform_plugin_location:org.eclipse.emf.ecore}"/>
+<mapEntry key="org.eclipse.emf.ecore.xmi" value="${target_platform_plugin_location:org.eclipse.emf.ecore.xmi}"/>
+<mapEntry key="org.eclipse.equinox.common" value="${target_platform_plugin_location:org.eclipse.equinox.common}"/>
+<mapEntry key="org.eclipse.xtend.lib" value="${target_platform_plugin_location:org.eclipse.xtend.lib}"/>
+<mapEntry key="org.eclipse.xtext" value="${target_platform_plugin_location:org.eclipse.xtext}"/>
+<mapEntry key="org.eclipse.xtext.common.types" value="${target_platform_plugin_location:org.eclipse.xtext.common.types}"/>
+<mapEntry key="org.eclipse.xtext.util" value="${target_platform_plugin_location:org.eclipse.xtext.util}"/>
+<mapEntry key="org.eclipse.xtext.xbase.lib" value="${target_platform_plugin_location:org.eclipse.xtext.xbase.lib}"/>
+</mapAttribute>
</launchConfiguration>

Back to the top