Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Calling the serializer preserving original formatting
Calling the serializer preserving original formatting [message #1002428] Fri, 18 January 2013 15:01 Go to next message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
Hi all

I'd like to call the serializer preserving the original formatting, while when I call it, the format of the resulting textual representation is determined by the Formatter.

Is it possible in some way to preserve original formatting?

I read in the documentation that SaveOptions can be passed to the serializer to disable the formatter:

Quote:
If disabled, the formatter only defi nes white space information for the places in which no white space information can be preserved from the node model.


but I cannot understand how. Sad [And I do not know if this affects what I want. Confused]

Could you please help me? Rolling Eyes


Marco
Re: Calling the serializer preserving original formatting [message #1002504 is a reply to message #1002428] Fri, 18 January 2013 18:08 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
Look at the SaveOptions class. I think you create one, and then tell it
to "preserve whitespace" or somesuch. That means "no formatting".

Inserting spaces then takes place only where there is not source text as
the source of the model (i.e, when there are semantic changes that are
not (yet) reflected in text.

Hope that helps.
- henrik

On 2013-18-01 16:01, Marco Naddeo wrote:
> Hi all
>
> I'd like to call the serializer preserving the original formatting,
> while when I call it, the format of the resulting textual representation
> is determined by the Formatter.
>
> Is it possible in some way to preserve original formatting?
>
> I read in the documentation that SaveOptions can be passed to the
> serializer to disable the formatter:
>
> Quote:
>> If disabled, the formatter only defi nes white space information for
>> the places in which no white space information can be preserved from
>> the node model.
>
>
> but I cannot understand how. :( [And I do not know if this affects what
> I want. :?]
>
> Could you please help me? :roll:
>
> Marco
Re: Calling the serializer preserving original formatting [message #1003462 is a reply to message #1002504] Mon, 21 January 2013 09:36 Go to previous message
Marco Naddeo is currently offline Marco NaddeoFriend
Messages: 62
Registered: November 2012
Member
I tried to set a SaveOptions object and to pass it to the Serializer on the call of:

public String serialize(EObject obj, SaveOptions options)


but with both true or false for the formatting option, it does not change anything.

Any ideas? Sad

Henrik Lindberg wrote on Fri, 18 January 2013 13:08
Look at the SaveOptions class. I think you create one, and then tell it
to "preserve whitespace" or somesuch. That means "no formatting".

Inserting spaces then takes place only where there is not source text as
the source of the model (i.e, when there are semantic changes that are
not (yet) reflected in text.

Hope that helps.
- henrik

Previous Topic:problem running a xtext file
Next Topic:Image path for PluginImageHelper
Goto Forum:
  


Current Time: Fri Apr 19 23:29:31 GMT 2024

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

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

Back to the top