Search in sources :

Example 21 with Scope

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

the class StextTestFactory method getOrCreateSimpleScope.

public static SimpleScope getOrCreateSimpleScope(State state) {
    for (Scope scope : state.getScopes()) {
        if (scope instanceof SimpleScope) {
            return (SimpleScope) scope;
        }
    }
    SimpleScope scope = StextFactory.eINSTANCE.createSimpleScope();
    state.getScopes().add(scope);
    return scope;
}
Also used : InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) SimpleScope(org.yakindu.sct.model.stext.stext.SimpleScope) Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) SimpleScope(org.yakindu.sct.model.stext.stext.SimpleScope)

Example 22 with Scope

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

the class StextTestFactory method _createLocalReaction.

public static LocalReaction _createLocalReaction(Statechart parent, EventSpec triggerEvent) {
    LocalReaction reaction = _createLocalReaction(triggerEvent);
    Scope scope = getOrCreateInternalScope(parent);
    scope.getReactions().add(reaction);
    return reaction;
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) SimpleScope(org.yakindu.sct.model.stext.stext.SimpleScope) Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope)

Example 23 with Scope

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

the class RenameRefactoringTest method testRenameMultiStatement.

@Test
public void testRenameMultiStatement() {
    Statechart initial = models.loadStatechartFromResource(RENAMING + "beforeMultiStatement.sct");
    Statechart expected = models.loadStatechartFromResource(RENAMING + "AfterMultiStatement.sct");
    // get element to rename
    InterfaceScope someInterface = null;
    EList<Scope> scopes = initial.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            someInterface = (InterfaceScope) scope;
        }
    }
    testRenaming(initial, expected, someInterface.getVariables().get(0), "y");
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Test(org.junit.Test) RefactoringTest(org.yakindu.sct.refactoring.refactor.RefactoringTest)

Example 24 with Scope

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

the class RenameRefactoringTest method testRenameEvent.

@Test
public void testRenameEvent() {
    Statechart initial = models.loadStatechartFromResource(RENAMING + INITIAL_STATECHART);
    Statechart expected = models.loadStatechartFromResource(RENAMING + "AfterRenamingEvent.sct");
    // get element to rename
    Event someEvent1 = null;
    EList<Scope> scopes = initial.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            InterfaceScope iScope = (InterfaceScope) scope;
            for (Event event : iScope.getEvents()) {
                if (event.getName().equals("someEvent1")) {
                    someEvent1 = event;
                }
            }
        }
    }
    testRenaming(initial, expected, someEvent1, "someNewEventName");
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) Event(org.yakindu.base.types.Event) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Test(org.junit.Test) RefactoringTest(org.yakindu.sct.refactoring.refactor.RefactoringTest)

Example 25 with Scope

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

the class STextJavaValidatorTest method checkVariableDefinition.

/**
 * @see STextJavaValidator#checkVariableDefinition(org.yakindu.sct.model.stext.stext.VariableDefinition)
 */
@Test
public void checkVariableDefinition() {
    Scope context = (Scope) parseExpression("interface if : var i : void", InterfaceScope.class.getSimpleName());
    AssertableDiagnostics validationResult = tester.validate(context);
    validationResult.assertErrorContains(STextTypeInferrer.VARIABLE_VOID_TYPE);
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) Scope(org.yakindu.sct.model.sgraph.Scope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) ImportScope(org.yakindu.sct.model.stext.stext.ImportScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) 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