[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [henshin-dev] Compare two node's attributes in rule?
|
Hi Jens,
Am 1/7/2013 4:36 PM, schrieb Jens Bürger:
Hi,
In addition to my last question, it would be important for me to
compare the attributes values of two nodes of the same type.
Say I have two nodes of the type critical.
Every node has the attribute "high". I want to create a rule which has
a match if the values of the two "high"-attributes do differ.
For doing this, the rule should have two parameters, say x and y. If you
want to use parameter types, they should have the same type as the
high-attribute. Now you should match the high-attribute of the one node
with x and the one with y. So in the graphical editor you should enter
"high=x" and "high=y" as node attributes. The trick now is to create an
AttributeCondition and set the condition text to "x!=y" (assuming the
high attribute is of a primitive type or an enum). The graphical editor
does not support AttributeConditions yet. So you have to do it in the
tree-based editor. You can create AttributeConditions as children of Rules.
Is there any documentation on how Henshin calculates values of the
"Value"-property and what it's features are?
We don't have a manual I am afraid. In general, the interpreter does not
offer any special syntax for attribute calculations. What happens is
that we use a JavaScript engine to make these calculations. The
parameters of a rule are used as JavaScript variables. Attribute values
or conditions that you define in rules are then just evaluated using
this JavaScript engine.
That being said, there are some exceptions. For instance, when the
attribute values are constants (like enums), we avoid using JavaScript
to improve the performance. In the case of list attributes, I think we
also need some special treatment (we can still use JavaScript for the
elements of the list I guess).
Hope this help.
Cheers,
Christian
Jens
_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/henshin-dev