diff options
author | Henrik Rentz-Reichert | 2014-11-07 14:33:47 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2014-11-07 14:33:47 +0000 |
commit | c5a6e7e66276b21b78b764afc1da048a56194f67 (patch) | |
tree | 56049b177d7587e99c7042e4c1419d58964469c3 | |
parent | 14a7fab98fef78c50448908fcd46f29aaca76c81 (diff) | |
download | org.eclipse.etrice-c5a6e7e66276b21b78b764afc1da048a56194f67.tar.gz org.eclipse.etrice-c5a6e7e66276b21b78b764afc1da048a56194f67.tar.xz org.eclipse.etrice-c5a6e7e66276b21b78b764afc1da048a56194f67.zip |
Bug 449873 - Port Operations and Messages with the same name
https://bugs.eclipse.org/bugs/show_bug.cgi?id=449873
Included operations into detection of duplicate names.
Created some generic functionality and improved algorithm.
Change-Id: I26df2e375994d1cb56eb186f3041965e0d85caf3
2 files changed, 24 insertions, 24 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore index 93d87936b..c159b7da1 100644 --- a/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore +++ b/plugins/org.eclipse.etrice.core.room/src-gen/org/eclipse/etrice/core/Room.ecore @@ -696,7 +696,7 @@ <details key="body" value="if (this instanceof <%org.eclipse.etrice.core.room.Port%>)
	return ((Port) this).getProtocol();
else if (this instanceof <%org.eclipse.etrice.core.room.SAP%>)
	return ((SAP) this).getProtocol();
else if (this instanceof <%org.eclipse.etrice.core.room.SPP%>)
	return ((SPP) this).getProtocol();
return null;
"/> </eAnnotations> </eOperations> - <eOperations name="getSemantics" eType="ecore:EClass http://www.eclipse.org/etrice/core/fsm/FSM#//ProtocolSemantics"> + <eOperations name="getSemantics" eType="ecore:EClass ../../../../../../org.eclipse.etrice.core.fsm/model/generated/FSM.ecore#//ProtocolSemantics"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <details key="body" value="if (getGeneralProtocol() instanceof <%org.eclipse.etrice.core.room.ProtocolClass%>)
	return ((ProtocolClass)getGeneralProtocol()).getSemantics();
else
	return null;
"/> </eAnnotations> diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java index ad1b20a0e..70cfb2bc6 100644 --- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java +++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java @@ -30,6 +30,9 @@ import org.eclipse.etrice.core.common.base.AnnotationType; import org.eclipse.etrice.core.common.base.BasePackage; import org.eclipse.etrice.core.common.base.Import; import org.eclipse.etrice.core.common.base.LiteralType; +import org.eclipse.etrice.core.common.validation.ValidationHelpers; +import org.eclipse.etrice.core.common.validation.ValidationHelpers.NamedObject; +import org.eclipse.etrice.core.common.validation.ValidationHelpers.NamedObjectList; import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType; import org.eclipse.etrice.core.fsm.fSM.FSMPackage; import org.eclipse.etrice.core.fsm.fSM.MessageFromIf; @@ -512,34 +515,31 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator { default: } + checkDuplicates(pc, true); + checkDuplicates(pc, false); + if (pc.getBase()!=null) { // derived protocol - if (pc.getIncomingMessages().size()>0 && pc.getOutgoingMessages().size()>0) + if (pc.getIncomingMessages().size()>0 && pc.getOutgoingMessages().size()>0) { warning("a derived protocol should add either incoming or outgoing messages, not both", RoomPackage.Literals.PROTOCOL_CLASS__OUTGOING_MESSAGES); - - { - List<Message> incoming = roomHelpers.getAllMessages(pc, true); - HashSet<String> inNames = new HashSet<String>(); - for (Message in : incoming) { - if (!inNames.add(in.getName())) { - int idx = pc.getIncomingMessages().indexOf(in); - if (idx>=0) - error("duplicate message name", pc, RoomPackage.Literals.PROTOCOL_CLASS__INCOMING_MESSAGES, idx); - } - } } + } + } - { - List<Message> outgoing = roomHelpers.getAllMessages(pc, true); - HashSet<String> outNames = new HashSet<String>(); - for (Message out : outgoing) { - if (!outNames.add(out.getName())) { - int idx = pc.getOutgoingMessages().indexOf(out); - if (idx>=0) - error("duplicate message name", pc, RoomPackage.Literals.PROTOCOL_CLASS__OUTGOING_MESSAGES, idx); - } - } - } + /** + * checks duplicates in the set of messages and operations including inherited items + * per direction + * + * @param pc the protocol class + * @param incoming a flag giving the direction to be checked + */ + private void checkDuplicates(ProtocolClass pc, boolean incoming) { + NamedObjectList all = new NamedObjectList(); + all.addAll(roomHelpers.getAllMessages(pc, incoming), RoomPackage.Literals.MESSAGE__NAME); + all.addAll(roomHelpers.getAllOperations(pc, incoming), RoomPackage.Literals.OPERATION__NAME); + Iterable<NamedObject> duplicates = ValidationHelpers.inSameResource(ValidationHelpers.removeUniques(all), pc.eResource()); + for (NamedObject dupl : duplicates) { + error("duplicate message name", dupl.getObj(), dupl.getFeature()); } } |