Search in sources :

Example 41 with Scope

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

the class STextScopeProvider method getNamedTopLevelScope.

/**
 * Returns the toplevel scope
 */
protected IScope getNamedTopLevelScope(final EObject context, EReference reference) {
    List<EObject> scopeCandidates = Lists.newArrayList();
    Statechart statechart = getStatechart(context);
    if (statechart == null)
        return IScope.NULLSCOPE;
    EList<Scope> scopes = statechart.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            String name = ((InterfaceScope) scope).getName();
            if (name != null && name.trim().length() > 0) {
                scopeCandidates.add(scope);
            }
        }
    }
    return Scopes.scopeFor(scopeCandidates);
}
Also used : FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Scope(org.yakindu.sct.model.sgraph.Scope) IScope(org.eclipse.xtext.scoping.IScope) SimpleScope(org.eclipse.xtext.scoping.impl.SimpleScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) ImportScope(org.eclipse.xtext.scoping.impl.ImportScope) EObject(org.eclipse.emf.ecore.EObject) Statechart(org.yakindu.sct.model.sgraph.Statechart) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope)

Example 42 with Scope

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

the class STextScopeProvider method getUnnamedTopLevelScope.

/**
 * Returns a scope with all toplevel declarations of unnamed scope
 */
protected IScope getUnnamedTopLevelScope(final EObject context, EReference reference) {
    List<EObject> scopeCandidates = Lists.newArrayList();
    Statechart statechart = getStatechart(context);
    if (statechart == null)
        return IScope.NULLSCOPE;
    EList<Scope> scopes = statechart.getScopes();
    for (Scope scope : scopes) {
        if (scope instanceof InterfaceScope) {
            String name = ((InterfaceScope) scope).getName();
            if (name == null || name.trim().length() == 0) {
                scopeCandidates.addAll(scope.getDeclarations());
            }
        } else if (scope instanceof InternalScope) {
            scopeCandidates.addAll(scope.getDeclarations());
        }
    }
    // Add import scope
    IScope scope = getDelegate().getScope(context, reference);
    return Scopes.scopeFor(scopeCandidates, scope);
}
Also used : FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) Scope(org.yakindu.sct.model.sgraph.Scope) IScope(org.eclipse.xtext.scoping.IScope) SimpleScope(org.eclipse.xtext.scoping.impl.SimpleScope) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) ImportScope(org.eclipse.xtext.scoping.impl.ImportScope) EObject(org.eclipse.emf.ecore.EObject) InternalScope(org.yakindu.sct.model.stext.stext.InternalScope) Statechart(org.yakindu.sct.model.sgraph.Statechart) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope) IScope(org.eclipse.xtext.scoping.IScope)

Example 43 with Scope

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

the class StateSpecificationImpl method basicSetScope.

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public NotificationChain basicSetScope(Scope newScope, NotificationChain msgs) {
    Scope oldScope = scope;
    scope = newScope;
    if (eNotificationRequired()) {
        ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StextPackage.STATE_SPECIFICATION__SCOPE, oldScope, newScope);
        if (msgs == null)
            msgs = notification;
        else
            msgs.add(notification);
    }
    return msgs;
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) ENotificationImpl(org.eclipse.emf.ecore.impl.ENotificationImpl)

Example 44 with Scope

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

the class StextResource method serializeState.

protected void serializeState(State state) {
    if (state.getScopes().size() != 1)
        return;
    Scope scope = state.getScopes().get(0);
    EList<Reaction> reactions = scope.getReactions();
    StringBuilder builder = new StringBuilder();
    for (Reaction reaction : reactions) {
        if (builder.length() > 0)
            builder.append(NEW_LINE);
        builder.append(serializeReaction(reaction));
    }
    state.setSpecification(builder.toString());
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) Reaction(org.yakindu.sct.model.sgraph.Reaction) TransitionReaction(org.yakindu.sct.model.stext.stext.TransitionReaction)

Example 45 with Scope

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

the class StatechartImpl method getLocalReactions.

/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
public EList<Reaction> getLocalReactions() {
    EList<Reaction> result = new BasicInternalEList<Reaction>(Reaction.class);
    EList<Scope> scopes = getScopes();
    for (Scope scope : scopes) {
        result.addAll(scope.getReactions());
    }
    return result;
}
Also used : Scope(org.yakindu.sct.model.sgraph.Scope) BasicInternalEList(org.eclipse.emf.ecore.util.BasicInternalEList) Reaction(org.yakindu.sct.model.sgraph.Reaction)

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