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