use of org.yakindu.sct.generator.core.extensions.ILibraryDescriptor in project statecharts by Yakindu.
the class SGenTemplateProposalProvider method createFeatureConfigurationTemplates.
private void createFeatureConfigurationTemplates(TemplateContext templateContext, ContentAssistContext context, ITemplateAcceptor acceptor) {
GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(context.getCurrentModel());
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
for (ILibraryDescriptor desc : libraryDescriptor) {
ResourceSet set = new ResourceSetImpl();
Resource resource = set.getResource(desc.getURI(), true);
FeatureTypeLibrary lib = (FeatureTypeLibrary) resource.getContents().get(0);
EList<FeatureType> types = lib.getTypes();
for (FeatureType featureType : types) {
Template template = new Template(featureType.getName() + " feature", "Creates feature " + featureType.getName(), featureType.getName(), creator.createProposal(featureType, desc.createFeatureValueProvider(SGenActivator.getInstance().getInjector(SGenActivator.ORG_YAKINDU_SCT_GENERATOR_GENMODEL_SGEN)), context.getCurrentModel()), false);
TemplateProposal proposal = createProposal(template, templateContext, context, getImage(template), getRelevance(template));
acceptor.accept(proposal);
}
}
}
use of org.yakindu.sct.generator.core.extensions.ILibraryDescriptor 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.yakindu.sct.generator.core.extensions.ILibraryDescriptor in project statecharts by Yakindu.
the class SGenJavaValidator method checkRequiredParameters.
@Check
public void checkRequiredParameters(FeatureConfiguration configuration) {
GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(configuration);
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
Iterable<ILibraryDescriptor> libraryDescriptors = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
Iterable<String> requiredParameters = transform(filter(concat(transform(filter(concat(transform(transform(libraryDescriptors, getFeatureTypeLibrary()), getFeatureTypes())), hasName(configuration.getType().getName())), getParameter())), isRequiredParamter()), getName());
List<String> configuredParameters = Lists.newArrayList();
for (FeatureParameterValue featureParameterValue : configuration.getParameterValues()) {
configuredParameters.add(featureParameterValue.getParameter().getName());
}
for (String string : requiredParameters) {
if (!configuredParameters.contains(string))
error(String.format(MISSING_REQUIRED_PARAMETER + " %s", string), SGenPackage.Literals.FEATURE_CONFIGURATION__TYPE);
}
}
use of org.yakindu.sct.generator.core.extensions.ILibraryDescriptor in project statecharts by Yakindu.
the class HelpIntegrationTest method getAllElements.
private Iterable<IEObjectDescription> getAllElements(String generatorId) {
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(generatorId);
Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
Iterable<IEObjectDescription> allElements = Lists.newArrayList();
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 allElements;
}
use of org.yakindu.sct.generator.core.extensions.ILibraryDescriptor in project statecharts by Yakindu.
the class SGenJavaValidator method checkRequiredFeatures.
@Check
public void checkRequiredFeatures(GeneratorEntry entry) {
GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(entry);
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
Iterable<ILibraryDescriptor> libraryDescriptors = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
Iterable<FeatureType> requiredFeatures = filter(concat(transform(transform(libraryDescriptors, getFeatureTypeLibrary()), getFeatureTypes())), isRequired());
List<String> configuredTypes = Lists.newArrayList();
for (FeatureConfiguration featureConfiguration : entry.getFeatures()) {
configuredTypes.add(featureConfiguration.getType().getName());
}
for (FeatureType featureType : requiredFeatures) {
if (!configuredTypes.contains(featureType.getName()))
error(String.format(MISSING_REQUIRED_FEATURE + " %s", featureType.getName()), SGenPackage.Literals.GENERATOR_ENTRY__ELEMENT_REF, CODE_REQUIRED_FEATURE, featureType.getName());
}
}
Aggregations