Search in sources :

Example 1 with GeneratorEntry

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

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

the class AbstractJavaGeneratorTest method generateAndCompile.

public IMarker[] generateAndCompile(Statechart statechart) throws Exception {
    GeneratorEntry entry = createGeneratorEntry(statechart.getName(), SRC_GEN);
    entry.setElementRef(statechart);
    IProject targetProject = getProject(entry);
    targetProject.delete(true, new NullProgressMonitor());
    targetProject = getProject(entry);
    if (!targetProject.exists()) {
        targetProject.create(new NullProgressMonitor());
        targetProject.open(new NullProgressMonitor());
    }
    IGeneratorEntryExecutor executor = new EclipseContextGeneratorExecutorLookup() {

        protected Module getContextModule() {
            return Modules.override(super.getContextModule()).with(new Module() {

                @Override
                public void configure(Binder binder) {
                    binder.bind(IConsoleLogger.class).to(TestLogger.class);
                }
            });
        }
    }.createExecutor(entry, "yakindu::java");
    executor.execute(entry);
    targetProject.refreshLocal(IResource.DEPTH_INFINITE, null);
    targetProject.getWorkspace().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
    targetProject.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
    IMarker[] markers = targetProject.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
    return markers;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Binder(com.google.inject.Binder) IConsoleLogger(org.yakindu.sct.generator.core.console.IConsoleLogger) GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) IGeneratorEntryExecutor(org.yakindu.sct.generator.core.execution.IGeneratorEntryExecutor) IMarker(org.eclipse.core.resources.IMarker) Module(com.google.inject.Module) IProject(org.eclipse.core.resources.IProject) EclipseContextGeneratorExecutorLookup(org.yakindu.sct.generator.builder.EclipseContextGeneratorExecutorLookup)

Example 3 with GeneratorEntry

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

the class SGenJavaValidator method checkDuplicateGeneratorEntryFeature.

@Check
public void checkDuplicateGeneratorEntryFeature(final FeatureConfiguration config) {
    GeneratorEntry entry = (GeneratorEntry) config.eContainer();
    Iterable<FeatureConfiguration> filter = Iterables.filter(entry.getFeatures(), new Predicate<FeatureConfiguration>() {

        public boolean apply(FeatureConfiguration input) {
            return (input.getType().getName().equals(config.getType().getName()));
        }
    });
    if (Iterables.size(filter) > 1) {
        error(DUPLICATE_FEATURE, SGenPackage.Literals.FEATURE_CONFIGURATION__TYPE);
    }
}
Also used : GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration) Check(org.eclipse.xtext.validation.Check)

Example 4 with GeneratorEntry

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

the class ModelCreator method createGeneratorEntry.

private GeneratorEntry createGeneratorEntry(EObject eobject) {
    GeneratorEntry entry = factory.createGeneratorEntry();
    entry.setContentType(descriptor.getContentType());
    entry.setElementRef(eobject);
    List<FeatureType> featureTypes = getFeatureTypes(descriptor);
    for (FeatureType featureType : featureTypes) {
        FeatureConfiguration config = createFeatureConfiguration(eobject, featureType);
        if (config != null && !config.getParameterValues().isEmpty()) {
            entry.getFeatures().add(config);
        }
    }
    return entry;
}
Also used : FeatureType(org.yakindu.sct.model.sgen.FeatureType) GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) FeatureConfiguration(org.yakindu.sct.model.sgen.FeatureConfiguration)

Example 5 with GeneratorEntry

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

the class CPPDefaultFeatureValueProvider method setDefaultValue.

@Override
protected void setDefaultValue(FeatureType featureType, FeatureParameterValue parameterValue, EObject contextElement) {
    GeneratorEntry entry = (GeneratorEntry) contextElement;
    Statechart statechart = (Statechart) entry.getElementRef();
    if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_MODULE_NAME)) {
        parameterValue.setValue(asIdentifier(statechart.getName(), "_"));
    } else if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_STATEMACHINE_PREFIX)) {
        parameterValue.setValue(StringExtensions.toFirstLower(asIdentifier(statechart.getName(), "_")));
    } else if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_MAX_IDENTIFIER_LENGTH)) {
        parameterValue.setValue("31");
    } else if (parameterValue.getParameter().getName().equals(ICFeatureConstants.PARAMETER_NAMING_SEPARATOR)) {
        parameterValue.setValue("_");
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_INNER_FUNCTION_VISIBILITY)) {
        parameterValue.setValue(Visibility.PRIVATE.toString().toLowerCase());
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_STATIC_OPC)) {
        parameterValue.setValue(false);
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_INCLUDES_USE_RELATIVE_PATHS)) {
        parameterValue.setValue(true);
    } else if (parameterValue.getParameter().getName().equals(CPPFeatureConstants.PARAMETER_API_CHECK_UNIMPLEMENTED_OCBS)) {
        parameterValue.setValue(true);
    }
}
Also used : GeneratorEntry(org.yakindu.sct.model.sgen.GeneratorEntry) Statechart(org.yakindu.sct.model.sgraph.Statechart)

Aggregations

GeneratorEntry (org.yakindu.sct.model.sgen.GeneratorEntry)8 FeatureConfiguration (org.yakindu.sct.model.sgen.FeatureConfiguration)3 FeatureType (org.yakindu.sct.model.sgen.FeatureType)2 Statechart (org.yakindu.sct.model.sgraph.Statechart)2 Binder (com.google.inject.Binder)1 Module (com.google.inject.Module)1 List (java.util.List)1 IMarker (org.eclipse.core.resources.IMarker)1 IProject (org.eclipse.core.resources.IProject)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 EObject (org.eclipse.emf.ecore.EObject)1 INode (org.eclipse.xtext.nodemodel.INode)1 LeafNode (org.eclipse.xtext.nodemodel.impl.LeafNode)1 Check (org.eclipse.xtext.validation.Check)1 ElementReferenceExpression (org.yakindu.base.expressions.expressions.ElementReferenceExpression)1 EclipseContextGeneratorExecutorLookup (org.yakindu.sct.generator.builder.EclipseContextGeneratorExecutorLookup)1 IConsoleLogger (org.yakindu.sct.generator.core.console.IConsoleLogger)1 IGeneratorEntryExecutor (org.yakindu.sct.generator.core.execution.IGeneratorEntryExecutor)1 DeprecatableElement (org.yakindu.sct.model.sgen.DeprecatableElement)1 FeatureParameter (org.yakindu.sct.model.sgen.FeatureParameter)1