Search in sources :

Example 6 with IGeneratorDescriptor

use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.

the class SGenJavaValidator method checkContentType.

@Check
public void checkContentType(GeneratorEntry entry) {
    GeneratorModel generatorModel = EcoreUtil2.getContainerOfType(entry, GeneratorModel.class);
    IGeneratorDescriptor descriptor = GeneratorExtensions.getGeneratorDescriptor(generatorModel.getGeneratorId());
    if (descriptor == null)
        return;
    String contentType = entry.getContentType();
    if (contentType == null || contentType.trim().length() == 0) {
        return;
    }
    if (!contentType.equals(descriptor.getContentType())) {
        error(UNKNOWN_CONTENT_TYPE + contentType + "'", SGenPackage.Literals.GENERATOR_ENTRY__CONTENT_TYPE);
    }
}
Also used : GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) Check(org.eclipse.xtext.validation.Check)

Example 7 with IGeneratorDescriptor

use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.

the class SGenJavaValidator method checkParameterValue.

@Check
public void checkParameterValue(final FeatureParameterValue value) {
    if (value.getExpression() == null || value.getExpression() == null)
        return;
    GeneratorModel model = (GeneratorModel) EcoreUtil2.getRootContainer(value);
    IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(model.getGeneratorId());
    IDefaultFeatureValueProvider provider = LibraryExtensions.getDefaultFeatureValueProvider(generatorDescriptor.getLibraryIDs(), value.getParameter().getFeatureType().getLibrary());
    injector.injectMembers(provider);
    IStatus status = provider.validateParameterValue(value);
    createMarker(status);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IDefaultFeatureValueProvider(org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) Check(org.eclipse.xtext.validation.Check)

Example 8 with IGeneratorDescriptor

use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor 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 9 with IGeneratorDescriptor

use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.

the class SGenProposalProvider method completeGeneratorEntry_ContentType.

@Override
public void completeGeneratorEntry_ContentType(EObject model, Assignment assignment, ContentAssistContext context, ICompletionProposalAcceptor acceptor) {
    GeneratorModel generatorModel = EcoreUtil2.getContainerOfType(model, GeneratorModel.class);
    IGeneratorDescriptor descriptor = GeneratorExtensions.getGeneratorDescriptor(generatorModel.getGeneratorId());
    if (descriptor == null)
        return;
    ICompletionProposal proposal = createCompletionProposal(descriptor.getContentType(), context);
    acceptor.accept(proposal);
}
Also used : ICompletionProposal(org.eclipse.jface.text.contentassist.ICompletionProposal) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)

Example 10 with IGeneratorDescriptor

use of org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor in project statecharts by Yakindu.

the class HelpIntegrationTest method getAllElements.

private Iterable<IEObjectDescription> getAllElements(String generatorId) {
    IGeneratorDescriptor generatorDescriptor = GeneratorExtensions.getGeneratorDescriptor(generatorId);
    Iterable<ILibraryDescriptor> libraryDescriptor = LibraryExtensions.getLibraryDescriptors(generatorDescriptor.getLibraryIDs());
    Iterable<IEObjectDescription> allElements = Lists.newArrayList();
    for (ILibraryDescriptor desc : libraryDescriptor) {
        Resource library = resourceSet.getResource(desc.getURI(), true);
        FeatureResourceDescription description = new FeatureResourceDescription(library);
        injector.injectMembers(description);
        allElements = Iterables.concat(allElements, description.getExportedObjects());
    }
    return allElements;
}
Also used : FeatureResourceDescription(org.yakindu.sct.generator.genmodel.resource.FeatureResourceDescription) Resource(org.eclipse.emf.ecore.resource.Resource) IGeneratorDescriptor(org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor) ILibraryDescriptor(org.yakindu.sct.generator.core.extensions.ILibraryDescriptor) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

IGeneratorDescriptor (org.yakindu.sct.generator.core.extensions.IGeneratorDescriptor)15 GeneratorModel (org.yakindu.sct.model.sgen.GeneratorModel)10 Resource (org.eclipse.emf.ecore.resource.Resource)6 ILibraryDescriptor (org.yakindu.sct.generator.core.extensions.ILibraryDescriptor)6 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)4 Check (org.eclipse.xtext.validation.Check)4 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)3 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)3 FeatureType (org.yakindu.sct.model.sgen.FeatureType)3 IResource (org.eclipse.core.resources.IResource)2 EClass (org.eclipse.emf.ecore.EClass)2 EObject (org.eclipse.emf.ecore.EObject)2 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)2 SimpleScope (org.eclipse.xtext.scoping.impl.SimpleScope)2 IDefaultFeatureValueProvider (org.yakindu.sct.generator.core.library.IDefaultFeatureValueProvider)2 FeatureResourceDescription (org.yakindu.sct.generator.genmodel.resource.FeatureResourceDescription)2 FeatureTypeLibrary (org.yakindu.sct.model.sgen.FeatureTypeLibrary)2 Injector (com.google.inject.Injector)1 IOException (java.io.IOException)1 IStatus (org.eclipse.core.runtime.IStatus)1