Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Unable to make a query with collection as return type
[Acceleo] Unable to make a query with collection as return type [message #64963] Sun, 26 July 2009 12:15 Go to next message
Alexis Muller is currently offline Alexis MullerFriend
Messages: 13
Registered: July 2009
Junior Member
Hello,

The current acceleo version (2.6.0 with galileo) is not able to compile a
query with a Set as return type.

For example :

[module umlUtils('http://www.eclipse.org/uml2/2.1.0/UML')/]

[query public allAssociations (m : Model) : Set (Association) =
m.allOwnedElements()->select (oclIsKindOf(Association))/]

Says :
Invalid Type:Set (Association)

According to the OMG specification this must be works.

Thanks for your great work on acceleo.

Best regards,
Alexis
Re: [Acceleo] Unable to make a query with collection as return type [message #64975 is a reply to message #64963] Sun, 26 July 2009 16:58 Go to previous messageGo to next message
Alexis Muller is currently offline Alexis MullerFriend
Messages: 13
Registered: July 2009
Junior Member
Interesting....

If I write :

[query public allAssociations (m : Model) : Association =
m.allOwnedElements()->select (oclIsKindOf(Association))/]


A collection is returned. Is it a standard behavior ?

Regards,

Alexis
Re: [Acceleo] Unable to make a query with collection as return type [message #65089 is a reply to message #64975] Mon, 27 July 2009 09:51 Go to previous messageGo to next message
Max Bureck is currently offline Max BureckFriend
Messages: 72
Registered: July 2009
Member
Hi,

I think your problem is the same as I reported here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=262153

It seems that editor and runtime sometimes do no type-checks where you
would expect them. E.g. the following code is working if the package p
contains only classes:

[template public generate(p : Package)]
[for (c : Class | p.ownedType->select(t:Type|t.oclIsTypeOf(uml::Class)))]
[c.genereateClass()/]
[/for]
[/template]

The return type of the the statement
p.ownedType->select(t:Type|t.oclIsTypeOf(uml::Class)) is Set(Type) and not
Set(Class). Still, neither the editor, nor the engine complains. The
correct statement would be
p.ownedType->select(t:Type|t.oclIsTypeOf(uml::Class))->collect(t:Type|t.oclAsType(uml::Class))

By the way: This is a very bloated expression, but I think it cannot be
written in a shorter way using standard OCL. I hope in the next version of
the MTL standard they adopt some shortcuts from QVT-OM. In QVT-OM you can
write p.ownedType[uml::Class] to achieve the same.

Greetings,
Max
Re: [Acceleo] Unable to make a query with collection as return type [message #65156 is a reply to message #65089] Mon, 27 July 2009 11:09 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060805060500080004090103
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Hi,

> By the way: This is a very bloated expression, but I think it cannot
> be written in a shorter way using standard OCL.

The only shortcuts I can think of for your expression is to make use of
the implicit collect and variables :
p.ownedType->select(oclIsTypeOf(uml::Class)).oclAsType(uml::Class)

That being said, you can take a look at this newsgroup thread
http://www.eclipse.org/newsportal/article.php?id=1885&gr oup=eclipse.modeling.mdt.ocl#1885
for details on why the implementation doesn't check the return type of
these selects.

As for the first query given as an exemple here, I believe Acceleo has
its own issues with parsing parameterized collections (instead of
Set(Association), you could have written 'Set(T)") that we must attend
to. OCL on its side has some opened bugs on such issues that could be
the source of yours : https://bugs.eclipse.org/bugs/show_bug.cgi?id=191819 .

Laurent Goubet
Obeo

Max Bureck a
Previous Topic:[Acceleo] extending Module
Next Topic:Model Loader for UML
Goto Forum:
  


Current Time: Tue Apr 23 17:33:38 GMT 2024

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

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

Back to the top