Search in sources :

Example 1 with FeatureParameterValue

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

the class AbstractJavaGeneratorTest method createGeneratorEntry.

private GeneratorEntry createGeneratorEntry(String targetProject, String targetFolder) {
    GeneratorEntry entry = SGenFactory.eINSTANCE.createGeneratorEntry();
    entry.setContentType(CONTENT_TYPE);
    FeatureConfiguration config = SGenFactory.eINSTANCE.createFeatureConfiguration();
    FeatureType type = SGenFactory.eINSTANCE.createFeatureType();
    type.setName(OUTLET_FEATURE);
    config.setType(type);
    FeatureParameterValue project = SGenFactory.eINSTANCE.createFeatureParameterValue();
    FeatureParameter projectParameter = SGenFactory.eINSTANCE.createFeatureParameter();
    projectParameter.setName(TARGET_PROJECT);
    project.setParameter(projectParameter);
    project.setValue(targetProject);
    config.getParameterValues().add(project);
    FeatureParameterValue targetFolderValue = SGenFactory.eINSTANCE.createFeatureParameterValue();
    FeatureParameter targetParameter = SGenFactory.eINSTANCE.createFeatureParameter();
    targetParameter.setName(TARGET_FOLDER);
    targetFolderValue.setParameter(targetParameter);
    targetFolderValue.setValue(targetFolder);
    config.getParameterValues().add(targetFolderValue);
    entry.getFeatures().add(config);
    return entry;
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) FeatureParameterValue(org.yakindu.sct.model.sgen.FeatureParameterValue) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) FeatureParameter(org.yakindu.sct.model.sgen.FeatureParameter)

Example 2 with FeatureParameterValue

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

the class SGenJavaValidator method checkDuplicateFeatureParameter.

@Check
public void checkDuplicateFeatureParameter(final FeatureParameterValue value) {
    FeatureConfiguration entry = (FeatureConfiguration) value.eContainer();
    Iterable<FeatureParameterValue> filter = Iterables.filter(entry.getParameterValues(), new Predicate<FeatureParameterValue>() {

        public boolean apply(FeatureParameterValue input) {
            return (input.getParameter().getName().equals(value.getParameter().getName()));
        }
    });
    if (Iterables.size(filter) > 1) {
        error(DUPLICATE_PARAMETER, SGenPackage.Literals.FEATURE_PARAMETER_VALUE__PARAMETER);
    }
}
Also used : FeatureParameterValue(org.yakindu.sct.model.sgen.FeatureParameterValue) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) Check(org.eclipse.xtext.validation.Check)

Example 3 with FeatureParameterValue

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

Example 4 with FeatureParameterValue

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

the class WorkspaceGeneratorExecutor method getLookupRoot.

protected IProject getLookupRoot(GeneratorEntry entry) {
    IProject project = null;
    FeatureConfiguration templateConfig = entry.getFeatureConfiguration(TEMPLATE_FEATURE);
    FeatureParameterValue projectName = templateConfig.getParameterValue(GENERATOR_PROJECT);
    if (projectName != null) {
        project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName.getStringValue());
    } else {
        URI uri = entry.getElementRef().eResource().getURI();
        project = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(uri.toPlatformString(true))).getProject();
    }
    return project;
}
Also used : Path(org.eclipse.core.runtime.Path) FeatureParameterValue(org.yakindu.sct.model.sgen.FeatureParameterValue) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject)

Example 5 with FeatureParameterValue

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

Aggregations

FeatureParameterValue (org.yakindu.sct.model.sgen.FeatureParameterValue)12 FeatureConfiguration (org.yakindu.sct.model.sgen.FeatureConfiguration)4 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)2 Check (org.eclipse.xtext.validation.Check)2 FeatureParameter (org.yakindu.sct.model.sgen.FeatureParameter)2 IProject (org.eclipse.core.resources.IProject)1 Path (org.eclipse.core.runtime.Path)1 URI (org.eclipse.emf.common.util.URI)1 IGenArtifactConfigurations (org.yakindu.sct.generator.c.IGenArtifactConfigurations)1 IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)1 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)1 FeatureType (org.yakindu.sct.model.sgen.FeatureType)1 GeneratorEntry (org.yakindu.sct.model.sgen.GeneratorEntry)1 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)1