Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2019-03-15 08:37:34 -0400
committerGerrit Code Review @ Eclipse.org2019-03-15 08:37:34 -0400
commitb5c3ad1ba11cb5bc9d9ea3d6db7efea17358f617 (patch)
tree00b8b5f0d18fdc61808837b9491fcc9bb29d0cee
parent6ddba2137388e0833a0f8fe607f0e4146b78346e (diff)
parent6ef105b37e8981b43cad3d560e254613b2b5d3a0 (diff)
downloadorg.eclipse.etrice-b5c3ad1ba11cb5bc9d9ea3d6db7efea17358f617.tar.gz
org.eclipse.etrice-b5c3ad1ba11cb5bc9d9ea3d6db7efea17358f617.tar.xz
org.eclipse.etrice-b5c3ad1ba11cb5bc9d9ea3d6db7efea17358f617.zip
Merge "Bug 545314 - [core] get rid of 'protocol don't match'"
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java29
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java9
2 files changed, 30 insertions, 8 deletions
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 1c365ee81..5c1908651 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
@@ -67,6 +67,7 @@ import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RefPath;
import org.eclipse.etrice.core.room.ReferenceType;
+import org.eclipse.etrice.core.room.RelaySAPoint;
import org.eclipse.etrice.core.room.RoomAnnotationTargetEnum;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.core.room.RoomElement;
@@ -430,20 +431,34 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
@Check
public void checkPortCompatibility(Binding bind) {
+ // don't validate if unresolved, this is already be an error
+ if(EcoreUtil.ExternalCrossReferencer.find(bind).keySet().stream().anyMatch(eObj -> eObj.eIsProxy()))
+ return;
+ // don't validate if protocols are missing or null (NPE), this is an error at the interface item
+ if(bind.getEndpoint1().getPort().getProtocol().eIsProxy() || bind.getEndpoint2().getPort().getProtocol().eIsProxy())
+ return;
+
Result result = validationUtil.isValid(bind);
if (!result.isOk()) {
- EObject sc = bind.eContainer();
- @SuppressWarnings("unchecked")
- int idx = ((List<EObject>)sc.eGet(bind.eContainingFeature())).indexOf(bind);
- error(result.getMsg(), sc, bind.eContainingFeature(), idx);
+ error(result.getMsg(), bind, null);
}
}
@Check
public void checkServiceCompatibility(LayerConnection conn) {
+ // don't validate if unresolved, this is already an error
+ if(EcoreUtil.ExternalCrossReferencer.find(conn).keySet().stream().anyMatch(eObj -> eObj.eIsProxy()))
+ return;
+ // don't validate if protocols are missing or null (NPE), this is an error at the interface item
+ if(conn.getFrom() instanceof RelaySAPoint && ((RelaySAPoint) conn.getFrom()).getRelay().getProtocol().eIsProxy())
+ return;
+ if(conn.getTo().getService().getProtocol().eIsProxy())
+ return;
+
Result result = validationUtil.isValid(conn);
- if (!result.isOk())
+ if (!result.isOk()) {
error(result.getMsg(), RoomPackage.eINSTANCE.getLayerConnection_From());
+ }
}
@Check
@@ -678,6 +693,10 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
public void checkReplicatedPortBindingPatterns(StructureClass sc) {
HashSet<String> haveReplPeer = new HashSet<String>();
for (Binding bind : sc.getBindings()) {
+ // don't validate if unresolved, this is already be an error
+ if(EcoreUtil.ExternalCrossReferencer.find(bind).keySet().stream().anyMatch(eObj -> eObj.eIsProxy()))
+ continue;
+
Port p1 = bind.getEndpoint1().getPort();
Port p2 = bind.getEndpoint2().getPort();
if (p1.getMultiplicity()<0 && p2.getMultiplicity()<0) {
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
index 2a2bfbc01..a83c4fd20 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java
@@ -207,8 +207,7 @@ public class ValidationUtil extends FSMValidationUtil {
return Result.error("protocols don't match");
}
else {
- // under some circumstances the protocols are instances of GeneralProtocolClass
- // (why?)
+ // RoomValidator circumvents this case because its is already a linker error
if (!(pc1 instanceof ProtocolClass && pc2 instanceof ProtocolClass))
return Result.error("protocols don't match");
@@ -234,10 +233,14 @@ public class ValidationUtil extends FSMValidationUtil {
String ns1 = ((RoomModel)pc1.eContainer()).getName();
String ns2 = ((RoomModel)pc2.eContainer()).getName();
if (!ns1.equals(ns2))
- return Result.error("protocols don't match (same name, different name spaces)");
+ return Result.error("protocols have different name spaces");
+ if(pc1.eResource() != pc2.eResource())
+ return Result.error("protocols were not loaded uniquely - check imports");
+ // should not happen
return Result.error("protocols don't match (but have same name)");
}
+
return Result.error("protocols don't match");
}
}

Back to the top