-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong line delimiter when enclosing multi-line strings with double quotes. #2293
Comments
Small example to reproduce:
is compiled to the following java code:
|
For RichStrings, the XtendCompiler._toJavaExpression(RichString richString, ITreeAppendable b) method is called, for String Literals the XtendCompiler._toJavaExpression(XStringLiteral expr, ITreeAppendable b) method is called. I think we should make a difference if the XStringLiteral is a multi-line string and handle such cases similar to RichStrings. cc @cdietrich , @szarnekow @ArneDeutsch What do you think about this idea? |
Instead of imposing runtime semantics, I’d rather align this with Java’s multiline strings and always use unix line delimiters. |
I had a look about this. At first I thought one could simply fix It seems for me locally I could fix the line ending issues by:
At least inside eclipse context, not sure about outside this scope, Xtext/Xtend seems to work right. At least if environment is configured properly. Perhaps this is just an issue to preconfigure our distro appropriatly and document all this in better way. I will keep my installation as is for now and experiment with it. |
Are there any settings among the ones you described, that we can automatically apply with Oomph when cloning the repos? |
I have no experience in configuration of Oomph, but I will have a look. Probably @kthoms can help? |
The https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings If we do so and set |
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
Avoids dirty flags on checkout on windows machines. Signed-off-by: Arne Deutsch <Arne.Deutsch@itemis.de>
This could be achieved by converting the line delimiters to Unix style in the LiteralsCompiler. |
@szarnekow, I had also suggested this in another issue I cannot find right now, which may have been lost during the transition to the mono-repo. I had proposed something similar to #2293 (comment) I seem to remember that there's an earlier place where the parsed string can be "sanitized" by simply removing |
If the compiler always emits Unix linebreaks, the model should never contain Windows line endings, either. Consequently, the value converter would be the right service to sanitize the strings. |
@szarnekow would this |
I'd use a subtype specifically used for Xbase string literal values. |
@szarnekow OK, thanks for the suggestion! I've updated the PR #3004 If I understood correctly, 8ea116b#diff-71a02996356cc4a288de10e1aa3233fdc96cbdcda67302af2d119480c4bc4960R259 this should do the trick; locally the tests are still green. This way, neither the LiteralsCompiler nor the XbaseInterpreter need adjustments. |
After checking out a fresh Xtend workspace on windows, there are several java files in xtend-gen folder marked as dirty:
As far as I can see, the reason for the change is that multi line Strings enclosed by double quotes are translated differently on windows and on mac.
Hint: by multi line String enclosed by
'''
thenewLine()
method is used in the generated *.java file. I suggest to also use this approach for multi-line Strings enclosed by"
.The text was updated successfully, but these errors were encountered: