Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo3] using ecore in query
[Acceleo3] using ecore in query [message #666374] Wed, 20 April 2011 08:24 Go to next message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 209
Registered: June 2010
Senior Member
Hi,

I created a meta model and am experimenting with code generation.

In this, I have a PG_Return meta class that either might occur inside a PG_Calc or a PG_GetCalc object. The generated code depends on the context PG_Return is used in. Therefore, I created a query that checks whether the context of the PG_Return instance is within PG_GetCalc.

[query public inGetCalcContext(s: PG_Statement) : Boolean = 
let container: EObject = s.eContainer() 
in
	if (container <> null) and (container.oclIsTypeOf(PG_GetCalc)) 
	then
		true
	else
	    if (container = null) 
	    then
	    	false
	    else
	    	inGetCalcContext(container)
	    endif
	endif
/]


However, Acceleo complains that it doesn't know EObject? Is it not possible to use ecore concepts like above?

Greetings,
Wilbert
Re: [Acceleo3] using ecore in query [message #666667 is a reply to message #666374] Thu, 21 April 2011 13:55 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 Wilbert,

If you want to use Ecore, you have to declare it in the header of your module:
[module generate('http://www.myawesomemetamodel.com', 'http://www.eclipse.org/emf/2002/Ecore')]


Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Re: [Acceleo3] using ecore in query [message #666673 is a reply to message #666667] Thu, 21 April 2011 14:08 Go to previous message
Wilbert Alberts is currently offline Wilbert AlbertsFriend
Messages: 209
Registered: June 2010
Senior Member
Hi Stephane ,

Again your answer was right to the spot for which I thank you.

However, in the documentation I stumbled across the 'Acceleo non standard operations reference'. The thing I wanted to achieve can also be solved using the 'ancestors' operation. Let's use as much as possible the provided operations.

Thanks,
Wilbert.

Previous Topic:Problem with using annotations in acceleo
Next Topic:[Acceleo] Generate a complex inheritance list
Goto Forum:
  


Current Time: Thu Apr 25 10:45:47 GMT 2024

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

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

Back to the top