Home » Modeling » TMF (Xtext) » Extra output during serialization
| | |
Re: Extra output during serialization [message #656441 is a reply to message #656299] |
Fri, 25 February 2011 15:36 |
Henrik Lindberg Messages: 2509 Registered: July 2009 |
Senior Member |
|
|
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 16:16 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
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
>
|
|
| |
Goto Forum:
Current Time: Sun Sep 22 08:53:54 GMT 2024
Powered by FUDForum. Page generated in 0.04642 seconds
|