Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext, xtend and source generation
xtext, xtend and source generation [message #895081] Wed, 11 July 2012 15:52 Go to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I've developed my custom DSL and a generator which generates an XML-File
from my DSL.

The problem I'm facing now is that if the users of my plugin are on
different OSes I get whitespace changes because
StringConcatenationBuilder by my template always uses the system
line-breaks (StringConcatenation _builder = new StringConcatenation())
when using multiline strings

Is there someway to configure the line break an xtend-multi line string
should use, e.g. by annotating the method or class?

The original method looks like this:

> class FXGraphTemplate implements IGenerator<FXGraphElement> {
>
> override generateContent(FXGraphElement element) '''
> LINE1
> LINE2
> LINE3
> }


> class FXGraphTemplate implements IGenerator<FXGraphElement> {
> @LineBreak("\r\n")
> override generateContent(FXGraphElement element) '''
> LINE1
> LINE2
> LINE3
> }

Tom
Re: xtext, xtend and source generation [message #895253 is a reply to message #895081] Thu, 12 July 2012 09:25 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Tom,

there is currently no way to configure that in the code. Did you try to
configure the line delimiter in the preferences of your project (the
project that contains the input files for your generated XML stuff).
There is a class called
'org.eclipse.xtext.generator.LineSeparatorHarmonizer' which in turn uses
a IWhitespaceInformationProvider. The latter reads that preference and
the harmonizer should be configured as the default callback for
generated files.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 11.07.12 17:52, schrieb Tom Schindl:
> Hi,
>
> I've developed my custom DSL and a generator which generates an XML-File
> from my DSL.
>
> The problem I'm facing now is that if the users of my plugin are on
> different OSes I get whitespace changes because
> StringConcatenationBuilder by my template always uses the system
> line-breaks (StringConcatenation _builder = new StringConcatenation())
> when using multiline strings
>
> Is there someway to configure the line break an xtend-multi line string
> should use, e.g. by annotating the method or class?
>
> The original method looks like this:
>
>> class FXGraphTemplate implements IGenerator<FXGraphElement> {
>>
>> override generateContent(FXGraphElement element) '''
>> LINE1
>> LINE2
>> LINE3
>> }
>
>
>> class FXGraphTemplate implements IGenerator<FXGraphElement> {
>> @LineBreak("\r\n")
>> override generateContent(FXGraphElement element) '''
>> LINE1
>> LINE2
>> LINE3
>> }
>
> Tom
Re: xtext, xtend and source generation [message #895257 is a reply to message #895081] Thu, 12 July 2012 09:35 Go to previous messageGo to next message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Line separator handling is not yet implemented into the
StringConcatenation itself.

Instead, we usa a post processing approach. If you use an
AbstractFileSystemAccess in the IGenerator, there is an
IFilePostProcessor injected. The default LineSeparatorHarmonizer
replaces all newlines with what is configered with as the
IWhitespaceInformationProvider.

Am 11.07.12 17:52, schrieb Tom Schindl:
> Hi,
>
> I've developed my custom DSL and a generator which generates an XML-File
> from my DSL.
>
> The problem I'm facing now is that if the users of my plugin are on
> different OSes I get whitespace changes because
> StringConcatenationBuilder by my template always uses the system
> line-breaks (StringConcatenation _builder = new StringConcatenation())
> when using multiline strings
>
> Is there someway to configure the line break an xtend-multi line string
> should use, e.g. by annotating the method or class?
>
> The original method looks like this:
>
>> class FXGraphTemplate implements IGenerator<FXGraphElement> {
>>
>> override generateContent(FXGraphElement element) '''
>> LINE1
>> LINE2
>> LINE3
>> }
>
>
>> class FXGraphTemplate implements IGenerator<FXGraphElement> {
>> @LineBreak("\r\n")
>> override generateContent(FXGraphElement element) '''
>> LINE1
>> LINE2
>> LINE3
>> }
>
> Tom


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Re: xtext, xtend and source generation [message #895267 is a reply to message #895253] Thu, 12 July 2012 10:13 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Works like a charme - I've replaced the default one with my custom which
forces the windows "\r\n".

Tom

Am 12.07.12 11:25, schrieb Sebastian Zarnekow:
> Hi Tom,
>
> there is currently no way to configure that in the code. Did you try to
> configure the line delimiter in the preferences of your project (the
> project that contains the input files for your generated XML stuff).
> There is a class called
> 'org.eclipse.xtext.generator.LineSeparatorHarmonizer' which in turn uses
> a IWhitespaceInformationProvider. The latter reads that preference and
> the harmonizer should be configured as the default callback for
> generated files.
>
> Regards,
> Sebastian
Previous Topic:OCL: Iterate over code lines
Next Topic:Cross reference is being activated without an import, why ?
Goto Forum:
  


Current Time: Thu Apr 25 11:54:39 GMT 2024

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

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

Back to the top