Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] Problem with casting
[ACCELEO] Problem with casting [message #1470860] Wed, 12 November 2014 17:43 Go to next message
Martin Paquin is currently offline Martin PaquinFriend
Messages: 21
Registered: July 2014
Junior Member
I have problem with cast. My Class X2ELibrary is an extention of omg gastm CompilationUnit. I have try different way to cast the CompilationUnit to X2ELibrary

[for (compUnit : CompilationUnit | project.files)]
	[for (it : X2EFile | compUnit.oclAsType(X2ELibrary).x2eFiles)]


org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid loop iteration at line 18 in Module generate for block for (compUnit.oclAsType(x2esastm::X2ELibrary).x2eFiles). Last recorded value of self was x2esastm.impl.X2ELibraryImpl@4716be8b (path: X2EMDL) (language: Synon).
	at generate.generateElement(Project)(generate.mtl:18)
	at generate.generateElement(Project)(generate.mtl:15)
	at generate.generateElement(Project)(generate.mtl:12)


x2esastm.impl.X2ELibraryImpl is the implementation class for X2ELibrary

I have register my library in Generate.java like this

    /**
     * This can be used to update the resource set's package registry with all needed EPackages.
     * 
     * @param resourceSet
     *            The resource set which registry has to be updated.
     * @generated NOT
     */
    @Override
    public void registerPackages(ResourceSet resourceSet) {
        super.registerPackages(resourceSet);
        if (!isInWorkspace(org.eclipse.emf.ecore.EcorePackage.class)) {
            resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.EcorePackage.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.EcorePackage.eINSTANCE);
        }
        if (!isInWorkspace(GASTMPackage.class)) {
            // The normal package registration if your metamodel is in a plugin.
            resourceSet.getPackageRegistry().put(GASTMPackage.eNS_URI, GASTMPackage.eINSTANCE);
        }
        if (!isInWorkspace(x2esastm.X2esastmPackage.class)) {
            // The normal package registration if your metamodel is in a plugin.
            resourceSet.getPackageRegistry().put(x2esastm.X2esastmPackage.eNS_URI, x2esastm.X2esastmPackage.eINSTANCE);
        }
        


Any idea on how to solve my problem?

Martin
Re: [ACCELEO] Problem with casting [message #1470880 is a reply to message #1470860] Wed, 12 November 2014 18:01 Go to previous messageGo to next message
Martin Paquin is currently offline Martin PaquinFriend
Messages: 21
Registered: July 2014
Junior Member
The problem only appears when I run the transformation. The Acceleo editor doesn't gave me any warning or errors.
Re: [ACCELEO] Problem with casting [message #1470891 is a reply to message #1470880] Wed, 12 November 2014 18:14 Go to previous messageGo to next message
Martin Paquin is currently offline Martin PaquinFriend
Messages: 21
Registered: July 2014
Junior Member
if I change to
[for (library : X2ELibrary | project.files)]


I got this exception:
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid type for iteration at line 15 in Module generate for block for (project.files). x2esastm.impl.X2ELibraryImpl was not an instanceof X2ELibrary.
	at generate.generateElement(Project)(generate.mtl:15)
	at generate.generateElement(Project)(generate.mtl:12)

Re: [ACCELEO] Problem with casting [message #1471039 is a reply to message #1470891] Wed, 12 November 2014 21:00 Go to previous message
Martin Paquin is currently offline Martin PaquinFriend
Messages: 21
Registered: July 2014
Junior Member
I create a new project using the same models but this time I have another exception:

The type of the first parameter of the main template named 'generateElement' is a proxy


A simplify template
[comment encoding = UTF-8 /]
[**
 * The documentation of the module generate.
 */]
[module generate('http://www.eclipse.org/emf/2002/Ecore', 'http://www.eclipse.org/MoDisco/GASTM/1.0.Beta2/gastm', 'http://www.freschelegacy.com/x2e/SASTM/1.0/sastm')]


[**
 * The documentation of the template generateElement.
 * @param anEClass
 */]
[template public generateElement(project : Project)]
[comment @main/]
[file ('log.txt', false, 'UTF-8')]
	[project.eAllContents(X2ELibrary)/]
	[for (cu : CompilationUnit | project.files)]
		[cu.toString()/]
	[/for]
[/file]
[/template]


I use the same registration code as in the first program.

Here a copy of the manifest file
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Acceleo X2e2java Module Runtime Plug-in
Bundle-SymbolicName: com.freschelegacy.acceleo.module.x2e2java;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.freschelegacy.acceleo.module.x2e2java.Activator
Bundle-Vendor: Eclipse Modeling Project
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.emf.ecore,
 org.eclipse.emf.ecore.xmi,
 org.eclipse.ocl,
 org.eclipse.ocl.ecore,
 org.eclipse.acceleo.common;bundle-version="3.3.0",
 org.eclipse.acceleo.model;bundle-version="3.3.0",
 org.eclipse.acceleo.profiler;bundle-version="3.3.0",
 org.eclipse.acceleo.engine;bundle-version="3.3.0",
 org.eclipse.core.resources;bundle-version="3.9.1",
 org.eclipse.modisco.omg.gastm;bundle-version="0.12.1",
 com.freschelegacy.x2e.omg.sastm.synon;bundle-version="0.1.0",
 com.google.guava
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Eclipse-LazyStart: true
Export-Package: com.freschelegacy.acceleo.module.x2e2java.main



My version of Acceleo:
Version: 3.5.1.201409021433
Previous Topic:Re: Run-time errors in queries and templates
Next Topic:Maven plugin difficulties
Goto Forum:
  


Current Time: Tue Jan 16 19:29:58 GMT 2018

Powered by FUDForum. Page generated in 0.01455 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software