use of org.yakindu.sct.model.stext.stext.InterfaceScope in project statecharts by Yakindu.
the class STextProposalProvider method completeKeyword.
/**
* Validates if a keyword should be viewed by the proposal view.
*
* Builds dependent on the ContentAssistContext a list with keywords which
* shouldn't be displayed by the proposal view.
*/
@Override
public void completeKeyword(Keyword keyword, ContentAssistContext contentAssistContext, ICompletionProposalAcceptor acceptor) {
List<Keyword> suppressKeywords = new ArrayList<Keyword>();
EObject rootModel = contentAssistContext.getRootModel();
if (rootModel instanceof TransitionSpecification) {
suppressKeywords(suppressKeywords, (TransitionSpecification) rootModel);
} else if (rootModel instanceof SimpleScope) {
suppressKeywords(suppressKeywords, (SimpleScope) rootModel);
} else if (rootModel instanceof StatechartSpecification) {
suppressKeywords(suppressKeywords, (StatechartSpecification) rootModel);
}
EObject currentModel = contentAssistContext.getCurrentModel();
if (currentModel instanceof InterfaceScope) {
suppressKeywords(suppressKeywords, (InterfaceScope) currentModel);
}
if (currentModel instanceof FeatureCall) {
suppressKeywords(suppressKeywords, (FeatureCall) currentModel);
}
if (currentModel instanceof ElementReferenceExpression) {
suppressKeywords(suppressKeywords, (ElementReferenceExpression) currentModel);
}
if (currentModel instanceof InternalScope) {
suppressKeywords(suppressKeywords, (InternalScope) currentModel);
}
if (!suppressKeywords.contains(keyword)) {
super.completeKeyword(keyword, contentAssistContext, new AcceptorDelegate(acceptor));
}
}
use of org.yakindu.sct.model.stext.stext.InterfaceScope in project statecharts by Yakindu.
the class StextNameProvider method qualifiedName.
public QualifiedName qualifiedName(Property ele) {
QualifiedName name = null;
if (!Strings.isEmpty(ele.getName())) {
name = nameConverter.toQualifiedName(ele.getName());
}
InterfaceScope scope = EcoreUtil2.getContainerOfType(ele, InterfaceScope.class);
if (scope != null) {
if (!Strings.isEmpty(scope.getName())) {
QualifiedName namespace = nameConverter.toQualifiedName(scope.getName());
name = namespace.append(name);
}
}
return name;
}
use of org.yakindu.sct.model.stext.stext.InterfaceScope in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testSiblingRegionEntryOnComposite.
/**
* For all and-states that a on the entry path of a transition the enter
* sequences for all orthogonal parts must be called.
*/
@Test
public void testSiblingRegionEntryOnComposite() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
{
Region r2 = _createRegion("r2", s1);
{
Entry r2_entry = _createEntry(EntryKind.INITIAL, null, r2);
State s2 = _createState("s2", r2);
_createTransition(r2_entry, s2);
}
Region r3 = _createRegion("r3", s1);
{
Entry r3_entry = _createEntry(EntryKind.INITIAL, null, r3);
State s3 = _createState("s3", r3);
{
Region r3a = _createRegion("r3a", s3);
{
Entry r3a_entry = _createEntry(EntryKind.INITIAL, null, r3a);
State s3a = _createState("s3a", r3a);
_createTransition(r3a_entry, s3a);
}
Region r3b = _createRegion("r3b", s3);
{
Entry r3b_entry = _createEntry(EntryKind.INITIAL, null, r3b);
State s3b = _createState("s3b", r3b);
_createTransition(r3b_entry, s3b);
}
Region r3c = _createRegion("r3c", s3);
{
Entry r3c_entry = _createEntry(EntryKind.INITIAL, null, r3c);
State s3c = _createState("s3c", r3c);
_createTransition(r3c_entry, s3c);
}
}
_createEntryAssignment(v1, s3, 42);
_createTransition(r3_entry, s3);
}
Region r4 = _createRegion("r4", s1);
{
Entry r4_entry = _createEntry(EntryKind.INITIAL, null, r4);
State s4 = _createState("s4", r4);
_createTransition(r4_entry, s4);
}
}
_createTransition(r_entry, s1);
State s5 = _createState("s5", r);
_createTransition(s5, findState(sc, "s3b"));
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s1.r2.s2", _s2.getName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("sc.r.s1.r3.s3", _s3.getName());
ExecutionState _s3a = flow.getStates().get(3);
assertEquals("sc.r.s1.r3.s3.r3a.s3a", _s3a.getName());
ExecutionState _s3b = flow.getStates().get(4);
assertEquals("sc.r.s1.r3.s3.r3b.s3b", _s3b.getName());
ExecutionState _s3c = flow.getStates().get(5);
assertEquals("sc.r.s1.r3.s3.r3c.s3c", _s3c.getName());
ExecutionState _s4 = flow.getStates().get(6);
assertEquals("sc.r.s1.r4.s4", _s4.getName());
ExecutionState _s5 = flow.getStates().get(7);
assertEquals("sc.r.s5", _s5.getName());
Reaction _t = _s5.getReactions().get(0);
assertTrue(_t.isTransition());
Sequence _effect = (Sequence) _t.getEffect();
assertEquals("wrong sequence: " + stepListAsString(_effect), 7, _effect.getSteps().size());
assertCall(_effect, 0, _s5.getExitSequence());
assertCall(_effect, 1, _s2.getSuperScope().getEnterSequences().get(0));
assertCall(_s2.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(1).getReactSequence());
assertCall(_effect, 2, _s3.getEntryAction());
assertCall(_effect, 3, _s3a.getSuperScope().getEnterSequences().get(0));
assertCall(_s3a.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(3).getReactSequence());
assertCall(_effect, 4, _s3b.getEnterSequences().get(0));
assertCall(_effect, 5, _s3c.getSuperScope().getEnterSequences().get(0));
assertCall(_s3c.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(5).getReactSequence());
assertCall(_effect, 6, _s4.getSuperScope().getEnterSequences().get(0));
assertCall(_s4.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(6).getReactSequence());
}
use of org.yakindu.sct.model.stext.stext.InterfaceScope in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testSourceSiblingExitExclusion.
/**
* A transition to a state with orthogonal siblings that comes out of a non
* orthogonal sibling state must exclude the source state sibling exit or
* enter behavior.
*/
@SuppressWarnings("unused")
@Test
public void testSourceSiblingExitExclusion() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
{
Region r2 = _createRegion("r2", s1);
{
Entry r2_entry = _createEntry(EntryKind.INITIAL, null, r2);
State s2 = _createState("s2", r2);
_createTransition(r2_entry, s2);
}
Region r3 = _createRegion("r3", s1);
{
Entry r3_entry = _createEntry(EntryKind.INITIAL, null, r3);
State s3 = _createState("s3", r3);
{
Region r3a = _createRegion("r3a", s3);
{
Entry r3a_entry = _createEntry(EntryKind.INITIAL, null, r3a);
State s3a = _createState("s3a", r3a);
_createTransition(r3a_entry, s3a);
}
Region r3b = _createRegion("r3b", s3);
{
Entry r3b_entry = _createEntry(EntryKind.INITIAL, null, r3b);
State s3b = _createState("s3b", r3b);
State s3b2 = _createState("s3b2", r3b);
_createTransition(r3b_entry, s3b);
}
Region r3c = _createRegion("r3c", s3);
{
Entry r3c_entry = _createEntry(EntryKind.INITIAL, null, r3c);
State s3c = _createState("s3c", r3c);
_createTransition(r3c_entry, s3c);
}
}
State s3z = _createState("s3z", r3);
_createEntryAssignment(v1, s3, 42);
_createTransition(r3_entry, s3);
}
Region r4 = _createRegion("r4", s1);
{
Entry r4_entry = _createEntry(EntryKind.INITIAL, null, r4);
State s4 = _createState("s4", r4);
_createTransition(r4_entry, s4);
}
}
_createTransition(r_entry, s1);
State s5 = _createState("s5", r);
_createTransition(findState(sc, "s3b2"), findState(sc, "s3z"));
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s1.r2.s2", _s2.getName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("sc.r.s1.r3.s3", _s3.getName());
ExecutionState _s3a = flow.getStates().get(3);
assertEquals("sc.r.s1.r3.s3.r3a.s3a", _s3a.getName());
ExecutionState _s3b = flow.getStates().get(4);
assertEquals("sc.r.s1.r3.s3.r3b.s3b", _s3b.getName());
ExecutionState _s3b2 = flow.getStates().get(5);
assertEquals("sc.r.s1.r3.s3.r3b.s3b2", _s3b2.getName());
ExecutionState _s3c = flow.getStates().get(6);
assertEquals("sc.r.s1.r3.s3.r3c.s3c", _s3c.getName());
ExecutionState _s3z = flow.getStates().get(7);
assertEquals("sc.r.s1.r3.s3z", _s3z.getName());
ExecutionState _s4 = flow.getStates().get(8);
assertEquals("sc.r.s1.r4.s4", _s4.getName());
ExecutionState _s5 = flow.getStates().get(9);
assertEquals("sc.r.s5", _s5.getName());
Reaction _t = _s3b2.getReactions().get(0);
assertTrue(_t.isTransition());
Sequence _effect = (Sequence) _t.getEffect();
assertEquals("wrong steps: " + stepListAsString(_effect), 2, _effect.getSteps().size());
assertedOrder(_effect, Lists.newArrayList(_s3a, _s3b2, _s3c), Lists.newArrayList(new StepLeaf(_s3a.getExitSequence()), new StepLeaf(_s3b2.getExitSequence()), new StepLeaf(_s3c.getExitSequence()), new StepLeaf(_s3z.getEnterSequences().get(0))));
assertCall(_effect, 1, _s3z.getEnterSequences().get(0));
}
use of org.yakindu.sct.model.stext.stext.InterfaceScope in project statecharts by Yakindu.
the class ModelSequencerOrthogonalityTest method testSiblingRegionEntryOnTargetState.
/**
* The transition to a leaf state with orthogonal siblings must invoke the
* entry sequence of the orthogonal sibling regions.
*/
@SuppressWarnings("unused")
@Test
public void testSiblingRegionEntryOnTargetState() {
Statechart sc = _createStatechart("sc");
{
InterfaceScope s_scope = _createInterfaceScope("Interface", sc);
VariableDefinition v1 = _createVariableDefinition("v1", TYPE_INTEGER, s_scope);
Region r = _createRegion("r", sc);
{
Entry r_entry = _createEntry(EntryKind.INITIAL, null, r);
State s1 = _createState("s1", r);
{
Region r2 = _createRegion("r2", s1);
{
Entry r2_entry = _createEntry(EntryKind.INITIAL, null, r2);
State s2 = _createState("s2", r2);
_createTransition(r2_entry, s2);
}
Region r3 = _createRegion("r3", s1);
{
Entry r3_entry = _createEntry(EntryKind.INITIAL, null, r3);
State s3 = _createState("s3", r3);
_createTransition(r3_entry, s3);
}
Region r4 = _createRegion("r4", s1);
{
Entry r4_entry = _createEntry(EntryKind.INITIAL, null, r4);
State s4 = _createState("s4", r4);
_createTransition(r4_entry, s4);
}
}
_createTransition(r_entry, s1);
State s5 = _createState("s5", r);
_createTransition(s5, findState(sc, "s3"));
}
}
ExecutionFlow flow = sequencer.transform(sc);
ExecutionState _s2 = flow.getStates().get(1);
assertEquals("sc.r.s1.r2.s2", _s2.getName());
ExecutionState _s3 = flow.getStates().get(2);
assertEquals("sc.r.s1.r3.s3", _s3.getName());
ExecutionState _s4 = flow.getStates().get(3);
assertEquals("sc.r.s1.r4.s4", _s4.getName());
ExecutionState _s5 = flow.getStates().get(4);
assertEquals("sc.r.s5", _s5.getName());
Reaction _t = _s5.getReactions().get(0);
assertTrue(_t.isTransition());
Sequence _effect = (Sequence) _t.getEffect();
assertEquals("wrong sequence: " + stepListAsString(_effect), 4, _effect.getSteps().size());
assertCall(_effect, 0, _s5.getExitSequence());
assertCall(_effect, 1, _s2.getSuperScope().getEnterSequences().get(0));
assertCall(_s2.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(1).getReactSequence());
assertCall(_effect, 2, _s3.getEnterSequences().get(0));
assertCall(_effect, 3, _s4.getSuperScope().getEnterSequences().get(0));
assertCall(_s4.getSuperScope().getEnterSequences().get(0), 0, flow.getNodes().get(3).getReactSequence());
}
Aggregations