|
@@ -20,17 +20,13 @@ 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.IQualifiedNameConverter;
|
|
|
-import org.eclipse.xtext.naming.QualifiedName;
|
|
|
import org.eclipse.xtext.resource.IEObjectDescription;
|
|
|
import org.eclipse.xtext.scoping.IScope;
|
|
|
import org.eclipse.xtext.scoping.Scopes;
|
|
|
import org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider;
|
|
|
import org.eclipse.xtext.scoping.impl.FilteringScope;
|
|
|
-import org.eclipse.xtext.scoping.impl.ImportNormalizer;
|
|
|
import org.eclipse.xtext.scoping.impl.SimpleScope;
|
|
|
import org.eclipse.xtext.util.PolymorphicDispatcher.ErrorHandler;
|
|
|
-import org.eclipse.xtext.util.Strings;
|
|
|
import org.yakindu.base.expressions.expressions.ElementReferenceExpression;
|
|
|
import org.yakindu.base.expressions.expressions.Expression;
|
|
|
import org.yakindu.base.expressions.expressions.FeatureCall;
|
|
@@ -45,7 +41,6 @@ import org.yakindu.sct.model.sgraph.SGraphPackage;
|
|
|
import org.yakindu.sct.model.sgraph.Scope;
|
|
|
import org.yakindu.sct.model.sgraph.Statechart;
|
|
|
import org.yakindu.sct.model.stext.scoping.ContextPredicateProvider.EmptyPredicate;
|
|
|
-import org.yakindu.sct.model.stext.stext.ImportScope;
|
|
|
import org.yakindu.sct.model.stext.stext.InterfaceScope;
|
|
|
import org.yakindu.sct.model.stext.stext.InternalScope;
|
|
|
|
|
@@ -84,7 +79,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public IScope getScope(EObject context, EReference reference) {
|
|
|
try {
|
|
@@ -107,10 +102,7 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
|
|
|
* variable declarations.
|
|
|
*/
|
|
|
public IScope scope_TypedElement_type(final EObject context, EReference reference) {
|
|
|
- Statechart statechart = getStatechart(context);
|
|
|
- EList<Scope> scopes = statechart.getScopes();
|
|
|
- IScope scope = retrieveImportScope(context, reference, scopes);
|
|
|
-
|
|
|
+ IScope scope = getDelegate().getScope(context, reference);
|
|
|
Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
|
|
|
return new FilteringScope(scope, predicate);
|
|
|
}
|
|
@@ -219,27 +211,6 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
|
|
|
return Scopes.scopeFor(scopeCandidates);
|
|
|
}
|
|
|
|
|
|
- @Inject
|
|
|
- private IQualifiedNameConverter qualifiedNameConverter;
|
|
|
-
|
|
|
- protected ImportNormalizer createImportedNamespaceResolver(final String namespace, boolean ignoreCase) {
|
|
|
- if (Strings.isEmpty(namespace))
|
|
|
- return null;
|
|
|
- QualifiedName importedNamespace = qualifiedNameConverter.toQualifiedName(namespace);
|
|
|
- if (importedNamespace == null || importedNamespace.getSegmentCount() < 1) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- boolean hasWildCard = ignoreCase ? importedNamespace.getLastSegment().equalsIgnoreCase("*")
|
|
|
- : importedNamespace.getLastSegment().equals("*");
|
|
|
- if (hasWildCard) {
|
|
|
- if (importedNamespace.getSegmentCount() <= 1)
|
|
|
- return null;
|
|
|
- return new ImportNormalizer(importedNamespace.skipLast(1), true, ignoreCase);
|
|
|
- } else {
|
|
|
- return new ImportNormalizer(importedNamespace, false, ignoreCase);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Returns a scope with all toplevel declarations of unnamed scope
|
|
|
*/
|
|
@@ -261,25 +232,8 @@ public class STextScopeProvider extends AbstractDeclarativeScopeProvider {
|
|
|
}
|
|
|
|
|
|
// Add import scope
|
|
|
- IScope scope = retrieveImportScope(context, reference, scopes);
|
|
|
- return Scopes.scopeFor(scopeCandidates, scope);
|
|
|
- }
|
|
|
-
|
|
|
- private IScope retrieveImportScope(final EObject context, EReference reference, EList<Scope> scopes) {
|
|
|
IScope scope = getDelegate().getScope(context, reference);
|
|
|
- Iterable<ImportScope> filter = Iterables.filter(scopes, ImportScope.class);
|
|
|
- if (Iterables.size(filter) > 0) {
|
|
|
- List<ImportNormalizer> normalizers = Lists.newArrayList();
|
|
|
- for (ImportScope importScope : filter) {
|
|
|
- EList<org.yakindu.sct.model.stext.stext.Import> imports = importScope.getImports();
|
|
|
- for (org.yakindu.sct.model.stext.stext.Import import1 : imports) {
|
|
|
- normalizers.add(createImportedNamespaceResolver(import1.getImportedNamespace(), false));
|
|
|
- }
|
|
|
- }
|
|
|
- scope = new org.eclipse.xtext.scoping.impl.ImportScope(normalizers, scope, null,
|
|
|
- reference.getEReferenceType(), false);
|
|
|
- }
|
|
|
- return scope;
|
|
|
+ return Scopes.scopeFor(scopeCandidates, scope);
|
|
|
}
|
|
|
|
|
|
/**
|