Home » Modeling » TMF (Xtext) » Extra output during serialization
Extra output during serialization [message #656249] |
Thu, 24 February 2011 11:50  |
Eclipse User |
|
|
|
Hi,
I would like to output comments during serialization of a model (that
does not yet have a node model). I would like to output these comments
before the output of certain semantic objects.
How can I achieve this? Need a hint where such code is best placed.
Regards
- henrik
|
|
| | |
Re: Extra output during serialization [message #656441 is a reply to message #656299] |
Fri, 25 February 2011 10:36   |
Eclipse User |
|
|
|
Have looked into the code, and debugged a bit. It seems quite
complicated. The IValueSerializer gets called for stuff *inside* the
semantic object so does not seem to give me the opportunity to emit
comments before the semantic object.
The MyLanguageParstreeReconstructor has lots of subclasses - one of them
where I want to output comments looks like this:
// "class"
protected class HostClassDefinition_ClassKeyword_0 extends KeywordToken {
public HostClassDefinition_ClassKeyword_0(AbstractToken
lastRuleCallOrigin, AbstractToken next, int transitionIndex,
IEObjectConsumer eObjectConsumer) {
super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
}
@Override
public Keyword getGrammarElement() {
return grammarAccess.getHostClassDefinitionAccess().getClassKeyword _0();
}
@Override
public AbstractToken createFollower(int index, IEObjectConsumer inst) {
switch(index) {
default: return lastRuleCallOrigin.createFollowerAfterReturn(this,
index, index, inst);
}
}
}
To me this looks like it is building a structure that is traversed in a
later step.
In
org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractToken,
WsMergerStream, ITextRegion)
I can see how each part gets processed, but I am uncertain about the
contract (can I just write some text) - and how to write comment data.
I can imagine that the functionality I am interested in is of value to
others as well. i.e. create a semantic model, associate comments with
semantic objects, and get the comment text serialized. It is very useful
for things like "// generated by xyz, tranformed from...
Not sure how to proceed at this point... any pointers or suggestions?
- henrik
On 2/25/11 12:51 AM, Sebastian Zarnekow wrote:
> Hi Henrik,
>
> this is a tough question and I'm afraid I cannot provide an answer
> without digging into a concrete YourLangParsetreeConstructor and the
> formatting stuff. I can imagine that the IValueSerializer provides a way
> to achieve this but I'm not 100% sure.
>
> Regards,
> Sebastian
|
|
|
Re: Extra output during serialization [message #656443 is a reply to message #656441] |
Fri, 25 February 2011 11:16   |
Eclipse User |
|
|
|
Hi Henrik,
the architecture of the 1.x serializer was not really designed for
customization. That's why Moritz is currently in the process of
rewriting it completely. The focus will be more on extensibility and
maintainability. As we are currently not sure whether the serializer 2.0
will be the default in Xtext 2.0 or only an experimental option, it may
be the easiest way for to
a) wait for the new serializer (it's due May)
b) traverse your model manually and emit text to a stringbuffer (in
other words: write your own serializer).
I'm afraid I cannot provide any more insights on the old serializer's
architecture / control flow / code structure / entry points. It'd
require a detailed analysis of of a specific language.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 25.02.11 16:36, schrieb Henrik Lindberg:
> Have looked into the code, and debugged a bit. It seems quite
> complicated. The IValueSerializer gets called for stuff *inside* the
> semantic object so does not seem to give me the opportunity to emit
> comments before the semantic object.
>
> The MyLanguageParstreeReconstructor has lots of subclasses - one of them
> where I want to output comments looks like this:
>
> // "class"
> protected class HostClassDefinition_ClassKeyword_0 extends KeywordToken {
>
> public HostClassDefinition_ClassKeyword_0(AbstractToken
> lastRuleCallOrigin, AbstractToken next, int transitionIndex,
> IEObjectConsumer eObjectConsumer) {
> super(lastRuleCallOrigin, next, transitionIndex, eObjectConsumer);
> }
>
> @Override
> public Keyword getGrammarElement() {
> return grammarAccess.getHostClassDefinitionAccess().getClassKeyword _0();
> }
>
> @Override
> public AbstractToken createFollower(int index, IEObjectConsumer inst) {
> switch(index) {
> default: return lastRuleCallOrigin.createFollowerAfterReturn(this,
> index, index, inst);
> }
> }
>
> }
>
> To me this looks like it is building a structure that is traversed in a
> later step.
>
> In
> org.eclipse.xtext.parsetree.reconstr.impl.AbstractParseTreeC onstructor.write(AbstractToken,
> WsMergerStream, ITextRegion)
>
> I can see how each part gets processed, but I am uncertain about the
> contract (can I just write some text) - and how to write comment data.
>
> I can imagine that the functionality I am interested in is of value to
> others as well. i.e. create a semantic model, associate comments with
> semantic objects, and get the comment text serialized. It is very useful
> for things like "// generated by xyz, tranformed from...
>
> Not sure how to proceed at this point... any pointers or suggestions?
>
> - henrik
>
> On 2/25/11 12:51 AM, Sebastian Zarnekow wrote:
>> Hi Henrik,
>>
>> this is a tough question and I'm afraid I cannot provide an answer
>> without digging into a concrete YourLangParsetreeConstructor and the
>> formatting stuff. I can imagine that the IValueSerializer provides a way
>> to achieve this but I'm not 100% sure.
>>
>> Regards,
>> Sebastian
>
|
|
|
Re: Extra output during serialization [message #656465 is a reply to message #656443] |
Fri, 25 February 2011 13:34  |
Eclipse User |
|
|
|
I rhink will wait for the new framework.
Meanwhile, if you thinknit is meaningful, if you want to take a look at the
code, it is at github cloudsmith/geppetto (projects *.pp*).
- henrik
Sebastian Zarnekow <Sebastian.Zarnekow@itemis.de> wrote:
> Hi Henrik,
>
> the architecture of the 1.x serializer was not really designed for
> customization. That's why Moritz is currently in the process of rewriting
> it completely. The focus will be more on extensibility and
> maintainability. As we are currently not sure whether the serializer 2.0
> will be the default in Xtext 2.0 or only an experimental option, it may
> be the easiest way for to
>
> a) wait for the new serializer (it's due May)
> b) traverse your model manually and emit text to a stringbuffer (in other
> words: write your own serializer).
>
> I'm afraid I cannot provide any more insights on the old serializer's
> architecture / control flow / code structure / entry points. It'd require
> a detailed analysis of of a specific language.
>
> Regards,
> Sebastian
--
- henrik
|
|
|
Goto Forum:
Current Time: Mon Jul 07 15:52:11 EDT 2025
Powered by FUDForum. Page generated in 0.12863 seconds
|