Get the value of a reference from Value Converter [message #1102980] |
Fri, 06 September 2013 09:08 |
Ashwini Nayak Messages: 19 Registered: July 2013 |
Junior Member |
|
|
Hello,
I have 2 classes in my xcore, say,
Class A
{
...
}
Class B
{
...
}
In my xtext grammar, I have a rule for each of the classes.
Rule for Class A:
------------------------
A:
"attribute" attribute=AttributeRule
..... //other attributes
B
....//other attributes
;
Here, B is a part of rule, A.
Rule for Class B:
------------------------
B:
..
;
Rule for AttributeRule:
-----------------------
AttributeRule:
..
;
I have a ValueConverter class for the rule, AttributeRule. In my ValueConverter class, I get the values for all the attributes of Rule A, but B is null (even though B is a part of A).
How do I get the value of B from ValueConverter class?
Thanks in advance.
[Updated on: Fri, 06 September 2013 09:11] Report message to a moderator
|
|
|
|
Re: Get the value of a reference from Value Converter [message #1103021 is a reply to message #1103004] |
Fri, 06 September 2013 09:53 |
Ashwini Nayak Messages: 19 Registered: July 2013 |
Junior Member |
|
|
For an attribute of rule A, I am using ValueConverter.
ValueConverter class
---------------------
toValue(string val, INode node)
{
...
//do calculation
}
Here, if I do node.getSemanticElement(), I get A. I get the values of all attributes of A here by calling get() method.
I have a method to get B - A.getB() which should return the reference B. But, it returns null.
I am not able to get the reference B.(My Class A has a reference to Class B as told in my previous comment.)
[Updated on: Fri, 06 September 2013 10:07] Report message to a moderator
|
|
|
|
Re: Get the value of a reference from Value Converter [message #1103061 is a reply to message #1103030] |
Fri, 06 September 2013 10:42 |
Ashwini Nayak Messages: 19 Registered: July 2013 |
Junior Member |
|
|
Hi Christian,
Sorry, the problem I mentioned was not very clear.
I have made an attempt to write it clearly in this comment.
Rule A:
-------
"name" name=ID "{"
"index" index = Index
"type" b=[B]
"}"
;
Rule for Index
--------------
Index:
INT | Double
;
Rule B:
-------
"name" name=ID "{"
"size" size = INT
"}"
ValueConverter class
--------------------
@ValueConverter(rule = "Index")
toValue(String string, INode node){
......
......
}
The data in my editor looks like this:
name A {
index 2.3
type B {
size 1
}
}
Within my toValue() method, I convert the value of 'index' to the required form.
I want to set some value to the 'size' field of B within this method.
And that size value should get reflected in the editor. Is this possible?
I tried to get the reference B from this method. But, it returns null.
Thanks
[Updated on: Fri, 06 September 2013 11:24] Report message to a moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03638 seconds