Search in sources :

Example 6 with FeatureConfiguration

use of org.yakindu.sct.model.sgen.FeatureConfiguration in project statecharts by Yakindu.

the class AbstractDefaultFeatureValueProvider method createDefaultFeatureConfiguration.

public final FeatureConfiguration createDefaultFeatureConfiguration(FeatureType type, EObject contextElement) {
    FeatureConfiguration config = createConfiguration(type);
    EList<FeatureParameter> parameters = type.getParameters();
    for (FeatureParameter parameter : parameters) {
        FeatureParameterValue parameterValue = createParameterValue(type, parameter, contextElement);
        if (parameterValue != null && parameterValue.getExpression() != null) {
            config.getParameterValues().add(parameterValue);
        }
    }
    return config;
}
Also used : FeatureParameterValue(org.yakindu.sct.model.sgen.FeatureParameterValue) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) FeatureParameter(org.yakindu.sct.model.sgen.FeatureParameter)

Example 7 with FeatureConfiguration

use of org.yakindu.sct.model.sgen.FeatureConfiguration in project statecharts by Yakindu.

the class HelpIntegrationTest method checkDocumentedFeaturesExist.

@Test
public void checkDocumentedFeaturesExist() {
    List<String> features = getDocumentedFeatures();
    ArrayList<String> generators = new ArrayList<String>(Arrays.asList(YAKINDU_JAVA, YAKINDU_C, YAKINDU_CPP, YAKINDU_GENERIC));
    for (String generator : generators) {
        Iterable<IEObjectDescription> allElements = getAllElements(generator);
        for (IEObjectDescription desc : allElements) {
            if (desc.getEClass() != SGenPackage.Literals.FEATURE_TYPE)
                continue;
            EObject o = desc.getEObjectOrProxy();
            String name = null;
            if (o instanceof FeatureConfiguration) {
                FeatureType type = ((FeatureConfiguration) o).getType();
                if (type != null) {
                    name = type.getName();
                }
            } else if (o instanceof FeatureType) {
                FeatureType type = (FeatureType) o;
                if (type != null) {
                    name = type.getName();
                }
            } else if (o instanceof FeatureParameter) {
                FeatureType type = ((FeatureParameter) o).getFeatureType();
                if (type != null) {
                    name = type.getName();
                }
            }
            if (name != null)
                name = name.toLowerCase();
            if (name != null && features.contains(name)) {
                features.remove(name);
            }
        }
    }
    if (features.size() > 0) {
        fail("There are documented features that are not implemented: " + Arrays.toString(features.toArray()));
    }
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) EObject(org.eclipse.emf.ecore.EObject) ArrayList(java.util.ArrayList) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) FeatureParameter(org.yakindu.sct.model.sgen.FeatureParameter) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) Test(org.junit.Test)

Example 8 with FeatureConfiguration

use of org.yakindu.sct.model.sgen.FeatureConfiguration in project statecharts by Yakindu.

the class FeatureConfigurationItemProvider method getText.

/**
 * This returns the label text for the adapted class. <!-- begin-user-doc
 * --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public String getText(Object object) {
    FeatureConfiguration configuration = ((FeatureConfiguration) object);
    FeatureType type = configuration.getType();
    if (type != null) {
        return type.getName() + " feature";
    }
    return "";
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration)

Example 9 with FeatureConfiguration

use of org.yakindu.sct.model.sgen.FeatureConfiguration in project statecharts by Yakindu.

the class SGenJavaValidator method checkDeprecatedFeatures.

@Check
public void checkDeprecatedFeatures(GeneratorEntry entry) {
    Iterable<FeatureConfiguration> features = entry.getFeatures();
    Iterable<FeatureType> deprecatedFeatures = filter(transform(features, getFeatureType()), isDeprecated());
    for (FeatureType feature : deprecatedFeatures) {
        warning(String.format(DEPRECATED + " %s : %s", feature.getName(), feature.getComment()), SGenPackage.Literals.GENERATOR_ENTRY__ELEMENT_REF, feature.getName());
    }
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) Check(org.eclipse.xtext.validation.Check)

Example 10 with FeatureConfiguration

use of org.yakindu.sct.model.sgen.FeatureConfiguration 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

FeatureConfiguration (org.yakindu.sct.model.sgen.FeatureConfiguration)12 FeatureType (org.yakindu.sct.model.sgen.FeatureType)6 Check (org.eclipse.xtext.validation.Check)4 FeatureParameterValue (org.yakindu.sct.model.sgen.FeatureParameterValue)4 FeatureParameter (org.yakindu.sct.model.sgen.FeatureParameter)3 GeneratorEntry (org.yakindu.sct.model.sgen.GeneratorEntry)3 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 Path (org.eclipse.core.runtime.Path)1 URI (org.eclipse.emf.common.util.URI)1 EObject (org.eclipse.emf.ecore.EObject)1 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)1 Test (org.junit.Test)1 IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)1 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)1 FlowOptimizer (org.yakindu.sct.model.sexec.transformation.FlowOptimizer)1 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)1