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);
}
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"));
}
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;
}
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");
}
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;
}
Aggregations