-
Notifications
You must be signed in to change notification settings - Fork 0
Deal with eol in Windows for Xtend generated files with simple multiline strings #12
Comments
You can paste this onto your git clone task to override Oomph's git clone task adding this property set to true:
I'd avoid setting it to false, because it's all too easy to check-in windows line endings into the git repository messing up with others see on mac/linux... (Good generators should respect workspace preferences and/or preserve what's used in already-present files. It's easy to overlook this when you aren't developing on or for Windows.) |
does the checkout really help |
The Xtext / Xtend compiler infra does that. But: String literals are taken literally - it's a sequence of chars. If that sequence contains a If the repository contains |
@cdietrich indeed my feeling is that the git setting would work only for the checkout: modifying the source later will lead to the same problem, that's why I was suggesting to do the preprocessing removing |
Yes, that would be a separate compiler setting, though. |
@szarnekow so you're suggesting introducing a new Xtend compiler setting to decide whether to remove |
Maybe. First, I need to understand the real problem. |
I think the (a?) fundamental problem is that org.eclipse.xtend2.lib.StringConcatenation.DEFAULT_LINE_DELIMITER uses org.eclipse.xtend2.lib.DefaultLineDelimiter.get() which simply does this:
So on Windows such things will generate \r\n always so I'm not sure how forcing linux endings in the clone will help... |
That property is used at runtime only and not by the Xbase compiler itself. It's all a bit confusing. E.g. the Xbase compiler use the TreeAppendable abstraction which is initialized like this:
You see how it uses unix line endings by default. Subsequently it funnels the result through UnicodeAwarePostProcessor which reads the getLineSeparatorInformation from the project (in Eclipse) and replaces the UNIX line endings by the project specific line endings. All this doesn't matter for plain string literals. Note that a string literal in the model is exactly that: a literal. It's an array of chars. The compiler is not in the position to judge that array. If it contains a carriage return, it needs to go into the class file. |
@szarnekow probably, my solution is oversimplistic because I wasn't considering I was thinking about Java text blocks where it is the compiler stripping |
That's related to the discussion eclipse-xtext/xtext#2135 (comment)
In Windows, Xtend generates a Java string with
\r\n
.@szarnekow suggests we force unix line handling when cloning the Git repository in Windows.
@merks, is there a way to configure Oomph accordingly?
@szarnekow concerning your comment eclipse-xtext/xtext#2135 (comment) do you think it would be feasible to manually remove
\r
after callingconvertToJavaString
(I mean, a simple.replace("\r", "")
)? Java text blocks are ensured never to contain\r
, since the compiler strips them. Would that be a breaking change?The text was updated successfully, but these errors were encountered: