Search in sources :

Example 1 with GeneratorModel

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."));
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) AbstractSGenTest(org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest) Test(org.junit.Test)

Example 2 with GeneratorModel

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));
    }
}
Also used : AssertableDiagnostics(org.eclipse.xtext.junit4.validation.AssertableDiagnostics) EObject(org.eclipse.emf.ecore.EObject) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) AbstractSGenTest(org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest) Test(org.junit.Test)

Example 3 with GeneratorModel

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);
        }
    }
}
Also used : TemplateProposal(org.eclipse.jface.text.templates.TemplateProposal) FeatureType(org.yakindu.sct.model.sgen.FeatureType) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) FeatureTypeLibrary(org.yakindu.sct.model.sgen.FeatureTypeLibrary) Resource(org.eclipse.emf.ecore.resource.Resource) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) ILibraryDescriptor(org.yakindu.sct.generator.core.extensions.ILibraryDescriptor) Template(org.eclipse.jface.text.templates.Template)

Example 4 with GeneratorModel

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());
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EList(org.eclipse.emf.common.util.EList) SimpleScope(org.eclipse.xtext.scoping.impl.SimpleScope) IScope(org.eclipse.xtext.scoping.IScope) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) FilteringScope(org.eclipse.xtext.scoping.impl.FilteringScope) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 5 with GeneratorModel

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));
}
Also used : GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) PropertyDefinition(org.yakindu.sct.model.sgen.PropertyDefinition) Property(org.yakindu.base.types.Property)

Aggregations

GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)28 EObject (org.eclipse.emf.ecore.EObject)13 AssertableDiagnostics (org.eclipse.xtext.junit4.validation.AssertableDiagnostics)11 Test (org.junit.Test)11 AbstractSGenTest (org.yakindu.sct.generator.genmodel.test.util.AbstractSGenTest)11 IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)10 Resource (org.eclipse.emf.ecore.resource.Resource)6 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)5 Check (org.eclipse.xtext.validation.Check)4 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 FeatureType (org.yakindu.sct.model.sgen.FeatureType)3 IResource (org.eclipse.core.resources.IResource)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)2 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)2 SimpleScope (org.eclipse.xtext.scoping.impl.SimpleScope)2 IDefaultFeatureValueProvider (org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider)2 FeatureTypeLibrary (org.yakindu.sct.model.sgen.FeatureTypeLibrary)2 PropertyDefinition (org.yakindu.sct.model.sgen.PropertyDefinition)2