|
@@ -16,6 +16,7 @@ import java.util.List;
|
|
|
import org.eclipse.emf.common.util.EList;
|
|
|
import org.eclipse.emf.ecore.EObject;
|
|
|
import org.eclipse.emf.ecore.EReference;
|
|
|
+import org.eclipse.emf.ecore.util.EcoreUtil;
|
|
|
import org.eclipse.xtext.EcoreUtil2;
|
|
|
import org.eclipse.xtext.naming.IQualifiedNameProvider;
|
|
|
import org.eclipse.xtext.naming.QualifiedName;
|
|
@@ -43,10 +44,11 @@ import org.yakindu.sct.model.sgraph.ScopedElement;
|
|
|
import org.yakindu.sct.model.sgraph.SpecificationElement;
|
|
|
import org.yakindu.sct.model.sgraph.State;
|
|
|
import org.yakindu.sct.model.sgraph.Statechart;
|
|
|
-import org.yakindu.sct.model.stext.extensions.ISCTExtensions;
|
|
|
+import org.yakindu.sct.model.stext.extensions.STextExtensions;
|
|
|
import org.yakindu.sct.model.stext.scoping.ContextPredicateProvider.EmptyPredicate;
|
|
|
import org.yakindu.sct.model.stext.stext.InterfaceScope;
|
|
|
import org.yakindu.sct.model.stext.stext.InternalScope;
|
|
|
+import org.yakindu.sct.model.stext.stext.StatechartSpecification;
|
|
|
|
|
|
import com.google.common.base.Predicate;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -71,10 +73,10 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
|
|
|
private ContextPredicateProvider predicateProvider;
|
|
|
|
|
|
@Inject
|
|
|
- protected ISCTExtensions utils;
|
|
|
+ protected STextExtensions utils;
|
|
|
|
|
|
public IScope scope_ActiveStateReferenceExpression_value(EObject context, EReference reference) {
|
|
|
- Statechart statechart = utils.getStatechart(context);
|
|
|
+ Statechart statechart = getStatechart(context);
|
|
|
if (statechart == null)
|
|
|
return IScope.NULLSCOPE;
|
|
|
List<State> allStates = EcoreUtil2.getAllContentsOfType(statechart, State.class);
|
|
@@ -187,7 +189,7 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
|
|
|
*/
|
|
|
protected IScope getNamedTopLevelScope(final EObject context, EReference reference) {
|
|
|
List<EObject> scopeCandidates = Lists.newArrayList();
|
|
|
- ScopedElement scopedElement = utils.getScopedElement(context);
|
|
|
+ ScopedElement scopedElement = getScopedElement(context);
|
|
|
if (scopedElement == null)
|
|
|
return IScope.NULLSCOPE;
|
|
|
EList<Scope> scopes = scopedElement.getScopes();
|
|
@@ -207,7 +209,7 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
|
|
|
*/
|
|
|
protected IScope getUnnamedTopLevelScope(final EObject context, EReference reference) {
|
|
|
List<EObject> scopeCandidates = Lists.newArrayList();
|
|
|
- ScopedElement scopedElement = utils.getScopedElement(context);
|
|
|
+ ScopedElement scopedElement = getScopedElement(context);
|
|
|
if (scopedElement == null)
|
|
|
return IScope.NULLSCOPE;
|
|
|
EList<Scope> scopes = scopedElement.getScopes();
|
|
@@ -226,6 +228,16 @@ public class STextScopeProvider extends ExpressionsScopeProvider {
|
|
|
IScope scope = getDelegate().getScope(context, reference);
|
|
|
return Scopes.scopeFor(scopeCandidates, scope);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ protected ScopedElement getScopedElement(EObject context) {
|
|
|
+ ScopedElement scopedElement = EcoreUtil2.getContainerOfType(context, ScopedElement.class);
|
|
|
+ if (EcoreUtil.getRootContainer(context) instanceof StatechartSpecification && scopedElement != null)
|
|
|
+ return scopedElement;
|
|
|
+ return getStatechart(context);
|
|
|
+ }
|
|
|
+
|
|
|
+ protected Statechart getStatechart(EObject context) {
|
|
|
+ return utils.getStatechart(context);
|
|
|
+ }
|
|
|
|
|
|
}
|