blob: 3dad34931301d13b2b45017bd550d3b75918f899 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
package rba.tool.editor.scoping
import java.util.Iterator
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.EReference
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.util.EcoreUtil
import org.eclipse.xtext.resource.IEObjectDescription
import org.eclipse.xtext.scoping.Scopes
import org.eclipse.xtext.scoping.impl.ImportedNamespaceAwareLocalScopeProvider
import org.eclipse.xtext.scoping.impl.MultimapBasedSelectable
import org.eclipse.xtext.xbase.lib.Functions.Function1
import rba.core.RBACorePackage
import rba.core.Variable
class RBAModelImportedNamespaceAwareLocalScopeProvider extends ImportedNamespaceAwareLocalScopeProvider {
private Function1<? super IEObjectDescription, Boolean> variableFilter = [ description |
description.EClass !== RBACorePackage.Literals.VARIABLE
];
override protected getResourceScope(Resource res, EReference reference) {
val context = res.getContents().get(0);
var globalScope = getGlobalScope(res, reference, variableFilter);
val normalizers = getImplicitImports(isIgnoreCase(reference));
if(!normalizers.isEmpty()) {
globalScope = createImportScope(globalScope, normalizers, null, reference.getEReferenceType(), isIgnoreCase(reference));
}
return getResourceScope(globalScope, context, reference);
}
override protected internalGetAllDescriptions(Resource resource) {
val allContents = new Iterable<EObject>() {
override Iterator<EObject> iterator() {
return EcoreUtil.getAllContents(resource, false).filter(c|!(c instanceof Variable));
}
};
val allDescriptions = Scopes.scopedElementsFor(allContents, qualifiedNameProvider);
return new MultimapBasedSelectable(allDescriptions);
}
}
|