|
Re: [Acceleo] Let block syntax [message #482654 is a reply to message #482616] |
Thu, 27 August 2009 13:15 |
|
This is a multi-part message in MIME format.
--------------030502030004010406090300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi Guillaume,
Until recently, the let blocks couldn't be parsed when the type of their
initilalisation wasn't right (
https://bugs.eclipse.org/bugs/show_bug.cgi?id=242744 ). This has been
fixed, but you'll have to wait for the next integration build.
Laurent Goubet
Obeo
Guillaume Bourel a
|
|
|
Re: [Acceleo] Let block syntax [message #482805 is a reply to message #482654] |
Fri, 28 August 2009 06:14 |
Eclipse User |
|
|
|
Originally posted by: loic.fejoz.realtimeatwork.com
Hi,
I believe it works if you add oclAsType:
[let ac : AssociationClass = c.oclAsType(AssociationClass) ]
--
regards,
Loïc Fejoz
laurent Goubet a écrit :
> Hi Guillaume,
>
> Until recently, the let blocks couldn't be parsed when the type of their
> initilalisation wasn't right (
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=242744 ). This has been
> fixed, but you'll have to wait for the next integration build.
>
> Laurent Goubet
> Obeo
>
> Guillaume Bourel a écrit :
>> Hey,
>>
>> I was wondering how to use the [let] block within Acceleo :
>>
>> I tried the same syntax as in http://www.omg.org/spec/MOFM2T/1.0/
>>
>> [template public classToJava(c : Class)]
>> [let ac : AssociationClass = c ]
>> class [c.name/]
>> {
>> // Constructor
>> [c.name/]()
>> {
>> }
>> // Association class methods
>> [for (t:Type | ac.endType)]
>> Attach_[t.name/]([t.name/] p[t.name/])
>> {
>> // Code for the method here
>> }
>> [/for]
>> }
>> [/let]
>> [/template]
>>
>>
>> But "ac.endType" raise the following error :
>> "Init expression type does not conform to type of variable (ac)."
>>
>> Did I miss something ?
>
|
|
|
|
Re: [Acceleo] Let block syntax [message #483092 is a reply to message #482860] |
Mon, 31 August 2009 06:48 |
Eclipse User |
|
|
|
Originally posted by: loic.fejoz.realtimeatwork.com
Guillaume Bourel a écrit :
> Loïc Fejoz a écrit :
>> Hi,
>>
>> I believe it works if you add oclAsType:
>> [let ac : AssociationClass = c.oclAsType(AssociationClass) ]
>>
> Thanks for the tip,
>
> this syntax doesn't complains at build time but at runtime, there is a
> java exception from org.eclipse.acceleo.engine if "c" isn't an
> "AssociationClass" instance
Hi,
Obviously if you are not 100% sure that your object is an association
class then surround the let with a conditional...
--
regards,
Loïc Fejoz
|
|
|
|
Re: [Acceleo] Let block syntax [message #518838 is a reply to message #518820] |
Fri, 05 March 2010 09:18 |
|
This is a multi-part message in MIME format.
--------------090106080205030508050207
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi Maxime,
I'll just quote the MTL specification on that as I don't support the OMG
choice on the naming "let" :
"
A let block declares and initializes a variable of type subtype when the
cast is successful. Essentially, it can be seen as a
test that checks whether the object bound to the supertype variable is
actually an instance of the specified subtype and
execution of the associated block on success.
"
In other words ... an MTL "let" block is no more than a "if ...
oclIsKindOf" test. This is semantically incoherent with the OCL "let".
That said, I believe the parsing of your expression should have worked
alright ... how exactly does it fail? At parsing time (with what error
message)? Or rather at runtime (again, what would be the error message)?
Laurent Goubet
Obeo
Maxime Leray wrote:
> Hi,
> I'm working with the last acceleo version (0.9M5) and I have a question
> concerning the let block.
>
> I have a template with a custom metamodel, which define a Diagram
> element. Then, I use a let block as:
> [let d : Diagram = self.getDiagram('MyDiagramName')] // getDiagram is a
> Java service that I call through an invoke method
> [d.name/]
> [/let]
> The result of this template should write 'MyDiagramName', but actually,
> I have an OCL error while parsing the template: the parser tries to
> parse self.getDiagram('MyDiagramName').oclAsType(Diagram) and seems to
> fail because of the Diagram declaration.
>
> Do you have any clue on how to correctly declare that block?
--------------090106080205030508050207
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"
YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------090106080205030508050207--
|
|
|
Powered by
FUDForum. Page generated in 0.03713 seconds