Browse Source

moved check for exitst in top level regions from ExitValidator to RegionValidator

Axel Terfloth 7 years ago
parent
commit
302508157f

+ 0 - 13
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/validation/ExitValidator.java

@@ -50,18 +50,5 @@ public class ExitValidator extends AbstractSGraphValidator {
 	}
 
 	
-	private static final String REGION_NO_EXIT_ON_TOP_LEVEL_MSG  = "Exit node in top level region not supported - use final states instead.";
-	public static final String  REGION_NO_EXIT_ON_TOP_LEVEL_CODE = "region.NoExitOnTopLevel";
-
-	/**
-	 * TODO: move to region validation
-	 * @param exit
-	 */
-	@Check(CheckType.FAST)
-	public void exitOnStatechart(Exit exit) {
-		if (exit.getParentRegion().getComposite() instanceof Statechart) {
-			error(REGION_NO_EXIT_ON_TOP_LEVEL_MSG, exit, null, -1, REGION_NO_EXIT_ON_TOP_LEVEL_CODE);
-		}
-	}
 
 }

+ 16 - 0
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/validation/RegionValidator.java

@@ -101,4 +101,20 @@ public class RegionValidator extends AbstractSGraphValidator {
 		}
 	}
 
+	
+	
+	private static final String REGION_NO_EXIT_ON_TOP_LEVEL_MSG  = "Exit node in top level region not supported - use final states instead.";
+	public static final String  REGION_NO_EXIT_ON_TOP_LEVEL_CODE = "region.NoExitOnTopLevel";
+
+	/**
+	 * TODO: check region instead of exit. 
+	 * @param exit
+	 */
+	@Check(CheckType.FAST)
+	public void checkRegionNoExitOnTopLevel(Exit exit) {
+		if (exit.getParentRegion().getComposite() instanceof Statechart) {
+			error(REGION_NO_EXIT_ON_TOP_LEVEL_MSG, exit, null, -1, REGION_NO_EXIT_ON_TOP_LEVEL_CODE);
+		}
+	}
+
 }

+ 0 - 12
test-plugins/org.yakindu.sct.model.sgraph.test/src/org/yakindu/sct/model/sgraph/test/validation/ExitValidatorTest.java

@@ -70,18 +70,6 @@ public class ExitValidatorTest extends AbstractSGraphValidatorTest {
 		tester.validate(exit).assertError(EXIT_TRANSITIONS_NO_OUT_CODE);
 	}
 
-	/**
-	 * An exit node must not be used in top level regions.
-	 */
-	@Test
-	public void exitOnStatechart() {
-		State state = createState();
-		Region region = (Region) state.eContainer();
-		Exit exit = factory.createExit();
-		createTransition(state, exit);
-		region.getVertices().add(exit);
-		tester.validate(exit).assertError(REGION_NO_EXIT_ON_TOP_LEVEL_CODE);
-	}
 
 	/**
 	 * Tests a scenario where no issues for an exit nodes exists.

+ 16 - 0
test-plugins/org.yakindu.sct.model.sgraph.test/src/org/yakindu/sct/model/sgraph/test/validation/RegionValidatorTest.java

@@ -15,6 +15,7 @@ import static org.yakindu.sct.model.sgraph.validation.RegionValidator.*;
 import org.eclipse.xtext.junit4.validation.AssertableDiagnostics;
 import org.junit.Test;
 import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.Exit;
 import org.yakindu.sct.model.sgraph.Region;
 import org.yakindu.sct.model.sgraph.State;
 import org.yakindu.sct.model.sgraph.Statechart;
@@ -68,6 +69,21 @@ public class RegionValidatorTest extends AbstractSGraphValidatorTest {
 		tester.validate(statechart).assertOK();
 	}
 
+	
+	/**
+	 * An exit node must not be used in top level regions.
+	 */
+	@Test
+	public void exitOnStatechart() {
+		State state = createState();
+		Region region = (Region) state.eContainer();
+		Exit exit = factory.createExit();
+		createTransition(state, exit);
+		region.getVertices().add(exit);
+		tester.validate(exit).assertError(REGION_NO_EXIT_ON_TOP_LEVEL_CODE);
+	}
+
+	
 	@Override
 	protected Statechart loadStatechart(String path) {
 		return super.loadStatechart("region/" + path);