use of org.eclipse.xtext.scoping.impl.SimpleScope in project statecharts by Yakindu.
the class SGenScopeProvider method scope_GeneratorEntry_elementRef.
protected IScope scope_GeneratorEntry_elementRef(final EObject context, final EReference reference) {
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil2.getRootContainer(context);
String id = generatorModel.getGeneratorId();
final IGeneratorDescriptor desc = GeneratorExtensions.getGeneratorDescriptor(id);
if (desc == null)
return IScope.NULLSCOPE;
final String elementRefType = desc.getElementRefType();
IScope scope = new FilteringScope(getDelegate().getScope(context, reference), new Predicate<IEObjectDescription>() {
public boolean apply(IEObjectDescription input) {
EList<EClass> allSuperTypes = input.getEClass().getESuperTypes();
for (EClass eClass : allSuperTypes) {
if (elementRefType.equals(eClass.getInstanceClassName()))
return true;
}
return elementRefType.equals(input.getEClass().getInstanceClassName());
}
});
return new SimpleScope(scope.getAllElements());
}
use of org.eclipse.xtext.scoping.impl.SimpleScope in project statecharts by Yakindu.
the class SGenScopeProvider method getLibraryScope.
protected SimpleScope getLibraryScope(Resource resource) {
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil.getObjectByType(resource.getContents(), SGenPackage.Literals.GENERATOR_MODEL);
Assert.isNotNull(generatorModel);
String generatorId = generatorModel.getGeneratorId();
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(generatorId);
Iterable<IEObjectDescription> allElements = Lists.newArrayList();
if (generatorDescriptor != null) {
Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
for (ILibraryDescriptor desc : libraryDescriptor) {
Resource library = resourceSet.getResource(desc.getURI(), true);
FeatureResourceDescription description = new FeatureResourceDescription(library);
injector.injectMembers(description);
allElements = Iterables.concat(allElements, description.getExportedObjects());
}
}
return new SimpleScope(allElements);
}
use of org.eclipse.xtext.scoping.impl.SimpleScope in project statecharts by Yakindu.
the class STextGlobalScopeProvider method getScope.
public IScope getScope(Resource context, EReference reference, Predicate<IEObjectDescription> filter) {
IScope parentScope = super.getScope(context, reference, filter);
parentScope = new SimpleScope(parentScope, filterPropertiesOfLibrary(context, reference, filter).getAllElements());
final Statechart statechart = getStatechart(context);
parentScope = new TypeSystemAwareScope(parentScope, typeSystem, qualifiedNameProvider, reference.getEReferenceType());
IScope result = new FilteringScope(parentScope, new Predicate<IEObjectDescription>() {
@Override
public boolean apply(IEObjectDescription input) {
String userData = input.getUserData(DomainRegistry.DOMAIN_ID);
if (userData == null)
return true;
return statechart.getDomainID().equals(userData);
}
});
result = filterAnnotations(reference, result);
return new FilteringScope(result, input -> {
String isVisible = input.getUserData(TypedResourceDescriptionStrategy.IS_VISIBLE_TYPE);
return isVisible == null || Boolean.valueOf(isVisible);
});
}
use of org.eclipse.xtext.scoping.impl.SimpleScope in project statecharts by Yakindu.
the class STextScopeProvider method scope_ElementReferenceExpression_reference.
public IScope scope_ElementReferenceExpression_reference(final EObject context, EReference reference) {
IScope namedScope = getNamedTopLevelScope(context, reference);
IScope unnamedScope = getUnnamedTopLevelScope(context, reference);
Predicate<IEObjectDescription> predicate = calculateFilterPredicate(context, reference);
unnamedScope = new FilteringScope(unnamedScope, predicate);
return new SimpleScope(unnamedScope, namedScope.getAllElements());
}
use of org.eclipse.xtext.scoping.impl.SimpleScope in project xtext-core by eclipse.
the class XtextScopeProvider method createEPackageScope.
protected IScope createEPackageScope(final Grammar grammar) {
final List<Grammar> allGrammars = getAllGrammars(grammar);
IScope current = new SimpleScope(IScope.NULLSCOPE, Iterables.transform(EPackage.Registry.INSTANCE.keySet(), new Function<String, IEObjectDescription>() {
@Override
public IEObjectDescription apply(String from) {
InternalEObject proxyPackage = (InternalEObject) EcoreFactory.eINSTANCE.createEPackage();
proxyPackage.eSetProxyURI(URI.createURI(from));
return EObjectDescription.create(QualifiedName.create(from), proxyPackage, Collections.singletonMap("nsURI", "true"));
}
}));
for (int i = allGrammars.size() - 1; i >= 0; i--) {
current = createEPackageScope(allGrammars.get(i), current);
}
return current;
}
Aggregations