Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2012-05-04 13:24:18 +0000
committerHenrik Rentz-Reichert2012-05-04 13:24:18 +0000
commit1268e7865f37ea58ef293773777e965bfa643c5d (patch)
tree02fed385678db42161a294b8271ba9c8d8fada2e
parent6a9688f5111a152d129cef15d91035ca861671d9 (diff)
downloadorg.eclipse.etrice-1268e7865f37ea58ef293773777e965bfa643c5d.tar.gz
org.eclipse.etrice-1268e7865f37ea58ef293773777e965bfa643c5d.tar.xz
org.eclipse.etrice-1268e7865f37ea58ef293773777e965bfa643c5d.zip
[core.room] validation for RefinedStates
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java8
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/RoomJavaValidator.java7
-rw-r--r--plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/validation/ValidationUtil.java30
3 files changed, 43 insertions, 2 deletions
diff --git a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java
index 19ea10aa8..128a6e5d7 100644
--- a/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java
+++ b/plugins/org.eclipse.etrice.core.room/src/org/eclipse/etrice/core/naming/RoomNameProvider.java
@@ -32,6 +32,7 @@ import org.eclipse.etrice.core.room.LogicalSystem;
import org.eclipse.etrice.core.room.MessageFromIf;
import org.eclipse.etrice.core.room.NonInitialTransition;
import org.eclipse.etrice.core.room.Port;
+import org.eclipse.etrice.core.room.RefinedState;
import org.eclipse.etrice.core.room.RoomClass;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SAPRef;
@@ -56,8 +57,8 @@ import org.eclipse.etrice.core.room.util.RoomSwitch;
public class RoomNameProvider {
- private static final String TOP_STATE_NAME = "TOP";
- private static final String PATH_SEP = "_";
+ public static final String TOP_STATE_NAME = "TOP";
+ public static final String PATH_SEP = "_";
private static RoomSwitch<String> nameProvider = new RoomSwitch<String>() {
public String caseState(State object) { return RoomNameProvider.getStateName(object); }
@@ -194,6 +195,9 @@ public class RoomNameProvider {
}
public static String getParentPath(StateGraphItem item) {
+ if (item instanceof RefinedState)
+ item = ((RefinedState)item).getTarget();
+
State parent = getParentState(item);
if (parent==null)
return "";
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 cce2d3f92..e079b1aed 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
@@ -222,6 +222,13 @@ public class RoomJavaValidator extends AbstractRoomJavaValidator {
}
@Check
+ public void checkTopLevelRefinedStates(ActorClass ac) {
+ Result result = ValidationUtil.checkTopLevelRefinedStates(ac);
+ if (!result.isOk())
+ error(result);
+ }
+
+ @Check
public void checkRefinedStateUnique(RefinedState rs) {
StateGraph sg = (StateGraph) rs.eContainer();
TreeIterator<EObject> it = sg.eAllContents();
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 d80871a42..3e7722c52 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
@@ -21,6 +21,7 @@ import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EStructuralFeature.Setting;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.etrice.core.naming.RoomNameProvider;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorCommunicationType;
import org.eclipse.etrice.core.room.ActorContainerClass;
@@ -45,6 +46,7 @@ import org.eclipse.etrice.core.room.NonInitialTransition;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RefSAPoint;
+import org.eclipse.etrice.core.room.RefinedState;
import org.eclipse.etrice.core.room.RelaySAPoint;
import org.eclipse.etrice.core.room.RoomPackage;
import org.eclipse.etrice.core.room.SPPRef;
@@ -847,4 +849,32 @@ public class ValidationUtil {
}
return Result.ok();
}
+
+ public static Result checkTopLevelRefinedStates(ActorClass ac) {
+ if (ac.getStateMachine()==null)
+ return Result.ok();
+
+ ArrayList<String> paths = new ArrayList<String>();
+ for (org.eclipse.etrice.core.room.State s : ac.getStateMachine().getStates()) {
+ if (s instanceof RefinedState)
+ paths.add(RoomNameProvider.getFullPath(s));
+ }
+ for (org.eclipse.etrice.core.room.State s : ac.getStateMachine().getStates()) {
+ if (s instanceof RefinedState) {
+ String fullPath = RoomNameProvider.getFullPath(s);
+ for (String path : paths) {
+ if (!fullPath.equals(path) && fullPath.startsWith(path) && fullPath.charAt(path.length())==RoomNameProvider.PATH_SEP.charAt(0)) {
+ int idx = ac.getStateMachine().getStates().indexOf(s);
+ return Result.error(
+ "RefinedState has to be in the context of "+path,
+ ac.getStateMachine(),
+ RoomPackage.Literals.STATE_GRAPH__STATES,
+ idx);
+ }
+ }
+ }
+ }
+
+ return Result.ok();
+ }
}

Back to the top