use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkRequiredFeatures.
/**
* @see SGenJavaValidator#checkRequiredFeatures(org.yakindu.sct.model.sgen.GeneratorEntry)
*/
@Test
public void checkRequiredFeatures() {
EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example {}}", GeneratorModel.class.getSimpleName());
AssertableDiagnostics result = tester.validate(model);
result.assertAny(new MsgPredicate(MISSING_REQUIRED_FEATURE));
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkRequiredParameters.
/**
* @see SGenJavaValidator#checkRequiredParameters(FeatureConfiguration)
*/
@Test
public void checkRequiredParameters() {
EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example { feature Outlet {}}}", GeneratorModel.class.getSimpleName());
AssertableDiagnostics result = tester.validate(model);
result.assertAny(new MsgPredicate(MISSING_REQUIRED_PARAMETER));
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkEntriesExist.
/**
* @see SGenJavaValidator#checkDeprecatedParameters(GeneratorEntry)
*/
@Test
public void checkEntriesExist() {
EObject model = parseExpression("GeneratorModel for yakindu::java {}", GeneratorModel.class.getSimpleName());
if (!(model instanceof GeneratorModel)) {
fail("Model is of the wrong type");
} else {
GeneratorModel genModel = (GeneratorModel) model;
AssertableDiagnostics result = tester.validate(genModel);
result.assertAny(new MsgPredicate(EMPTY_SGEN));
}
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class FeatureParameterValueImpl method getExecutionContext.
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
protected ExecutionContext getExecutionContext() {
if (!(EcoreUtil.getRootContainer(this) instanceof GeneratorModel)) {
return new ExecutionContextImpl();
}
ExecutionContext context = new ExecutionContextImpl();
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil.getRootContainer(this);
EList<PropertyDefinition> properties = generatorModel.getProperties();
for (PropertyDefinition propertyDefinition : properties) {
ExecutionVariable variable = SRuntimeFactory.eINSTANCE.createExecutionVariable();
variable.setName(propertyDefinition.getName());
variable.setFqName(propertyDefinition.getName());
variable.setType(propertyDefinition.getType());
variable.setValue(interpreter.evaluate(propertyDefinition.getInitialValue(), context));
context.getSlots().add(variable);
}
return context;
}
use of org.yakindu.sct.model.sgen.GeneratorModel 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