Getting comments from the node model [message #1567778] |
Fri, 16 January 2015 10:19  |
Eclipse User |
|
|
|
Hi,
I've been trying to get comments from a node model, so that I can inject them into an EMF model for separate persistence. But, it is not working as I expected. I assumed that the node associated with an EObject (representing a keyword in the text, for instance) would contain a tree (or some graph) of sub elements, related to the DSL spec.
To illustrate, I have a problem with comments on an axiom,
Axiom returns context::Axiom:
'@'name=EString
predicate=EString?
(theorem?='theorem')?
('//' comment=EString)?
;
When trying to obtain comments from the node model, if you can see the graphic attached, the comment associated with axm2 (note 1) using node.getText() is incorrect. In the xtext it is associated with axm1 (note 2). In some cases the comments are lost, so I am obviously doing something wrong.
In my code I use NodeModelUtils.getNode(eobj) to get a composite node, and ICompositeNode.getChildren() method to get an iterator. Is my assumption correct, that the comment should be navigable through an iterator obtained from the Axiom EObject?
Any hints would be appreciated.
Many thanks,
Andy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Getting comments from the node model [message #1572673 is a reply to message #1572641] |
Mon, 19 January 2015 04:09  |
Eclipse User |
|
|
|
>> if you want to serialize it as non xtext? so you simply want to find the nodes on the existing nodemodel?
>> then your first approach in looking at the node model should be fine
Ok, this works, but seems a bit messy since some of the comments (those on the first line of the my file) appear lower in the node model's tree than the semantic text they are associated with; most other comments appear higher in the tree than the associated text. I also seem to have spurious newline characters and text, when I get comment text from the node using INode.getText(), which is rather strange.
>> if your comments arent hidden at all mabye you should exclude them from the hidden clase
They are hidden wrt to parsing.
>> which serializer(fragment) do you use?
Which should I be using, if any needs to be specified?
|
|
|
Powered by
FUDForum. Page generated in 0.06789 seconds