Search in sources :

Example 41 with InterfaceScope

use of org.yakindu.sct.model.stext.stext.InterfaceScope in project statecharts by Yakindu.

the class RenameRefactoringTest method testRenameInterface.

@Test
public void testRenameInterface() {
    Statechart initial = models.loadStatechartFromResource(RENAMING + INITIAL_STATECHART);
    Statechart expected = models.loadStatechartFromResource(RENAMING + "AfterRenamingInterface.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, "someNewInterfaceName");
}
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 42 with InterfaceScope

use of org.yakindu.sct.model.stext.stext.InterfaceScope 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 43 with InterfaceScope

use of org.yakindu.sct.model.stext.stext.InterfaceScope 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 44 with InterfaceScope

use of org.yakindu.sct.model.stext.stext.InterfaceScope 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 45 with InterfaceScope

use of org.yakindu.sct.model.stext.stext.InterfaceScope in project statecharts by Yakindu.

the class StextNameProvider method qualifiedName.

public QualifiedName qualifiedName(Event 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;
}
Also used : QualifiedName(org.eclipse.xtext.naming.QualifiedName) InterfaceScope(org.yakindu.sct.model.stext.stext.InterfaceScope)

Aggregations

InterfaceScope (org.yakindu.sct.model.stext.stext.InterfaceScope)45 Statechart (org.yakindu.sct.model.sgraph.Statechart)38 Test (org.junit.Test)37 StextTestFactory._createInterfaceScope (org.yakindu.sct.model.stext.test.util.StextTestFactory._createInterfaceScope)34 Region (org.yakindu.sct.model.sgraph.Region)32 State (org.yakindu.sct.model.sgraph.State)32 SGraphTestFactory._createRegion (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createRegion)32 SGraphTestFactory._createState (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createState)32 SGraphTestFactory._createStatechart (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createStatechart)32 ExecutionFlow (org.yakindu.sct.model.sexec.ExecutionFlow)31 VariableDefinition (org.yakindu.sct.model.stext.stext.VariableDefinition)31 StextTestFactory._createVariableDefinition (org.yakindu.sct.model.stext.test.util.StextTestFactory._createVariableDefinition)31 ExecutionState (org.yakindu.sct.model.sexec.ExecutionState)28 Sequence (org.yakindu.sct.model.sexec.Sequence)26 SCTTestUtil.findState (org.yakindu.sct.model.sexec.transformation.test.SCTTestUtil.findState)20 Reaction (org.yakindu.sct.model.sexec.Reaction)17 Entry (org.yakindu.sct.model.sgraph.Entry)17 SGraphTestFactory._createEntry (org.yakindu.sct.model.sgraph.test.util.SGraphTestFactory._createEntry)17 EnterState (org.yakindu.sct.model.sexec.EnterState)13 Step (org.yakindu.sct.model.sexec.Step)10