Search in sources :

Example 36 with Scope

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

the class STextJavaValidatorTest method checkOptionalArgumentsAreLast.

@Test
public void checkOptionalArgumentsAreLast() {
    Scope scope = (Scope) super.parseExpression("internal: ", InternalScope.class.getSimpleName());
    OperationDefinition op = StextTestFactory._createOperation("op", scope);
    tester.validate(scope).assertOK();
    // optional parameter last => no error
    op.getParameters().add(typesTestFactory.createParameter("p1", ITypeSystem.INTEGER, false));
    op.getParameters().add(typesTestFactory.createParameter("p2", ITypeSystem.INTEGER, true));
    tester.validate(op).assertOK();
    // optional parameter not last anymore => error
    op.getParameters().add(typesTestFactory.createParameter("p3", ITypeSystem.INTEGER, false));
    tester.validate(op).assertError(ERROR_OPTIONAL_MUST_BE_LAST_CODE);
}
Also used : 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) OperationDefinition(org.yakindu.sct.model.stext.stext.OperationDefinition) Test(org.junit.Test)

Example 37 with Scope

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

the class STextJavaValidatorTest method checkImportExists.

@Test
public void checkImportExists() {
    Scope context = (Scope) parseExpression("import: \"does.not.exist\"", ImportScope.class.getSimpleName());
    AssertableDiagnostics validationResult = tester.validate(context);
    validationResult.assertErrorContains(String.format(STextValidationMessages.IMPORT_NOT_RESOLVED_MSG, "does.not.exist"));
}
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)

Example 38 with Scope

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

the class StextTestFactory method _createLocalReaction.

public static LocalReaction _createLocalReaction(State parent, EventSpec triggerEvent) {
    LocalReaction reaction = _createLocalReaction(triggerEvent);
    Scope scope = getOrCreateSimpleScope(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 39 with Scope

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

the class RenameRefactoringTest method testRenameVariable.

@Test
public void testRenameVariable() {
    Statechart initial = models.loadStatechartFromResource(RENAMING + INITIAL_STATECHART);
    // get element to rename
    Property someVariable = null;
    EList<Scope> scopes = initial.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            InterfaceScope iScope = (InterfaceScope) scope;
            someVariable = iScope.getVariables().get(0);
        }
    }
    Statechart expected = models.loadStatechartFromResource(RENAMING + "AfterRenamingVariable.sct");
    testRenaming(initial, expected, someVariable, "someNewVariableName");
}
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) Property(org.yakindu.base.types.Property) Test(org.junit.Test) RefactoringTest(org.yakindu.sct.refactoring.refactor.RefactoringTest)

Example 40 with Scope

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

the class FoldOutgoingActionsRefactoring method createExitBlock.

private EList<Expression> createExitBlock(List<Expression> actionsToAdd) {
    EList<Expression> actionsOriginal;
    LocalReaction newLocalReaction = StextFactory.eINSTANCE.createLocalReaction();
    ReactionTrigger newReactionTrigger = StextFactory.eINSTANCE.createReactionTrigger();
    ExitEvent exitEvent = StextFactory.eINSTANCE.createExitEvent();
    ReactionEffect newReactionEffect = StextFactory.eINSTANCE.createReactionEffect();
    newLocalReaction.setTrigger(newReactionTrigger);
    newReactionTrigger.getTriggers().add(exitEvent);
    newReactionEffect.getActions().addAll(actionsToAdd);
    newLocalReaction.setEffect(newReactionEffect);
    Scope scope = getContextObject().getScopes().get(0);
    scope.getReactions().add(newLocalReaction);
    actionsOriginal = newReactionEffect.getActions();
    return actionsOriginal;
}
Also used : LocalReaction(org.yakindu.sct.model.stext.stext.LocalReaction) Scope(org.yakindu.sct.model.sgraph.Scope) Expression(org.yakindu.base.expressions.expressions.Expression) ReactionTrigger(org.yakindu.sct.model.stext.stext.ReactionTrigger) ReactionEffect(org.yakindu.sct.model.stext.stext.ReactionEffect) ExitEvent(org.yakindu.sct.model.stext.stext.ExitEvent)

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