Cann't get Array Type elements? [message #1691863] |
Fri, 10 April 2015 04:31  |
Eclipse User |
|
|
|
Hi all!
I'v know how to define array type grammar, like this:
UclArrayValue:
'['
(elements+=UclArrayElement (',' elements+=UclArrayElement)*)?
']'
;
UclArrayElement:
INT | STRING |UclObjectValue
;
the language example:
Product prod222
{
prodID : 222;
attributes[ "xxx","yyy" ];
}
I can't get the UclArrayValue's elements instance.
my java code is as:
if(value instanceof UclArrayValue)
{
ArrayList attValueList=new ArrayList();
UclArrayValue arrayValue=(UclArrayValue)value;
EList<UclArrayElement> arrayElements=arrayValue.getElements();
EList<EObject> sss=arrayValue.eContents();
TreeIterator<EObject> iter=arrayValue.eAllContents();
while(iter.hasNext())
{
EObject eo=iter.next();
System.out.println(eo.toString());
}
for(UclArrayElement ele:arrayElements)
{
attValueList.add(ele.toString());
}
}
all the APIs can't give me elements list. getElements(),eContents() and eAllContents() return empty EList.
the XText version is 2.7.3.
thanks!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06314 seconds