|
|
|
|
|
Re: Assigning rule generated target model elements to a contained reference [message #632614 is a reply to message #632598] |
Wed, 13 October 2010 15:16 |
Dimitrios Kolovos Messages: 1776 Registered: July 2009 |
Senior Member |
|
|
Hi James,
equivalent() and equivalents() return different results depending on
whether they are invoked on objects or collections. For an object "o"
and a collection "c":
o.equivalent() -> returns one object
o.equivalents() -> returns a collection of objects
c.equivalent() -> returns a collection of objects
c.equivalents() -> returns a collection of collections
Therefore, the fact that
vProc.processStatements.equivalents() -> Bag {Sequence {HaskellStatement
[]}, Sequence {}}
means that processStatements is a collection which contains 2 objects,
the first of which has generated 1 HaskellStatement object and the
second has generated nothing.
Does this help?
Cheers,
Dimitris
James Sharp wrote:
> Hi Dimitris,
>
> My results when using equivalent() and equivalents() does not follow
> this pattern, (or maybe I have just not understood how to assign the
> values properly)
>
> I have the line:
>
> cProc.processStatement.letHaskellStatements.addAll(vProc.pro
> cessStatements.equivalent());
>
> which returns:
> Bag {HaskellStatement []} <- just one element as you say:
>
> However if I use:
> cProc.processStatement.letHaskellStatements.addAll(vProc.pro
> cessStatements.equivalents());
>
> this returns:
> Bag {Sequence {HaskellStatement []}, Sequence {}}
>
> And I get the error message:
> Internal error: java.lang.ArrayStoreException
> at org.eclipse.emf.common.util.BasicEList.assign[BasicEList.jav a:124]
>
> If I remove the @lazy from the rule I get 2 HaskellStatements generated
> within my model (albeit not assigned to the correct object).
>
> Should I be getting back both HaskellStatements? Should they be wrapped
> as Sequence like this for equivalents()?
>
>
> The Lazy rule producing them is:
> @lazy
> rule Assignment2HaskellStatement
> transform vAssignment : vhdl!Assignment
> to hStatement : csp!HaskellStatement {
>
> hStatement.assignsValueTo := csp!TypeItem.select
>
> (item|vAssignment.assignValueTo.usesElement.name.isSubstring
> Of(item.name)).first();
>
> }
>
> Sorry but totally lost why this is the result I am getting here, any
> help would be greatly appreciated.
>
> Many Thanks,
>
> James
|
|
|
|
Powered by
FUDForum. Page generated in 0.03069 seconds