Search in sources :

Example 1 with Synchronization

use of org.yakindu.sct.model.sgraph.Synchronization in project statecharts by Yakindu.

the class SGraphNameProvider method qualifiedName.

public QualifiedName qualifiedName(Synchronization ele) {
    QualifiedName qualifiedNameFromConverter = null;
    if (!Strings.isEmpty(ele.getName())) {
        qualifiedNameFromConverter = QualifiedName.create(ele.getName());
    } else {
        LinkedList<Synchronization> list = new LinkedList<Synchronization>();
        Iterables.addAll(list, Iterables.filter(((Region) ele.eContainer()).getVertices(), Synchronization.class));
        qualifiedNameFromConverter = QualifiedName.create(_SYNC_NAME + list.indexOf(ele));
    }
    return getParentQualifiedName(ele, qualifiedNameFromConverter);
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) Region(org.yakindu.sct.model.sgraph.Region) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) LinkedList(java.util.LinkedList)

Example 2 with Synchronization

use of org.yakindu.sct.model.sgraph.Synchronization in project statecharts by Yakindu.

the class SGraphJavaValidator method orthogonalTransition.

@Check
public void orthogonalTransition(Transition transition) {
    Vertex source = transition.getSource();
    Vertex target = transition.getTarget();
    if ((source instanceof Synchronization) || (target instanceof Synchronization))
        // ... the check does not apply.
        return;
    EObject commonAncestor = commonAncestor(source, target);
    if (commonAncestor instanceof CompositeElement) {
        error(ISSUE_TRANSITION_ORTHOGONAL, transition, null, -1);
    }
}
Also used : Vertex(org.yakindu.sct.model.sgraph.Vertex) EObject(org.eclipse.emf.ecore.EObject) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) CompositeElement(org.yakindu.sct.model.sgraph.CompositeElement) Check(org.eclipse.xtext.validation.Check)

Example 3 with Synchronization

use of org.yakindu.sct.model.sgraph.Synchronization in project statecharts by Yakindu.

the class TransitionsWithNoTriggerTest method noTriggerOnSyncOutgoing.

/**
 * The outgoing transitions of a sync (fork / join) node must not have any
 * trigger part. Thus empty transitions must not have any warning. This test
 * case addresses a bug #75 (
 * https://code.google.com/a/eclipselabs.org/p/yakindu/issues/detail?id=75 )
 * .
 */
@Test
public void noTriggerOnSyncOutgoing() {
    statechart = loadStatechart("ValidEmptyTransitionFromSync.sct");
    Region validRegion = firstNamed(eAllOfType(statechart, Region.class), "valid");
    Synchronization sync = eAllOfType(validRegion, Synchronization.class).get(0);
    for (Transition t : sync.getOutgoingTransitions()) {
        assertTrue(validate(t));
        assertIssueCount(diagnostics, 0);
    }
}
Also used : Transition(org.yakindu.sct.model.sgraph.Transition) Region(org.yakindu.sct.model.sgraph.Region) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Example 4 with Synchronization

use of org.yakindu.sct.model.sgraph.Synchronization in project statecharts by Yakindu.

the class SGraphJavaValidationTest method synchronizationOutgoingTransitionCount.

@Test
public void synchronizationOutgoingTransitionCount() {
    statechart = loadStatechart("SyncOutgoingTransition.sct");
    State state = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "StateB");
    Synchronization sync = (Synchronization) state.getOutgoingTransitions().get(0).getTarget();
    assertFalse(validator.validate(sync, diagnostics, new HashMap<Object, Object>()));
    assertIssueCount(diagnostics, 1);
    assertError(diagnostics, ISSUE_SYNCHRONIZATION_TRANSITION_OUTGOING);
}
Also used : HashMap(java.util.HashMap) FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Example 5 with Synchronization

use of org.yakindu.sct.model.sgraph.Synchronization in project statecharts by Yakindu.

the class SGraphJavaValidationTest method orthogonalSynchronizedTransition_Source.

@Test
public void orthogonalSynchronizedTransition_Source() {
    statechart = loadStatechart("NotOrthogonalRegion03.sct");
    State stateC = firstNamed(EcoreUtil2.eAllOfType(statechart, State.class), "C");
    Synchronization sync = (Synchronization) stateC.getOutgoingTransitions().get(0).getTarget();
    assertFalse(validator.validate(sync, diagnostics, new HashMap<Object, Object>()));
    assertIssueCount(diagnostics, 2);
    assertError(diagnostics, ISSUE_SYNCHRONIZATION_SOURCE_TARGET_STATES_PARENT_REGION);
}
Also used : HashMap(java.util.HashMap) FinalState(org.yakindu.sct.model.sgraph.FinalState) State(org.yakindu.sct.model.sgraph.State) Synchronization(org.yakindu.sct.model.sgraph.Synchronization) Test(org.junit.Test)

Aggregations

Synchronization (org.yakindu.sct.model.sgraph.Synchronization)16 Test (org.junit.Test)14 HashMap (java.util.HashMap)11 FinalState (org.yakindu.sct.model.sgraph.FinalState)10 State (org.yakindu.sct.model.sgraph.State)10 Region (org.yakindu.sct.model.sgraph.Region)4 EObject (org.eclipse.emf.ecore.EObject)2 Transition (org.yakindu.sct.model.sgraph.Transition)2 LinkedList (java.util.LinkedList)1 QualifiedName (org.eclipse.xtext.naming.QualifiedName)1 Check (org.eclipse.xtext.validation.Check)1 CompositeElement (org.yakindu.sct.model.sgraph.CompositeElement)1 Vertex (org.yakindu.sct.model.sgraph.Vertex)1