epsilon icon indicating copy to clipboard operation
epsilon copied to clipboard

Multiline string literals in EOL

Open kolovos opened this issue 10 months ago • 3 comments

String literals in EOL can be multi-line as shown below.

Image

This "feature" is unintentional and undocumented. Before https://github.com/eclipse-epsilon/epsilon/commit/da117386b18430d8a4e8c081e6a6528f0660be4f we used SingleLineRules to syntax-highlight string literals in Epsilon Eclipse's editors, which was masking this. However, in https://github.com/eclipse-epsilon/epsilon/commit/da117386b18430d8a4e8c081e6a6528f0660be4f the EOL editor became consistent with the parser and now uses MultiLineRules. This can create some awkward syntax highlighting when a string is not properly closed with a single/double quote as shown below.

Image

What's more, being an accidental feature, multi-line strings are not properly supported (e.g. indentation is not considered when computing their contents). To maintain backwards compatibility, one option would be to use SingleLineRules for double-quoted strings and raise a warning in the editor when multi-line double-quoted strings are used. For single-quoted strings, we can keep the MultiLineRule for syntax highlighting and not raise a warning, with the intention of improving support for them in 3.0 (i.e. in 3.0 onwards double-quoted strings would be single-line and single-quoted strings would be multi-line with proper support for indentation).

kolovos avatar Mar 20 '25 13:03 kolovos

After discussion on Slack, the consensus is that we should make single/double-quoted strings single-line in 3.x and add triple-quoted text blocks for multi-line strings in line with Java. In the meantime, we will switch to SingleLineRules for single/double-quoted string literals and raise a warning in the editor when they include new line characters.

kolovos avatar Mar 20 '25 15:03 kolovos

Is there any chance we could get string interpolation in single and multiline strings? Maybe with EGL syntax?

Arkaedan avatar Mar 21 '25 03:03 Arkaedan

I like the idea and reusing EGL makes a lot of sense.

kolovos avatar Mar 21 '25 08:03 kolovos