Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Generation templates not working with run-time meta-models and dynamic instances
[Acceleo] Generation templates not working with run-time meta-models and dynamic instances [message #667521] Fri, 29 April 2011 10:42 Go to next message
Niels Brouwers is currently offline Niels BrouwersFriend
Messages: 80
Registered: July 2009
Member
Hi all,

I have created a dynamic instance model, based on the following meta-model:

module _'MyEcoreModel.ecore'
package myEcoreModel : myEcoreModel = 'http://nl.example.metamodel'
{
	class SomeClass
	{
		attribute name : String[?] { ordered };
	}
}


The contents of the instance model is as follows:

<?xml version="1.0" encoding="ASCII"?>
<myEcoreModel:SomeClass 
	xmi:version="2.0" 
	xmlns:xmi="http://www.omg.org/XMI" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:myEcoreModel="http://nl.example.metamodel" 
	xsi:schemaLocation="http://nl.example.metamodel ../../model/MyEcoreModel.ecore" 
	name="someName"
/>


Next, I have create an Acceleo template to generate some text from the dynamic instance model:

[comment encoding = UTF-8 /]
[module generate('http://nl.example.metamodel')/]

[template public generate(a : SomeClass)]
	[comment @main /]
	[file ('output.txt', false, 'UTF-8')]
	[a.name/]
	[/file]
[/template]


Problem:
The Java class generated from the main generator module, Generate.java contains a compile error in the following code fragment:

	/**
	 * 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
	 */
	@Override
	public void registerPackages(ResourceSet resourceSet) {
        super.registerPackages(resourceSet);
        if (!isInWorkspace(org.eclipse.emf.ecore.impl.EPackageImpl.class)) {
            resourceSet.getPackageRegistry().put(org.eclipse.emf.ecore.impl.EPackageImpl.eINSTANCE.getNsURI(), org.eclipse.emf.ecore.impl.EPackageImpl.eINSTANCE);
        }
        // TODO If you need additional package registrations, do them here. The following line is an example for UML.
        // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
    }


The compile error is located on line 291, the line starting with: resourceSet..... and contains the following message:

Multiple markers at this line
	- eINSTANCE cannot be resolved or is not 
	 a field
	- eINSTANCE cannot be resolved or is not 
	 a field


Current environment: Eclipse Indigo M6a

Note: i've tested generation using the same meta-model, instance model and generation templates in a Eclipse Helios R2 distribution and experienced no problems there.

Is there something I am doing wrong or is this related to the following bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=337011?

Kind regards,
Niels Brouwers.


Kind regards,
Niels Brouwers.

[Updated on: Fri, 29 April 2011 10:42]

Report message to a moderator

Re: [Acceleo] Generation templates not working with run-time meta-models and dynamic instances [message #667526 is a reply to message #667521] Fri, 29 April 2011 11:42 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Niels,

The problem has been fixed after M6 (I think the fix is available in M6a). It was related to those bugs:
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=340814
- https://bugs.eclipse.org/bugs/show_bug.cgi?id=340086

The bug that you are linking was for another problem with dynamic metamodels. The fix for this bug will be available in Acceleo 3.1.0 M7 next week.

You may fix it by changing "@generated" in the comment to "@generated NOT" and then remove/change the line.

Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Re: [Acceleo] Generation templates not working with run-time meta-models and dynamic instances [message #667537 is a reply to message #667526] Fri, 29 April 2011 12:29 Go to previous messageGo to next message
Niels Brouwers is currently offline Niels BrouwersFriend
Messages: 80
Registered: July 2009
Member
Hi Stephane,

I had already tried that, so I was confused why you suggested the same work-around. First, removing the errornous line did not result in any errors while running the generator, nor did it result in any output.

So, I looked further. The solution was to convert the project containing the meta-model into a plugin project and add this project as dependency to the generator project. This solved the problem. Strange why it did not produce any error somewhere. I've checked the console, problems and error log views.

I would like to suggest to report an error if, for some reason, the meta-model could not be found.

Stephane, thanx for your help!

Kind regards,
Niels Brouwers.


Kind regards,
Niels Brouwers.
Re: [Acceleo] Generation templates not working with run-time meta-models and dynamic instances [message #667544 is a reply to message #667537] Fri, 29 April 2011 13:15 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi Niels,

I had already tried that, so I was confused why you suggested the same work-around. First, removing the errornous line did not result in any errors while running the generator


That specific line should not exist, because EPackageImpl.eINSTANCE does not exist. I have also added an error if we do not generate anything because we have a problem.

Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Re: [Acceleo] Generation templates not working with run-time meta-models and dynamic instances [message #667734 is a reply to message #667544] Sun, 01 May 2011 20:30 Go to previous message
Niels Brouwers is currently offline Niels BrouwersFriend
Messages: 80
Registered: July 2009
Member
Hi Stephane,

oke, thanxs for the support.

Kind regards,
Niels Brouwers.


Kind regards,
Niels Brouwers.
Previous Topic:T2T
Next Topic:[Acceleo] use of macro / let(loop)
Goto Forum:
  


Current Time: Fri Apr 19 23:43:07 GMT 2024

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

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

Back to the top