|
Re: Adding comments during serialization (without Node model) [message #1507028 is a reply to message #1505807] |
Thu, 11 December 2014 08:59 |
Moritz Eysholdt Messages: 161 Registered: July 2009 Location: Kiel, Germany |
Senior Member |
|
|
Hi Christoph,
you can overwrite
org.eclipse.xtext.serializer.sequencer.HiddenTokenSequencer.emitHiddenTokens(List<INode>)
This method is called for each token - before it get written out.
The parameter "hiddens" will be null in your scenario. It's only available if the to-be-serialized model has been created by the parser.
You're probably also interested in
org.eclipse.xtext.serializer.sequencer.HiddenTokenSequencer.enterAssignedAction(Action, EObject, ICompositeNode) and
org.eclipse.xtext.serializer.sequencer.HiddenTokenSequencer.enterAssignedParserRuleCall(RuleCall, EObject, ICompositeNode)
They're called before the tokens of the next EObject are about to be serialized.
Inside emitHiddenTokens(...) you can call
delegate.acceptComment(grammarElement, text, node);
You can pass 'null' as the node.
A good pattern is it to create a custom EMF Adapter that holds you comments. Then your M2M transformation can hook this adapter into all EObject that are supposed to have comments. Your subclass of the HiddenTokenSequencer will then check for the adapter, take the comments, and call delegate.acceptComment() for each comment.
hth,
Moritz
|
|
|
Powered by
FUDForum. Page generated in 0.04309 seconds