Search in sources :

Example 26 with Scope

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

the class StatechartObjectViewerFilter method select.

@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
    if (element instanceof DomainNavigatorItem) {
        DomainNavigatorItem navigatorItem = (DomainNavigatorItem) element;
        EObject modelElement = navigatorItem.getEObject();
        if (modelElement instanceof Diagram) {
            return false;
        }
        if (modelElement instanceof Trigger) {
            return false;
        }
        if (modelElement instanceof InternalScope || modelElement instanceof InterfaceScope) {
            return true;
        }
        if (modelElement instanceof Scope) {
            return false;
        }
        if (modelElement instanceof LocalReaction) {
            return false;
        }
        if (modelElement instanceof ReactionEffect) {
            return false;
        }
        if (modelElement instanceof Expression) {
            return false;
        }
    }
    return true;
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) Trigger(org.yakindu.sct.model.sgraph.Trigger) Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Expression(org.yakindu.base.expressions.expressions.Expression) EObject(org.eclipse.emf.ecore.EObject) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) Diagram(org.eclipse.gmf.runtime.notation.Diagram)

Example 27 with Scope

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

the class ModelSequencerStateTest method testLeafStateExitSequence.

/**
 * A leaf state must have a exit sequence. This exit sequence consists of an
 * exit action call and a state exit step.
 */
@Test
public void testLeafStateExitSequence() {
    Statechart sc = _createStatechart("cs");
    Scope scope = _createInterfaceScope("interface", sc);
    VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
    Region r = _createRegion("r", sc);
    State s1 = _createState("s1", r);
    LocalReaction entryAction = _createExitAction(s1);
    _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), (ReactionEffect) entryAction.getEffect());
    ExecutionFlow flow = sequencer.transform(sc);
    ExecutionState _s1 = flow.getStates().get(0);
    assertEquals(s1.getName(), _s1.getSimpleName());
    assertNotNull(_s1.getExitAction());
    assertNotNull(_s1.getExitSequence());
    assertEquals(2, _s1.getExitSequence().getSteps().size());
    assertClass(ExitState.class, _s1.getExitSequence().getSteps().get(0));
    assertCall(_s1.getExitSequence(), 1, _s1.getExitAction());
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) ExecutionScope(org.yakindu.sct.model.sexec.ExecutionScope) Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) StextTestFactory._createInterfaceScope(org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope) StextTestFactory._createVariableDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition) VariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition) FinalState(org.yakindu.sct.model.sgraph.FinalState) SGraphTestFactory._createFinalState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createFinalState) ExitState(org.yakindu.sct.model.sexec.ExitState) SCTTestUtil.findState(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState) SGraphTestFactory._createState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) EnterState(org.yakindu.sct.model.sexec.EnterState) State(org.yakindu.sct.model.sgraph.State) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Statechart(org.yakindu.sct.model.sgraph.Statechart) SGraphTestFactory._createStatechart(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart) Region(org.yakindu.sct.model.sgraph.Region) SGraphTestFactory._createRegion(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion) Test(org.junit.Test)

Example 28 with Scope

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

the class ModelSequencerStateTest method testLeafStateEnterSequence.

/**
 * A leaf state must have a enter sequence. This enter sequence consists of
 * an entry action call and a state enter step.
 */
@SuppressWarnings("unused")
@Test
public void testLeafStateEnterSequence() {
    Statechart sc = _createStatechart("cs");
    Scope scope = _createInterfaceScope("interface", sc);
    VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
    Region r = _createRegion("r", sc);
    State s1 = _createState("s1", r);
    LocalReaction entryAction = _createEntryAction(s1);
    _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), (ReactionEffect) entryAction.getEffect());
    Entry e = _createEntry(EntryKind.INITIAL, null, r);
    Transition t = _createTransition(e, s1);
    ExecutionFlow flow = sequencer.transform(sc);
    ExecutionState _s1 = flow.getStates().get(0);
    assertEquals(s1.getName(), _s1.getSimpleName());
    assertNotNull(_s1.getEntryAction());
    assertNotNull(_s1.getEnterSequences().get(0));
    assertEquals(2, _s1.getEnterSequences().get(0).getSteps().size());
    assertCall(_s1.getEnterSequences().get(0), 0, _s1.getEntryAction());
    assertClass(EnterState.class, _s1.getEnterSequences().get(0).getSteps().get(1));
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) Entry(org.yakindu.sct.model.sgraph.Entry) SGraphTestFactory._createEntry(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry) ExecutionScope(org.yakindu.sct.model.sexec.ExecutionScope) Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) StextTestFactory._createInterfaceScope(org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope) StextTestFactory._createVariableDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition) VariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition) FinalState(org.yakindu.sct.model.sgraph.FinalState) SGraphTestFactory._createFinalState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createFinalState) ExitState(org.yakindu.sct.model.sexec.ExitState) SCTTestUtil.findState(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState) SGraphTestFactory._createState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) EnterState(org.yakindu.sct.model.sexec.EnterState) State(org.yakindu.sct.model.sgraph.State) Transition(org.yakindu.sct.model.sgraph.Transition) SGraphTestFactory._createTransition(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createTransition) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Statechart(org.yakindu.sct.model.sgraph.Statechart) SGraphTestFactory._createStatechart(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart) Region(org.yakindu.sct.model.sgraph.Region) SGraphTestFactory._createRegion(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion) Test(org.junit.Test)

Example 29 with Scope

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

the class ModelSequencerStateTest method testSubStateEntryActionExclusion.

/**
 * entry actions of a substate must not be included in a states entry action
 * list
 */
@Test
public void testSubStateEntryActionExclusion() {
    Statechart sc = _createStatechart("test");
    Scope scope = _createInterfaceScope("interface", sc);
    VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, scope);
    Region r = _createRegion("main", sc);
    // Entry e = _createEntry(EntryKind.INITIAL, null, r);
    State s2 = _createState("s2", r);
    Region s2_r = _createRegion("sub", s2);
    State s2_1 = _createState("s2_1", s2_r);
    LocalReaction entryAction = _createEntryAction(s2_1);
    _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(42), (ReactionEffect) entryAction.getEffect());
    LocalReaction exitAction = _createExitAction(s2_1);
    _createVariableAssignment(v1, AssignmentOperator.ASSIGN, _createValue(43), (ReactionEffect) exitAction.getEffect());
    ExecutionFlow flow = sequencer.transform(sc);
    ExecutionState _s2 = flow.getStates().get(0);
    ExecutionState _s2_1 = flow.getStates().get(1);
    assertEquals(s2.getName(), _s2.getSimpleName());
    assertEquals(s2_1.getName(), _s2_1.getSimpleName());
    assertNull(_s2.getEntryAction());
    assertNotNull(_s2_1.getEntryAction());
    assertNull(_s2.getExitAction());
    assertNotNull(_s2_1.getExitAction());
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) StextTestFactory._createLocalReaction(org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) ExecutionScope(org.yakindu.sct.model.sexec.ExecutionScope) Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) StextTestFactory._createInterfaceScope(org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope) StextTestFactory._createVariableDefinition(org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition) VariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition) FinalState(org.yakindu.sct.model.sgraph.FinalState) SGraphTestFactory._createFinalState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createFinalState) ExitState(org.yakindu.sct.model.sexec.ExitState) SCTTestUtil.findState(org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState) SGraphTestFactory._createState(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState) ExecutionState(org.yakindu.sct.model.sexec.ExecutionState) EnterState(org.yakindu.sct.model.sexec.EnterState) State(org.yakindu.sct.model.sgraph.State) ExecutionFlow(org.yakindu.sct.model.sexec.ExecutionFlow) Statechart(org.yakindu.sct.model.sgraph.Statechart) SGraphTestFactory._createStatechart(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart) Region(org.yakindu.sct.model.sgraph.Region) SGraphTestFactory._createRegion(org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion) Test(org.junit.Test)

Example 30 with Scope

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

the class SCTResourceTest method testStatechartParsing.

@Test
public void testStatechartParsing() {
    Statechart statechart = createStatechart("internal: event Event1");
    assertEquals(0, statechart.getScopes().size());
    res.getContents().add(statechart);
    assertEquals(1, statechart.getScopes().size());
    Scope scope = statechart.getScopes().get(0);
    assertTrue(scope instanceof InternalScope);
    EList<Declaration> declarations = ((InternalScope) scope).getDeclarations();
    Declaration declaration = declarations.get(0);
    assertTrue(declaration instanceof EventDefinition);
    assertEquals("" + res.getSyntaxDiagnostics(), 0, res.getSyntaxDiagnostics().size());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) Declaration(org.yakindu.base.types.Declaration) EventDefinition(org.yakindu.sct.model.stext.stext.EventDefinition) Test(org.junit.Test)

Aggregations

Scope (org.yakindu.sct.model.sgraph.Scope)45 Test (org.junit.Test)27 InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)27 Statechart (org.yakindu.sct.model.sgraph.Statechart)25 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)18 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)16 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)16 Region (org.yakindu.sct.model.sgraph.Region)16 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)16 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)16 InternalScope (org.yakindu.sct.model.stext.stext.InternalScope)16 LocalReaction (org.yakindu.sct.model.stext.stext.LocalReaction)16 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)16 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)16 State (org.yakindu.sct.model.sgraph.State)14 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)14 StextTestFactory._createLocalReaction (org.yakindu.sct.model.stext.test.util.StextTestFactory._createLocalReaction)11 ExecutionScope (org.yakindu.sct.model.sexec.ExecutionScope)9 Entry (org.yakindu.sct.model.sgraph.Entry)9 FinalState (org.yakindu.sct.model.sgraph.FinalState)9