use of org.yakindu.sct.model.sgen.GeneratorModel 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.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenJavaValidator method checkContentType.
@Check
public void checkContentType(GeneratorEntry entry) {
GeneratorModel generatorModel = EcoreUtil2.getContainerOfType(entry, GeneratorModel.class);
IGeneratorDescriptor descriptor = GeneratorExtensions.getGeneratorDescriptor(generatorModel.getGeneratorId());
if (descriptor == null)
return;
String contentType = entry.getContentType();
if (contentType == null || contentType.trim().length() == 0) {
return;
}
if (!contentType.equals(descriptor.getContentType())) {
error(UNKNOWN_CONTENT_TYPE + contentType + "'", SGenPackage.Literals.GENERATOR_ENTRY__CONTENT_TYPE);
}
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenJavaValidator method checkParameterValue.
@Check
public void checkParameterValue(final FeatureParameterValue value) {
if (value.getExpression() == null || value.getExpression() == null)
return;
GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(value);
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
IDefaultFeatureValueProvider provider = LibraryExtensions.getDefaultFeatureValueProvider(generatorDescriptor.getLibraryIDs(), value.getParameter().getFeatureType().getLibrary());
injector.injectMembers(provider);
IStatus status = provider.validateParameterValue(value);
createMarker(status);
}
use of org.yakindu.sct.model.sgen.GeneratorModel 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.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class EclipseContextGeneratorExecutorLookup method executeGenerator.
public void executeGenerator(IFile file) {
final GeneratorModel model = GenModelLoader.load(file);
Job generatorJob = new Job("Execute SCT Genmodel " + file.getName()) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
execute(model);
} catch (Exception ex) {
return new Status(IStatus.ERROR, BuilderActivator.PLUGIN_ID, ex.getMessage(), ex);
}
return Status.OK_STATUS;
}
};
generatorJob.setRule(file.getProject().getWorkspace().getRoot());
generatorJob.schedule();
}
Aggregations