Search in sources :

Example 21 with GeneratorModel

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));
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) AbstractSGenTest(org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest) Test(org.junit.Test)

Example 22 with GeneratorModel

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));
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) AbstractSGenTest(org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest) Test(org.junit.Test)

Example 23 with GeneratorModel

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));
    }
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) AbstractSGenTest(org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest) Test(org.junit.Test)

Example 24 with GeneratorModel

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;
}
Also used : ExecutionContext(org.yakindu.sct.model.sruntime.ExecutionContext) ExecutionContextImpl(org.yakindu.sct.model.sruntime.impl.ExecutionContextImpl) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) PropertyDefinition(org.yakindu.sct.model.sgen.PropertyDefinition) ExecutionVariable(org.yakindu.sct.model.sruntime.ExecutionVariable)

Example 25 with GeneratorModel

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());
    }
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) ILibraryDescriptor(org.yakindu.sct.generator.core.extensions.ILibraryDescriptor) Check(org.eclipse.xtext.validation.Check)

Aggregations

GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)28 EObject (org.eclipse.emf.ecore.EObject)13 AssertableDiagnostics (org.eclipse.xtext.junit4.validation.AssertableDiagnostics)11 Test (org.junit.Test)11 AbstractSGenTest (org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest)11 IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)10 Resource (org.eclipse.emf.ecore.resource.Resource)6 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)5 Check (org.eclipse.xtext.validation.Check)4 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 FeatureType (org.yakindu.sct.model.sgen.FeatureType)3 IResource (org.eclipse.core.resources.IResource)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)2 SimpleScope (org.eclipse.xtext.scoping.impl.SimpleScope)2 IDefaultFeatureValueProvider (org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider)2 FeatureTypeLibrary (org.yakindu.sct.model.sgen.FeatureTypeLibrary)2 PropertyDefinition (org.yakindu.sct.model.sgen.PropertyDefinition)2