Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] Working with list attributes

One more note: in the graphical editor, you can use the arrow notation to define a change in a list attribute. So you would write something like:

x -> x.add(new Integer(4)); x;

Don't forget to define x as rule parameter.

Cheers,
Christian

Am 2/1/2013 11:45 AM, schrieb Christian Krause:
Hi all,

I added support for working with list attributes. Say you have an attribute of type int with an upper bound of -1. There are two possible ways for handling these attribute values:

- as constants: you use as attribute value a comma-separated list of constants surrounded by brackets, e.g. [1,2,3]. Henshin will automatically treat this as a list of integers.

- matching the lists by parameters: say you have a parameter x in your rule, you can match it with the list attribute value of an object. You can then use JavaScript to manipulate the list. For example, you can write

x.add(new Integer(4)); x;

to add 4 to the integer list. Note that the "return"-value of the expression must be the (modified) list.

Cheers,
Christian

PS: I will commit the code in the evening. The new version should be available in 24-48 hours at the nightly builds update site. Also, there are two new tests for this new feature.




Back to the top