Explorar o código

Fix some spelling issues

Dominik Tesch %!s(int64=9) %!d(string=hai) anos
pai
achega
887118e407

+ 12 - 12
plugins/org.yakindu.base.expressions/src/org/yakindu/base/expressions/validation/ExpressionsJavaValidator.java

@@ -37,23 +37,23 @@ import com.google.inject.Inject;
 public class ExpressionsJavaValidator extends org.yakindu.base.expressions.validation.AbstractExpressionsJavaValidator
 		implements IValidationIssueAcceptor {
 
-	public static final String WARNING_IS_RAW_CODE = "WarningRaw";
-	public static final String WARNING_IS_RAW_MSG = "%s is a raw type. References to generic type %s should be parameterized";
+	public static final String WARNING_IS_RAW_CODE = "WarningRaw.";
+	public static final String WARNING_IS_RAW_MSG = "%s is a raw type. References to generic type %s should be parameterized.";
 
-	public static final String ERROR_NOT_GENERIC_CODE = "TypeNotGeneric";
-	public static final String ERROR_NOT_GENERIC_MSG = "The type %s is not generic; it cannot be parameterized with arguments %s";
+	public static final String ERROR_NOT_GENERIC_CODE = "TypeNotGeneric.";
+	public static final String ERROR_NOT_GENERIC_MSG = "The type %s is not generic; it cannot be parameterized with arguments %s.";
 
-	public static final String ERROR_ARGUMENTED_SPECIFIER_INCORRECT_ARGUMENT_NR_CODE = "IncorrectNrOfArguments";
-	public static final String ERROR_ARGUMENTED_SPECIFIER_INCORRECT_ARGUMENT_NR_MSG = "Incorrect number of arguments for type %s; it cannot be parameterized with arguments %s";
+	public static final String ERROR_ARGUMENTED_SPECIFIER_INCORRECT_ARGUMENT_NR_CODE = "IncorrectNrOfArguments.";
+	public static final String ERROR_ARGUMENTED_SPECIFIER_INCORRECT_ARGUMENT_NR_MSG = "Incorrect number of arguments for type %s; it cannot be parameterized with arguments %s.";
 
-	public static final String ERROR_BOUND_MISSMATCH_CODE = "TypeParameterBoundMissmatch";
-	public static final String ERROR_BOUND_MISSMATCH_MSG = "Bound mismatch: The type %s is not a valid substitute for the bounded parameter %s of the type %s";
+	public static final String ERROR_BOUND_MISSMATCH_CODE = "TypeParameterBoundMissmatch.";
+	public static final String ERROR_BOUND_MISSMATCH_MSG = "Bound mismatch: The type %s is not a valid substitute for the bounded parameter %s of the type %s.";
 
-	public static final String ERROR_DUPLICATE_TYPE_PARAMETER_CODE = "DuplicateTypeParameter";
-	public static final String ERROR_DUPLICATE_TYPE_PARAMETER_MSG = "Duplicate Type Parameter %s";
+	public static final String ERROR_DUPLICATE_TYPE_PARAMETER_CODE = "DuplicateTypeParameter.";
+	public static final String ERROR_DUPLICATE_TYPE_PARAMETER_MSG = "Duplicate Type Parameter %s.";
 
-	public static final String ERROR_CYCLE_DETECTED_CODE = "TypeExtendsItself";
-	public static final String ERROR_CYCLE_DETECTED_MSG = "Cycle detected: the type %s cannot extend itself";
+	public static final String ERROR_CYCLE_DETECTED_CODE = "TypeExtendsItself.";
+	public static final String ERROR_CYCLE_DETECTED_MSG = "Cycle detected: the type %s cannot extend itself.";
 
 	@Inject
 	private GenericsPrettyPrinter printer;

+ 393 - 393
plugins/org.yakindu.sct.model.sgraph/src/org/yakindu/sct/model/sgraph/validation/SGraphJavaValidator.java

@@ -1,393 +1,393 @@
-/**
- * Copyright (c) 2012-2016 committers of YAKINDU and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- *     committers of YAKINDU - initial API and implementation
- */
-package org.yakindu.sct.model.sgraph.validation;
-
-import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.areOrthogonal;
-import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.collectAncestors;
-import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.commonAncestor;
-import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.findCommonAncestor;
-import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.sources;
-import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.targets;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.xtext.EcoreUtil2;
-import org.eclipse.xtext.validation.AbstractDeclarativeValidator;
-import org.eclipse.xtext.validation.Check;
-import org.eclipse.xtext.validation.CheckType;
-import org.eclipse.xtext.validation.EValidatorRegistrar;
-import org.yakindu.sct.model.sgraph.Choice;
-import org.yakindu.sct.model.sgraph.CompositeElement;
-import org.yakindu.sct.model.sgraph.Entry;
-import org.yakindu.sct.model.sgraph.EntryKind;
-import org.yakindu.sct.model.sgraph.Exit;
-import org.yakindu.sct.model.sgraph.FinalState;
-import org.yakindu.sct.model.sgraph.Region;
-import org.yakindu.sct.model.sgraph.Statechart;
-import org.yakindu.sct.model.sgraph.Synchronization;
-import org.yakindu.sct.model.sgraph.Transition;
-import org.yakindu.sct.model.sgraph.Vertex;
-
-import com.google.inject.Inject;
-
-/**
- * This validator is intended to be used by a compositeValidator (See
- * {@link org.eclipse.xtext.validation.ComposedChecks}) of another language
- * specific validator. It does not register itself as an EValidator.
- * 
- * This validator checks for common graphical constraints for all kinds of state
- * charts.
- * 
- * @author terfloth
- * @author muelder
- * @author bohl - migrated to xtext infrastruture
- * @author schwertfeger
- * @author antony
- */
-public class SGraphJavaValidator extends AbstractDeclarativeValidator {
-
-	public static final String ISSUE_STATE_WITHOUT_NAME = "A state must have a name.";
-	public static final String ISSUE_NODE_NOT_REACHABLE = "Node is not reachable.";
-	public static final String ISSUE_FINAL_STATE_OUTGOING_TRANSITION = "A final state should have no outgoing transition.";
-	public static final String ISSUE_STATE_WITHOUT_OUTGOING_TRANSITION = "A state should have at least one outgoing transition.";
-	public static final String ISSUE_INITIAL_ENTRY_WITH_IN_TRANS = "Initial entry should have no incoming transition.";
-	public static final String ISSUE_INITIAL_ENTRY_WITHOUT_OUT_TRANS = "Initial entry should have a single outgoing transition";
-	public static final String ISSUE_ENTRY_WITH_MULTIPLE_OUT_TRANS = "Entries must not have more than one outgoing transition";
-	public static final String ISSUE_ENTRY_WITH_TRIGGER = "Outgoing Transitions from Entries can not have a Trigger or Guard.";
-	public static final String ISSUE_EXIT_WITH_OUT_TRANS = "Exit node should have no outgoing transition.";
-	public static final String ISSUE_EXIT_WITHOUT_IN_TRANS = "Exit node should have at least one incoming transition";
-	public static final String ISSUE_EXIT_ON_STATECHART = "Exit node in top level region not supported - use final states instead.";
-	public static final String ISSUE_CHOICE_WITHOUT_OUTGOING_TRANSITION = "A choice must have at least one outgoing transition.";
-	public static final String ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY = "The region can't be entered using the shallow history. Add a default entry node.";
-	public static final String ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY = "The region can't be entered using the shallow history. Add a transition from default entry to a state.";
-	public static final String ISSUE_SUBMACHINE_UNRESOLVABLE = "Referenced substate machine '%s'does not exist!";
-	public static final String ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_ORTHOGONAL = "The target states of a synchronization must be orthogonal!";
-	public static final String ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_WITHIN_SAME_PARENTSTATE = "The target states of a synchronization have to be contained in the same parent state within different regions!";
-	public static final String ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_ORTHOGONAL = "The source states of a synchronization must be orthogonal!";
-	public static final String ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_WITHIN_SAME_PARENTSTATE = "The source states of a synchronization have to be contained in the same parent state within different regions!";
-	public static final String ISSUE_SYNCHRONIZATION_TRANSITION_COUNT = "A synchronization should have at least two incoming or two outgoing transitions";
-	public static final String ISSUE_TRANSITION_ORTHOGONAL = "Source and target of a transition must not be located in orthogonal regions!";
-	public static final String ISSUE_INITIAL_ENTRY_WITH_TRANSITION_TO_CONTAINER = "Outgoing Transitions from Entries can only target to sibling or inner states.";
-
-	@Check(CheckType.FAST)
-	public void vertexNotReachable(final Vertex vertex) {
-		if (!(vertex instanceof Entry)) {
-
-			final Set<Object> stateScopeSet = new HashSet<Object>();
-			for (EObject obj : EcoreUtil2.eAllContents(vertex)) {
-				stateScopeSet.add(obj);
-			}
-			stateScopeSet.add(vertex);
-
-			final List<Object> externalPredecessors = new ArrayList<Object>();
-
-			DFS dfs = new DFS() {
-
-				@Override
-				public Iterator<Object> getElementLinks(Object element) {
-					List<Object> elements = new ArrayList<Object>();
-
-					if (element instanceof org.yakindu.sct.model.sgraph.State) {
-						if (!stateScopeSet.contains(element)) {
-							externalPredecessors.add(element);
-						} else {
-							elements.addAll(((org.yakindu.sct.model.sgraph.State) element)
-									.getRegions());
-							elements.addAll(((org.yakindu.sct.model.sgraph.State) element)
-									.getIncomingTransitions());
-						}
-
-					} else if (element instanceof Region) {
-						elements.addAll(((Region) element).getVertices());
-					} else if (element instanceof Entry) {
-						if (!stateScopeSet.contains(element)) {
-							externalPredecessors.add(element);
-						} else {
-							elements.addAll(((Entry) element)
-									.getIncomingTransitions());
-						}
-
-					} else if (element instanceof Vertex) {
-						elements.addAll(((Vertex) element)
-								.getIncomingTransitions());
-
-					} else if (element instanceof Transition) {
-						elements.add(((Transition) element).getSource());
-
-					}
-
-					return elements.iterator();
-				}
-			};
-
-			dfs.perform(vertex);
-
-			if (externalPredecessors.size() == 0) {
-				error(ISSUE_NODE_NOT_REACHABLE, vertex, null, -1);
-			}
-		}
-	}
-
-	/**
-	 * Calculates all predecessor states
-	 */
-
-	@Check(CheckType.FAST)
-	public void finalStateWithOutgoingTransition(FinalState finalState) {
-		if ((finalState.getOutgoingTransitions().size() > 0)) {
-			warning(ISSUE_FINAL_STATE_OUTGOING_TRANSITION, finalState, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void nameIsNotEmpty(org.yakindu.sct.model.sgraph.State state) {
-		if ((state.getName() == null || state.getName().trim().length() == 0)
-				&& !(state instanceof FinalState)) {
-			error(ISSUE_STATE_WITHOUT_NAME, state, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void choiceWithoutOutgoingTransition(Choice choice) {
-		// Choice without outgoing transition
-		if (choice.getOutgoingTransitions().size() == 0) {
-			error(ISSUE_CHOICE_WITHOUT_OUTGOING_TRANSITION, choice, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void disallowTrigger(Entry entry) {
-		for (Transition transition : entry.getOutgoingTransitions()) {
-			if (transition.getTrigger() != null) {
-				error(ISSUE_ENTRY_WITH_TRIGGER, entry, null, -1);
-			}
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void initialEntryWithoutIncomingTransitions(Entry entry) {
-		if (entry.getIncomingTransitions().size() > 0
-				&& entry.getKind().equals(EntryKind.INITIAL)) {
-			warning(ISSUE_INITIAL_ENTRY_WITH_IN_TRANS, entry, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void initialEntryWithoutOutgoingTransition(Entry entry) {
-		if (entry.getOutgoingTransitions().size() == 0
-				&& ((Entry) entry).getKind().equals(EntryKind.INITIAL)) {
-			warning(ISSUE_INITIAL_ENTRY_WITHOUT_OUT_TRANS, entry, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void initialEntryWithMultipleOutgoingTransition(Entry entry) {
-		if (entry.getOutgoingTransitions().size() > 1) {
-			error(ISSUE_ENTRY_WITH_MULTIPLE_OUT_TRANS, entry, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void exitWithoutIncomingTransition(Exit exit) {
-		if (exit.getIncomingTransitions().size() == 0) {
-			warning(ISSUE_EXIT_WITHOUT_IN_TRANS, exit, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void exitWithOutgoingTransition(Exit exit) {
-		if (exit.getOutgoingTransitions().size() > 0) {
-			error(ISSUE_EXIT_WITH_OUT_TRANS, exit, null, -1);
-		}
-	}
-
-	/**
-	 * Exit nodes in top level regions are not supported.
-	 * 
-	 * @param exit
-	 */
-	@Check(CheckType.FAST)
-	public void exitOnStatechart(Exit exit) {
-		if (exit.getParentRegion().getComposite() instanceof Statechart) {
-			error(ISSUE_EXIT_ON_STATECHART, exit, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void synchronizationTransitionCount(Synchronization sync) {
-		if (sync.getIncomingTransitions().size() < 2
-				&& sync.getOutgoingTransitions().size() < 2) {
-			warning(ISSUE_SYNCHRONIZATION_TRANSITION_COUNT, sync, null, -1);
-		}
-	}
-
-	@Check(CheckType.FAST)
-	public void initialEntryWithTransitionToContainer(Transition t) {
-		if (t.getSource() instanceof Entry
-				&& !isChildOrSibling(t.getSource(), t.getTarget())) {
-			error(ISSUE_INITIAL_ENTRY_WITH_TRANSITION_TO_CONTAINER, t, null, -1);
-		}
-	}
-
-	private boolean isChildOrSibling(Vertex source, Vertex target) {
-		TreeIterator<EObject> iter = source.getParentRegion().eAllContents();
-		while (iter.hasNext()) {
-			if (target == iter.next()) {
-				return true;
-			}
-		}
-		return false;
-	}
-
-	/**
-	 * Checks if all composite states that are siblings of a shallow history can
-	 * enter their regions.
-	 * 
-	 * @param e
-	 */
-	@Check(CheckType.FAST)
-	public void regionCantBeEnteredUsingShallowHistory(Entry e) {
-
-		if (e.getKind() == EntryKind.SHALLOW_HISTORY) {
-
-			// get all regions off all sibling states
-			List<Region> regions = new ArrayList<Region>();
-			for (Vertex v : e.getParentRegion().getVertices()) {
-				if (v instanceof org.yakindu.sct.model.sgraph.State) {
-					org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) v;
-					regions.addAll(state.getRegions());
-				}
-			}
-
-			// check each region
-			for (Region r : regions) {
-
-				// first determine if the region contains a default entry
-				Entry defaultEntry = null;
-				for (Vertex v : r.getVertices()) {
-					if (v instanceof Entry) {
-						String name = v.getName().trim().toLowerCase();
-						if (name != null || "".equals(name)
-								|| "default".equals(name)) {
-							defaultEntry = (Entry) v;
-							break;
-						}
-					}
-				}
-
-				// now check error conditions
-				if (defaultEntry == null) {
-					error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY,
-							r, null, -1);
-				} else if (defaultEntry.getOutgoingTransitions().size() != 1) {
-					error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY,
-							r, null, -1);
-				}
-			}
-
-		}
-
-	}
-
-	@Check public void orthogonalTransition(Transition transition) {
-		
-		Vertex source = transition.getSource();
-		Vertex target = transition.getTarget();
-		
-		if ( (source instanceof Synchronization) || (target instanceof Synchronization) ) return; // ... the check does not apply.
-		
-		EObject commonAncestor = commonAncestor(source, target);
-		
-		if (commonAncestor instanceof CompositeElement) {
-			
-			error(ISSUE_TRANSITION_ORTHOGONAL, transition, null, -1);	
-		}
-	}
-	
-	
-	@Check public void orthogonalSourceStates(Synchronization sync) {
-		
-		List<Vertex> sourceVertices = sources(sync.getIncomingTransitions());
-		
-		if ( ! areOrthogonal(sourceVertices) ) {
-			error(ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_ORTHOGONAL, sync, null, -1);
-		}
-	}
-
-	
-
-	@Check public void orthogonalTargetStates(Synchronization sync) {
-		
-		List<Vertex> sourceVertices = targets(sync.getOutgoingTransitions());
-		
-		if ( ! areOrthogonal(sourceVertices) ) {
-			error(ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_ORTHOGONAL, sync, null, -1);
-		}
-	}
-
-
-
-	@Check public void orthogonalSynchronizedTransition(Synchronization sync) {
-		
-		List<Transition> incoming = sync.getIncomingTransitions();		
-		List<List<EObject>> inAncestorsList = new ArrayList<List<EObject>>();
-		for (Transition trans : incoming) { inAncestorsList.add(collectAncestors(trans.getSource(), new ArrayList<EObject>())); }
-
-		List<Transition> outgoing = sync.getOutgoingTransitions();
-		List<List<EObject>> outAncestorsList = new ArrayList<List<EObject>>(); 
-		for (Transition trans : outgoing) { outAncestorsList.add(collectAncestors(trans.getTarget(), new ArrayList<EObject>())); }
-				
-		
-		Set<Transition> inOrthogonal = new HashSet<Transition>(incoming);
-		Set<Transition> outOrthogonal = new HashSet<Transition>(outgoing);
-		
-		for ( int i=0; i<incoming.size(); i++) {
-			for ( int j=0; j<outgoing.size(); j++ ) {
-				
-				EObject commonAncestor = findCommonAncestor(inAncestorsList.get(i), outAncestorsList.get(j));
-
-				if ( commonAncestor instanceof Region ) {					
-					inOrthogonal.remove(incoming.get(i));
-					outOrthogonal.remove(outgoing.get(j));
-				}
-			}
-		}
-
-		for ( Transition trans : inOrthogonal ) {
-			error(ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_WITHIN_SAME_PARENTSTATE, trans, null, -1);				
-		}
-		
-		for ( Transition trans : outOrthogonal ) {
-			error(ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_WITHIN_SAME_PARENTSTATE, trans, null, -1);				
-		}
-		
-	}
-	
-	
-	
-
-
-	@Override
-	public boolean isLanguageSpecific() {
-		return false;
-	}
-
-	@Inject
-	public void register(EValidatorRegistrar registrar) {
-		// Do not register because this validator is only a composite #398987
-	}
-}
+/**
+ * Copyright (c) 2012-2016 committers of YAKINDU and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     committers of YAKINDU - initial API and implementation
+ */
+package org.yakindu.sct.model.sgraph.validation;
+
+import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.areOrthogonal;
+import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.collectAncestors;
+import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.commonAncestor;
+import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.findCommonAncestor;
+import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.sources;
+import static org.yakindu.sct.model.sgraph.util.SGgraphUtil.targets;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.xtext.EcoreUtil2;
+import org.eclipse.xtext.validation.AbstractDeclarativeValidator;
+import org.eclipse.xtext.validation.Check;
+import org.eclipse.xtext.validation.CheckType;
+import org.eclipse.xtext.validation.EValidatorRegistrar;
+import org.yakindu.sct.model.sgraph.Choice;
+import org.yakindu.sct.model.sgraph.CompositeElement;
+import org.yakindu.sct.model.sgraph.Entry;
+import org.yakindu.sct.model.sgraph.EntryKind;
+import org.yakindu.sct.model.sgraph.Exit;
+import org.yakindu.sct.model.sgraph.FinalState;
+import org.yakindu.sct.model.sgraph.Region;
+import org.yakindu.sct.model.sgraph.Statechart;
+import org.yakindu.sct.model.sgraph.Synchronization;
+import org.yakindu.sct.model.sgraph.Transition;
+import org.yakindu.sct.model.sgraph.Vertex;
+
+import com.google.inject.Inject;
+
+/**
+ * This validator is intended to be used by a compositeValidator (See
+ * {@link org.eclipse.xtext.validation.ComposedChecks}) of another language
+ * specific validator. It does not register itself as an EValidator.
+ * 
+ * This validator checks for common graphical constraints for all kinds of state
+ * charts.
+ * 
+ * @author terfloth
+ * @author muelder
+ * @author bohl - migrated to xtext infrastruture
+ * @author schwertfeger
+ * @author antony
+ */
+public class SGraphJavaValidator extends AbstractDeclarativeValidator {
+
+	public static final String ISSUE_STATE_WITHOUT_NAME = "A state must have a name.";
+	public static final String ISSUE_NODE_NOT_REACHABLE = "Node is not reachable.";
+	public static final String ISSUE_FINAL_STATE_OUTGOING_TRANSITION = "A final state should have no outgoing transition.";
+	public static final String ISSUE_STATE_WITHOUT_OUTGOING_TRANSITION = "A state should have at least one outgoing transition.";
+	public static final String ISSUE_INITIAL_ENTRY_WITH_IN_TRANS = "Initial entry should have no incoming transition.";
+	public static final String ISSUE_INITIAL_ENTRY_WITHOUT_OUT_TRANS = "Initial entry should have a single outgoing transition.";
+	public static final String ISSUE_ENTRY_WITH_MULTIPLE_OUT_TRANS = "Entries must not have more than one outgoing transition.";
+	public static final String ISSUE_ENTRY_WITH_TRIGGER = "Outgoing Transitions from Entries can not have a Trigger or Guard.";
+	public static final String ISSUE_EXIT_WITH_OUT_TRANS = "Exit node should have no outgoing transition.";
+	public static final String ISSUE_EXIT_WITHOUT_IN_TRANS = "Exit node should have at least one incoming transition.";
+	public static final String ISSUE_EXIT_ON_STATECHART = "Exit node in top level region not supported - use final states instead.";
+	public static final String ISSUE_CHOICE_WITHOUT_OUTGOING_TRANSITION = "A choice must have at least one outgoing transition.";
+	public static final String ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY = "The region can't be entered using the shallow history. Add a default entry node.";
+	public static final String ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY = "The region can't be entered using the shallow history. Add a transition from default entry to a state.";
+	public static final String ISSUE_SUBMACHINE_UNRESOLVABLE = "Referenced substate machine '%s'does not exist!";
+	public static final String ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_ORTHOGONAL = "The target states of a synchronization must be orthogonal!";
+	public static final String ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_WITHIN_SAME_PARENTSTATE = "The target states of a synchronization have to be contained in the same parent state within different regions!";
+	public static final String ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_ORTHOGONAL = "The source states of a synchronization must be orthogonal!";
+	public static final String ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_WITHIN_SAME_PARENTSTATE = "The source states of a synchronization have to be contained in the same parent state within different regions!";
+	public static final String ISSUE_SYNCHRONIZATION_TRANSITION_COUNT = "A synchronization should have at least two incoming or two outgoing transitions.";
+	public static final String ISSUE_TRANSITION_ORTHOGONAL = "Source and target of a transition must not be located in orthogonal regions!";
+	public static final String ISSUE_INITIAL_ENTRY_WITH_TRANSITION_TO_CONTAINER = "Outgoing Transitions from Entries can only target to sibling or inner states.";
+
+	@Check(CheckType.FAST)
+	public void vertexNotReachable(final Vertex vertex) {
+		if (!(vertex instanceof Entry)) {
+
+			final Set<Object> stateScopeSet = new HashSet<Object>();
+			for (EObject obj : EcoreUtil2.eAllContents(vertex)) {
+				stateScopeSet.add(obj);
+			}
+			stateScopeSet.add(vertex);
+
+			final List<Object> externalPredecessors = new ArrayList<Object>();
+
+			DFS dfs = new DFS() {
+
+				@Override
+				public Iterator<Object> getElementLinks(Object element) {
+					List<Object> elements = new ArrayList<Object>();
+
+					if (element instanceof org.yakindu.sct.model.sgraph.State) {
+						if (!stateScopeSet.contains(element)) {
+							externalPredecessors.add(element);
+						} else {
+							elements.addAll(((org.yakindu.sct.model.sgraph.State) element)
+									.getRegions());
+							elements.addAll(((org.yakindu.sct.model.sgraph.State) element)
+									.getIncomingTransitions());
+						}
+
+					} else if (element instanceof Region) {
+						elements.addAll(((Region) element).getVertices());
+					} else if (element instanceof Entry) {
+						if (!stateScopeSet.contains(element)) {
+							externalPredecessors.add(element);
+						} else {
+							elements.addAll(((Entry) element)
+									.getIncomingTransitions());
+						}
+
+					} else if (element instanceof Vertex) {
+						elements.addAll(((Vertex) element)
+								.getIncomingTransitions());
+
+					} else if (element instanceof Transition) {
+						elements.add(((Transition) element).getSource());
+
+					}
+
+					return elements.iterator();
+				}
+			};
+
+			dfs.perform(vertex);
+
+			if (externalPredecessors.size() == 0) {
+				error(ISSUE_NODE_NOT_REACHABLE, vertex, null, -1);
+			}
+		}
+	}
+
+	/**
+	 * Calculates all predecessor states
+	 */
+
+	@Check(CheckType.FAST)
+	public void finalStateWithOutgoingTransition(FinalState finalState) {
+		if ((finalState.getOutgoingTransitions().size() > 0)) {
+			warning(ISSUE_FINAL_STATE_OUTGOING_TRANSITION, finalState, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void nameIsNotEmpty(org.yakindu.sct.model.sgraph.State state) {
+		if ((state.getName() == null || state.getName().trim().length() == 0)
+				&& !(state instanceof FinalState)) {
+			error(ISSUE_STATE_WITHOUT_NAME, state, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void choiceWithoutOutgoingTransition(Choice choice) {
+		// Choice without outgoing transition
+		if (choice.getOutgoingTransitions().size() == 0) {
+			error(ISSUE_CHOICE_WITHOUT_OUTGOING_TRANSITION, choice, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void disallowTrigger(Entry entry) {
+		for (Transition transition : entry.getOutgoingTransitions()) {
+			if (transition.getTrigger() != null) {
+				error(ISSUE_ENTRY_WITH_TRIGGER, entry, null, -1);
+			}
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void initialEntryWithoutIncomingTransitions(Entry entry) {
+		if (entry.getIncomingTransitions().size() > 0
+				&& entry.getKind().equals(EntryKind.INITIAL)) {
+			warning(ISSUE_INITIAL_ENTRY_WITH_IN_TRANS, entry, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void initialEntryWithoutOutgoingTransition(Entry entry) {
+		if (entry.getOutgoingTransitions().size() == 0
+				&& ((Entry) entry).getKind().equals(EntryKind.INITIAL)) {
+			warning(ISSUE_INITIAL_ENTRY_WITHOUT_OUT_TRANS, entry, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void initialEntryWithMultipleOutgoingTransition(Entry entry) {
+		if (entry.getOutgoingTransitions().size() > 1) {
+			error(ISSUE_ENTRY_WITH_MULTIPLE_OUT_TRANS, entry, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void exitWithoutIncomingTransition(Exit exit) {
+		if (exit.getIncomingTransitions().size() == 0) {
+			warning(ISSUE_EXIT_WITHOUT_IN_TRANS, exit, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void exitWithOutgoingTransition(Exit exit) {
+		if (exit.getOutgoingTransitions().size() > 0) {
+			error(ISSUE_EXIT_WITH_OUT_TRANS, exit, null, -1);
+		}
+	}
+
+	/**
+	 * Exit nodes in top level regions are not supported.
+	 * 
+	 * @param exit
+	 */
+	@Check(CheckType.FAST)
+	public void exitOnStatechart(Exit exit) {
+		if (exit.getParentRegion().getComposite() instanceof Statechart) {
+			error(ISSUE_EXIT_ON_STATECHART, exit, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void synchronizationTransitionCount(Synchronization sync) {
+		if (sync.getIncomingTransitions().size() < 2
+				&& sync.getOutgoingTransitions().size() < 2) {
+			warning(ISSUE_SYNCHRONIZATION_TRANSITION_COUNT, sync, null, -1);
+		}
+	}
+
+	@Check(CheckType.FAST)
+	public void initialEntryWithTransitionToContainer(Transition t) {
+		if (t.getSource() instanceof Entry
+				&& !isChildOrSibling(t.getSource(), t.getTarget())) {
+			error(ISSUE_INITIAL_ENTRY_WITH_TRANSITION_TO_CONTAINER, t, null, -1);
+		}
+	}
+
+	private boolean isChildOrSibling(Vertex source, Vertex target) {
+		TreeIterator<EObject> iter = source.getParentRegion().eAllContents();
+		while (iter.hasNext()) {
+			if (target == iter.next()) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Checks if all composite states that are siblings of a shallow history can
+	 * enter their regions.
+	 * 
+	 * @param e
+	 */
+	@Check(CheckType.FAST)
+	public void regionCantBeEnteredUsingShallowHistory(Entry e) {
+
+		if (e.getKind() == EntryKind.SHALLOW_HISTORY) {
+
+			// get all regions off all sibling states
+			List<Region> regions = new ArrayList<Region>();
+			for (Vertex v : e.getParentRegion().getVertices()) {
+				if (v instanceof org.yakindu.sct.model.sgraph.State) {
+					org.yakindu.sct.model.sgraph.State state = (org.yakindu.sct.model.sgraph.State) v;
+					regions.addAll(state.getRegions());
+				}
+			}
+
+			// check each region
+			for (Region r : regions) {
+
+				// first determine if the region contains a default entry
+				Entry defaultEntry = null;
+				for (Vertex v : r.getVertices()) {
+					if (v instanceof Entry) {
+						String name = v.getName().trim().toLowerCase();
+						if (name != null || "".equals(name)
+								|| "default".equals(name)) {
+							defaultEntry = (Entry) v;
+							break;
+						}
+					}
+				}
+
+				// now check error conditions
+				if (defaultEntry == null) {
+					error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NO_DEFAULT_ENTRY,
+							r, null, -1);
+				} else if (defaultEntry.getOutgoingTransitions().size() != 1) {
+					error(ISSUE_REGION_CANT_BE_ENTERED_USING_SHALLOW_HISTORY_NON_CONNECTED_DEFAULT_ENTRY,
+							r, null, -1);
+				}
+			}
+
+		}
+
+	}
+
+	@Check public void orthogonalTransition(Transition transition) {
+		
+		Vertex source = transition.getSource();
+		Vertex target = transition.getTarget();
+		
+		if ( (source instanceof Synchronization) || (target instanceof Synchronization) ) return; // ... the check does not apply.
+		
+		EObject commonAncestor = commonAncestor(source, target);
+		
+		if (commonAncestor instanceof CompositeElement) {
+			
+			error(ISSUE_TRANSITION_ORTHOGONAL, transition, null, -1);	
+		}
+	}
+	
+	
+	@Check public void orthogonalSourceStates(Synchronization sync) {
+		
+		List<Vertex> sourceVertices = sources(sync.getIncomingTransitions());
+		
+		if ( ! areOrthogonal(sourceVertices) ) {
+			error(ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_ORTHOGONAL, sync, null, -1);
+		}
+	}
+
+	
+
+	@Check public void orthogonalTargetStates(Synchronization sync) {
+		
+		List<Vertex> sourceVertices = targets(sync.getOutgoingTransitions());
+		
+		if ( ! areOrthogonal(sourceVertices) ) {
+			error(ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_ORTHOGONAL, sync, null, -1);
+		}
+	}
+
+
+
+	@Check public void orthogonalSynchronizedTransition(Synchronization sync) {
+		
+		List<Transition> incoming = sync.getIncomingTransitions();		
+		List<List<EObject>> inAncestorsList = new ArrayList<List<EObject>>();
+		for (Transition trans : incoming) { inAncestorsList.add(collectAncestors(trans.getSource(), new ArrayList<EObject>())); }
+
+		List<Transition> outgoing = sync.getOutgoingTransitions();
+		List<List<EObject>> outAncestorsList = new ArrayList<List<EObject>>(); 
+		for (Transition trans : outgoing) { outAncestorsList.add(collectAncestors(trans.getTarget(), new ArrayList<EObject>())); }
+				
+		
+		Set<Transition> inOrthogonal = new HashSet<Transition>(incoming);
+		Set<Transition> outOrthogonal = new HashSet<Transition>(outgoing);
+		
+		for ( int i=0; i<incoming.size(); i++) {
+			for ( int j=0; j<outgoing.size(); j++ ) {
+				
+				EObject commonAncestor = findCommonAncestor(inAncestorsList.get(i), outAncestorsList.get(j));
+
+				if ( commonAncestor instanceof Region ) {					
+					inOrthogonal.remove(incoming.get(i));
+					outOrthogonal.remove(outgoing.get(j));
+				}
+			}
+		}
+
+		for ( Transition trans : inOrthogonal ) {
+			error(ISSUE_SYNCHRONIZATION_SOURCE_STATES_NOT_WITHIN_SAME_PARENTSTATE, trans, null, -1);				
+		}
+		
+		for ( Transition trans : outOrthogonal ) {
+			error(ISSUE_SYNCHRONIZATION_TARGET_STATES_NOT_WITHIN_SAME_PARENTSTATE, trans, null, -1);				
+		}
+		
+	}
+	
+	
+	
+
+
+	@Override
+	public boolean isLanguageSpecific() {
+		return false;
+	}
+
+	@Inject
+	public void register(EValidatorRegistrar registrar) {
+		// Do not register because this validator is only a composite #398987
+	}
+}

+ 18 - 18
plugins/org.yakindu.sct.model.stext/src/org/yakindu/sct/model/stext/validation/STextValidationMessages.java

@@ -19,22 +19,22 @@ package org.yakindu.sct.model.stext.validation;
  */
 public interface STextValidationMessages {
 
-	public static final String CHOICE_ONE_OUTGOING_DEFAULT_TRANSITION = "A choice should have one outgoing default transition";
-	public static final String FEATURE_CALL_HAS_NO_EFFECT = "FeatureCall has no effect";
-	public static final String ENTRY_EXIT_TRIGGER_NOT_ALLOWED = "Entry/Exit trigger not allowed";
-	public static final String LOCAL_REACTIONS_NOT_ALLOWED = "Local reactions not allowed";
-	public static final String FEATURE_CALL_TO_SCOPE = "FEATURE_CALL_TO_SCOPE";
+	public static final String CHOICE_ONE_OUTGOING_DEFAULT_TRANSITION = "A choice should have one outgoing default transition.";
+	public static final String FEATURE_CALL_HAS_NO_EFFECT = "FeatureCall has no effect.";
+	public static final String ENTRY_EXIT_TRIGGER_NOT_ALLOWED = "Entry/Exit trigger not allowed.";
+	public static final String LOCAL_REACTIONS_NOT_ALLOWED = "Local reactions not allowed.";
+	public static final String FEATURE_CALL_TO_SCOPE = "FEATURE_CALL_TO_SCOPE.";
 	public static final String ONLY_ONE_INTERFACE = "Only one default/unnamed interface is allowed.";
 	public static final String IN_OUT_DECLARATIONS = "In/Out declarations are not allowed in internal scope.";
 	public static final String LOCAL_DECLARATIONS = "Local declarations are not allowed in interface scope.";
-	public static final String TIME_EXPRESSION = "The evaluation result of a time expression must be of type integer";
-	public static final String GUARD_EXPRESSION = "The evaluation result of a guard expression must be of type boolean";
-	public static final String ASSIGNMENT_EXPRESSION = "No nested assignment of the same variable allowed (different behavior in various programming languages)";
-	public static final String TRANSITION_ENTRY_SPEC_NOT_COMPOSITE = "Target state isn't composite";
-	public static final String TRANSITION_EXIT_SPEC_NOT_COMPOSITE = "Source state isn't composite";
+	public static final String TIME_EXPRESSION = "The evaluation result of a time expression must be of type integer.";
+	public static final String GUARD_EXPRESSION = "The evaluation result of a guard expression must be of type boolean.";
+	public static final String ASSIGNMENT_EXPRESSION = "No nested assignment of the same variable allowed (different behavior in various programming languages).";
+	public static final String TRANSITION_ENTRY_SPEC_NOT_COMPOSITE = "Target state isn't composite.";
+	public static final String TRANSITION_EXIT_SPEC_NOT_COMPOSITE = "Source state isn't composite.";
 	public static final String TRANSITION_UNBOUND_DEFAULT_ENTRY_POINT = "Target state has regions without 'default' entries.";
 	public static final String TRANSITION_UNBOUND_NAMED_ENTRY_POINT = "Target state has regions without named entries: ";
-	public static final String TRANSITION_NOT_EXISTING_NAMED_EXIT_POINT = "Source State needs at least one region with the named exit point";
+	public static final String TRANSITION_NOT_EXISTING_NAMED_EXIT_POINT = "Source State needs at least one region with the named exit point.";
 	public static final String TOP_LEVEL_REGION_ENTRY_HAVE_TO_BE_A_DEFAULT_ENTRY = "Entry of top level region have to be a default entry.";
 	public static final String REGION_UNBOUND_DEFAULT_ENTRY_POINT = "Region must have a 'default' entry.";
 	public static final String REGION_UNBOUND_NAMED_ENTRY_POINT = "Region should have a named entry to support transitions entry specification: ";
@@ -42,12 +42,12 @@ public interface STextValidationMessages {
 	public static final String EXIT_UNUSED = "The named exit is not used by outgoing transitions.";
 	public static final String EXIT_DEFAULT_UNUSED = "The parent composite state has no 'default' exit transition.";
 	public static final String TRANSITION_EXIT_SPEC_ON_MULTIPLE_SIBLINGS = "ExitPointSpec can't be used on transition siblings.";
-	public static final String LEFT_HAND_ASSIGNMENT = "The left-hand side of an assignment must be a variable";
-	public static final String ISSUE_TRANSITION_WITHOUT_TRIGGER = "Missing trigger. Transition is never taken. Use 'oncycle' or 'always' instead";
-	public static final String IMPORT_NOT_RESOLVED = "Import cannot be resolved";
+	public static final String LEFT_HAND_ASSIGNMENT = "The left-hand side of an assignment must be a variable.";
+	public static final String ISSUE_TRANSITION_WITHOUT_TRIGGER = "Missing trigger. Transition is never taken. Use 'oncycle' or 'always' instead.";
+	public static final String IMPORT_NOT_RESOLVED = "Import cannot be resolved.";
 	public static final String EXITPOINTSPEC_WITH_TRIGGER = "Transitions with an exit point spec does not have a trigger or guard.";
-	public static final String ASSIGNMENT_TO_VALUE = "Assignment constant not allowed";
-	public static final String REFERENCE_TO_VARIABLE = "Cannot reference a variable in a constant initialization";
-	public static final String REFERENCE_CONSTANT_BEFORE_DEFINED = "Cannot reference a constant from different scope or before it is defined";	
-	public static final String INTERNAL_DECLARATION_UNUSED = "Internal declaration is not used in statechart";
+	public static final String ASSIGNMENT_TO_VALUE = "Assignment constant not allowed.";
+	public static final String REFERENCE_TO_VARIABLE = "Cannot reference a variable in a constant initialization.";
+	public static final String REFERENCE_CONSTANT_BEFORE_DEFINED = "Cannot reference a constant from different scope or before it is defined.";	
+	public static final String INTERNAL_DECLARATION_UNUSED = "Internal declaration is not used in statechart.";
 }