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;
}
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;
}
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);
}
}
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;
}
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);
}
}
Aggregations