use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class STextProposalProvider method getProposalFactory.
protected Function<IEObjectDescription, ICompletionProposal> getProposalFactory(String ruleName, ContentAssistContext contentAssistContext) {
return new DefaultProposalCreator(contentAssistContext, ruleName, getQualifiedNameConverter()) {
@Override
public ICompletionProposal apply(IEObjectDescription candidate) {
ICompletionProposal proposal = super.apply(candidate);
EObject eObjectOrProxy = candidate.getEObjectOrProxy();
if (eObjectOrProxy.eIsProxy()) {
return proposal;
}
if (eObjectOrProxy instanceof Operation) {
Operation operation = (Operation) eObjectOrProxy;
if (operation.getParameters().size() > 0 && (proposal instanceof ConfigurableCompletionProposal)) {
ConfigurableCompletionProposal configurableProposal = (ConfigurableCompletionProposal) proposal;
configurableProposal.setReplacementString(configurableProposal.getReplacementString() + "()");
configurableProposal.setCursorPosition(configurableProposal.getCursorPosition() + 1);
}
}
return proposal;
}
};
}
use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class AbstractLibraryGlobalScopeProvider method getDescriptions.
protected Iterable<IEObjectDescription> getDescriptions(Resource context, URI uri) {
List<IEObjectDescription> result = Lists.newArrayList();
ResourceSet set = context.getResourceSet();
Resource resource = set.getResource(uri, true);
IResourceServiceProvider resourceServiceProvider = serviceProviderRegistry.getResourceServiceProvider(uri);
if (resourceServiceProvider == null) {
Iterables.addAll(result, Scopes.scopedElementsFor(Lists.newArrayList(resource.getAllContents())));
} else {
IResourceDescription resourceDescription = resourceServiceProvider.getResourceDescriptionManager().getResourceDescription(resource);
Iterables.addAll(result, resourceDescription.getExportedObjects());
}
resource.unload();
return result;
}
use of org.eclipse.xtext.resource.IEObjectDescription in project statecharts by Yakindu.
the class FeatureResourceDescription method computeExportedObjects.
@Override
protected List<IEObjectDescription> computeExportedObjects() {
Iterator<EObject> contents = resource.getAllContents();
List<IEObjectDescription> result = Lists.newArrayList();
while (contents.hasNext()) {
EObject eObject = contents.next();
QualifiedName qualifiedName = qualifiedNameProvider.apply(eObject);
if (qualifiedName != null) {
Map<String, String> userData = new HashMap<String, String>();
if (eObject instanceof FeatureParameter) {
userData.put(FEATURE_CONTAINER, getFqName(eObject));
}
result.add(new EObjectDescription(qualifiedName, eObject, userData));
}
}
return result;
}
use of org.eclipse.xtext.resource.IEObjectDescription 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.resource.IEObjectDescription 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);
}
Aggregations