Search in sources :

Example 11 with GeneratorModel

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

the class GenModelLoader method load.

public static GeneratorModel load(IFile file) {
    Resource resource = null;
    URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
    resource = new ResourceSetImpl().getResource(uri, true);
    if (resource == null || resource.getContents().size() == 0 || resource.getErrors().size() > 0)
        return null;
    final GeneratorModel model = (GeneratorModel) resource.getContents().get(0);
    return model;
}
Also used : ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Resource(org.eclipse.emf.ecore.resource.Resource) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel) URI(org.eclipse.emf.common.util.URI)

Example 12 with GeneratorModel

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

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

the class GTestHelper method getGeneratorModel.

protected GeneratorModel getGeneratorModel(String sgenFileName) {
    IPath path = new Path(sgenFileName);
    Resource sgenResource = loadResource(getWorkspaceFileFor(path));
    GeneratorModel model = (GeneratorModel) sgenResource.getContents().get(0);
    return model;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IResource(org.eclipse.core.resources.IResource) Resource(org.eclipse.emf.ecore.resource.Resource) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel)

Example 14 with GeneratorModel

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

the class GTestHelper method generate.

public void generate() {
    IPath targetPath = getTargetPath();
    // copy model to JUnit workspace
    copyFileFromBundleToFolder(getModelBundle(), getModelPath(), targetPath);
    String sgenFileName = getSgenFileName(getTestProgram());
    copyFileFromBundleToFolder(getTestBundle(), sgenFileName, targetPath);
    GeneratorModel model = getGeneratorModel(sgenFileName);
    model.getEntries().get(0).setElementRef(getStatechart());
    performFullBuild();
    getGeneratorExecutorLookup().execute(model);
}
Also used : IPath(org.eclipse.core.runtime.IPath) GeneratorModel(org.yakindu.sct.model.sgen.GeneratorModel)

Example 15 with GeneratorModel

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

the class SGenJavaValidatorTest method checkDeprecatedParameters.

/**
 * @see SGenJavaValidator#checkDeprecatedParameters(GeneratorEntry)
 */
@Test
public void checkDeprecatedParameters() {
    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().getParameters().get(0).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)

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