Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Extra output during serialization
Extra output during serialization [message #656249] Thu, 24 February 2011 16:50 Go to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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 #656299 is a reply to message #656249] Thu, 24 February 2011 23:51 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
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
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 24.02.11 17:50, schrieb Henrik Lindberg:
> 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 #656306 is a reply to message #656299] Fri, 25 February 2011 00:25 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Thanks, then I know where to start looking...
- henrik
Sebastian Zarnekow <Sebastian.Zarnekow@itemis.de> 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


--
- henrik
Re: Extra output during serialization [message #656441 is a reply to message #656299] Fri, 25 February 2011 15:36 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
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 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
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
>
Re: Extra output during serialization [message #656465 is a reply to message #656443] Fri, 25 February 2011 18:34 Go to previous message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
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
Previous Topic:using content assist and syntax highlighting without Eclipse
Next Topic:Global Scope, Filtering and name collisions
Goto Forum:
  


Current Time: Sun Sep 22 08:53:54 GMT 2024

Powered by FUDForum. Page generated in 0.04642 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top