Home » Modeling » M2T (model-to-text transformation) » Strange result in query
|
Re: Strange result in query [message #667790 is a reply to message #667299] |
Mon, 02 May 2011 09:02 |
|
Hi Hallvard,
Seems to me like a variable leak in Acceleo. Could you raise a bug against M2T/Acceleo for this?
As for what you are trying to achieve ... Wouldn't it be easier with something like :
[ancestors(Package)->reverse().name->sep('.')/]
i.e "retrieve all ancestors of type "Package", reverse the list so that the root is first in the list, get all their names, then separate these names with dots". This is what we usually use when computing qualified names.
Laurent Goubet
Obeo
|
|
|
Re: Strange result in query [message #667805 is a reply to message #667790] |
Mon, 02 May 2011 09:44 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
On 02.05.11 11.02, Laurent Goubet wrote:
>
> Seems to me like a variable leak in Acceleo. Could you raise a
> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=M2T& component=Acceleo for
> this?
Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=344424
> As for what you are trying to achieve ... Wouldn't it be easier with
> something like :
>
> [ancestors(Package)->reverse().name->sep('.')/]
I didn't know about the ancestors function, thanks! However, the root
package is not the root of the model, so I think this would give me an
extra element that I need to remove (before or after doing reverse, I
guess).
Ideally, there is I would like to use a function that traverses along a
named relation (not necessarily the ancestor chain), 'package' in my
case, and collects them until it is null/empty. Does such a function
exist? Can I perhaps use OCL iterate construct?
Hallvard
|
|
|
Re: Strange result in query [message #667806 is a reply to message #667805] |
Mon, 02 May 2011 09:48 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
On 02.05.11 11.44, Hallvard Trætteberg wrote:
> On 02.05.11 11.02, Laurent Goubet wrote:
>>
>> Seems to me like a variable leak in Acceleo. Could you raise a
>> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=M2T& component=Acceleo
>> for
>> this?
>
> Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=344424
>
>> As for what you are trying to achieve ... Wouldn't it be easier with
>> something like :
>>
>> [ancestors(Package)->reverse().name->sep('.')/]
>
> I didn't know about the ancestors function, thanks! However, the root
> package is not the root of the model, so I think this would give me an
> extra element that I need to remove (before or after doing reverse, I
> guess).
Sorry, I didn't notice the Package (oclType) argument, which filters out
non-Package object. Thanks for the tip!
Hallvard
|
|
|
Re: Strange result in query [message #667809 is a reply to message #667806] |
Mon, 02 May 2011 10:07 |
Hallvard Traetteberg Messages: 673 Registered: July 2009 Location: Trondheim, Norway |
Senior Member |
|
|
On 02.05.11 11.48, Hallvard Trætteberg wrote:
> On 02.05.11 11.44, Hallvard Trætteberg wrote:
>> On 02.05.11 11.02, Laurent Goubet wrote:
>>>
>>> Seems to me like a variable leak in Acceleo. Could you raise a
>>> https://bugs.eclipse.org/bugs/enter_bug.cgi?product=M2T& component=Acceleo
>>>
>>> for
>>> this?
>>
>> Done: https://bugs.eclipse.org/bugs/show_bug.cgi?id=344424
>>
>>> As for what you are trying to achieve ... Wouldn't it be easier with
>>> something like :
>>>
>>> [ancestors(Package)->reverse().name->sep('.')/]
>>
>> I didn't know about the ancestors function, thanks! However, the root
>> package is not the root of the model, so I think this would give me an
>> extra element that I need to remove (before or after doing reverse, I
>> guess).
>
> Sorry, I didn't notice the Package (oclType) argument, which filters out
> non-Package object. Thanks for the tip!
Update: ancestors(Package)->reverse().name gives an error marker. I
think it's because reverse isn't recognized, since
ancestors(Package).name works. BTW, I'm using Acceleo 3.0.2 with Helios.
Hallvard
|
|
|
Re: Strange result in query [message #667818 is a reply to message #667299] |
Mon, 02 May 2011 10:32 |
|
Hallvard,
I know we've fixed a number of bugs with both the "reverse" and "ancestors" services ... but I don't remember which . The 3.1.0 M7 build for Acceleo will be available tomorrow, and it should fix the issue you have with this query.
In the meantime, and if memory serves, you should be able to use this query instead :
[ancestors(Package)->asSequence()->reverse().name->sep('.')/]
As I seem to remember something about "ancestors" not being statically typed to a Sequence or OrderedSet (i.e. an ordered collection) and thus "reverse" not being applicable.
If that doesn't fix it, could you provide me with the message associated with this compilation error?
Laurent Goubet
Obeo
|
|
| |
Re: Strange result in query [message #667884 is a reply to message #667299] |
Mon, 02 May 2011 15:12 |
|
ha, that one . It has been fixed too. The problem was that "reverse" lost the typing of the collection, ancestors(Package) returns a Collection(Package) but "Collection(Package)->reverse()" returns a Collection(T) ... and "name" does not exist on "T".
You can work around this by manually re-casting :
[ancestors(Package)->reverse().oclAsType(Package).name->sep('.')/]
These problems are fixed in Acceleo 3.1.
Laurent Goubet
Obeo
|
|
| |
Re: Strange result in query [message #667971 is a reply to message #667935] |
Tue, 03 May 2011 07:39 |
|
Quote: |
When you use -> it is a method on the collection (object), right. While
when you use . it applies to every element in the collection? So
..oclAsType(Package) means the same as ->oclAsType(Sequence(Package))
(not sure if that's correct ocl, but you understand what I mean)?
|
Yup, though "oclAsType" cannot be used on a Collection (with a "->") AFAIK.
Quote: |
Quote: |
These problems are fixed in Acceleo 3.1.
|
Which is coming to a place near you, soon
|
The M7 will be available today on the Milestones update site.
Laurent Goubet
Obeo
|
|
|
Goto Forum:
Current Time: Tue Dec 10 11:45:58 GMT 2024
Powered by FUDForum. Page generated in 0.05015 seconds
|