use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkParameterValueType.
/**
* @see SGenJavaValidator#checkParameterValueType(org.yakindu.sct.model.sgen.FeatureParameterValue)
*/
@Test
public void checkParameterValueType() {
EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example { feature Outlet { targetFolder = true }}}", GeneratorModel.class.getSimpleName());
AssertableDiagnostics result = tester.validate(model);
result.assertAny(new MsgPredicate("Incompatible types string and boolean."));
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenJavaValidatorTest method checkDeprecatedFeatures.
/**
* @see SGenJavaValidator#checkDeprecatedFeatures(GeneratorEntry)
*/
@Test
public void checkDeprecatedFeatures() {
EObject model = parseExpression("GeneratorModel for yakindu::java { statechart Example { feature Outlet {targetFolder = \"src-gen\" targetProject = \"TestProject\" }}}", GeneratorModel.class.getSimpleName());
if (!(model instanceof GeneratorModel)) {
fail("Model is of the wrong type");
} else {
GeneratorModel genModel = (GeneratorModel) model;
genModel.getEntries().get(0).getFeatures().get(0).getType().setDeprecated(true);
AssertableDiagnostics result = tester.validate(genModel);
result.assertAny(new MsgPredicate(DEPRECATED));
}
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenTemplateProposalProvider method createFeatureConfigurationTemplates.
private void createFeatureConfigurationTemplates(TemplateContext templateContext, ContentAssistContext context, ITemplateAcceptor acceptor) {
GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(context.getCurrentModel());
IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
for (ILibraryDescriptor desc : libraryDescriptor) {
ResourceSet set = new ResourceSetImpl();
Resource resource = set.getResource(desc.getURI(), true);
FeatureTypeLibrary lib = (FeatureTypeLibrary) resource.getContents().get(0);
EList<FeatureType> types = lib.getTypes();
for (FeatureType featureType : types) {
Template template = new Template(featureType.getName() + " feature", "Creates feature " + featureType.getName(), featureType.getName(), creator.createProposal(featureType, desc.createFeatureValueProvider(SGenActivator.getInstance().getInjector(SGenActivator.ORG_YAKINDU_SCT_GENERATOR_GENMODEL_SGEN)), context.getCurrentModel()), false);
TemplateProposal proposal = createProposal(template, templateContext, context, getImage(template), getRelevance(template));
acceptor.accept(proposal);
}
}
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenScopeProvider method scope_GeneratorEntry_elementRef.
protected IScope scope_GeneratorEntry_elementRef(final EObject context, final EReference reference) {
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil2.getRootContainer(context);
String id = generatorModel.getGeneratorId();
final IGeneratorDescriptor desc = GeneratorExtensions.getGeneratorDescriptor(id);
if (desc == null)
return IScope.NULLSCOPE;
final String elementRefType = desc.getElementRefType();
IScope scope = new FilteringScope(getDelegate().getScope(context, reference), new Predicate<IEObjectDescription>() {
public boolean apply(IEObjectDescription input) {
EList<EClass> allSuperTypes = input.getEClass().getESuperTypes();
for (EClass eClass : allSuperTypes) {
if (elementRefType.equals(eClass.getInstanceClassName()))
return true;
}
return elementRefType.equals(input.getEClass().getInstanceClassName());
}
});
return new SimpleScope(scope.getAllElements());
}
use of org.yakindu.sct.model.sgen.GeneratorModel in project statecharts by Yakindu.
the class SGenScopeProvider method getElementReferenceScope.
protected IScope getElementReferenceScope(EObject context) {
GeneratorModel generatorModel = (GeneratorModel) EcoreUtil.getRootContainer(context);
EList<PropertyDefinition> properties = generatorModel.getProperties();
List<Property> all = buildInDeclarations.getDeclarations();
return Scopes.scopeFor(properties, Scopes.scopeFor(all));
}
Aggregations