Skip to main content



      Home
Home » Modeling » TMF (Xtext) » xtext, xtend and source generation
xtext, xtend and source generation [message #895081] Wed, 11 July 2012 11:52 Go to next message
Eclipse UserFriend
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 05:25 Go to previous messageGo to next message
Eclipse UserFriend
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 05:35 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: xtext, xtend and source generation [message #895267 is a reply to message #895253] Thu, 12 July 2012 06:13 Go to previous message
Eclipse UserFriend
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: Mon Jul 14 01:47:55 EDT 2025

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

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

Back to the top