[C#] Fix various string literal highlighting issues#4484
[C#] Fix various string literal highlighting issues#4484deathaxe merged 15 commits intosublimehq:masterfrom
Conversation
This commit ... 1. removes `_literal` suffix from normal raw-strings to match context naming scheme with `inside_string` and `inside_long_string`. 2. renames `_long` to `_verbatim` as C# spec uses the later term for string literals starting with `@"`
This commit removes patterns of an unsupported raw string literals. Verbatim strings may start with escaped quotes `""`, which makes them look like verbatim raw string literals. C# 11 and 12 raise compiler error, only if `@` is combined with multiple `$` chars, such as `@$$" ... "`.
This commit removes `string_escaped` import from raw strings as those are interpreted literal.
This commit renames `_escaped` to `_escapes` in context names, to denote their no-popping behavior via plural.
This commit ...
1. restricts allowed number of subsequent `{` or `}`, depending on amount
of `$` a raw string literal starts with.
2. adds dedicated `raw_string_placeholder_format` without `string_escapes`
context.
1. sort string contexts by quoted, verbatim and raw strings 2. move extended placeholders contexts to to related string content contexts as interpolation contexts are organized this way. 3. include `string_placeholders` and `string_placeholder_escapes` separately.
This commit adds and tweaks interpolation bailouts in double quoted strings.
This commit changes scope to avoid confusion between verbatim and raw strings.
This commit scopes raw strings `string.quoted.block`, because... 1. they may be enclosed by any number of double quotes, which renders `.triple` scope name a bit inaccurate. 2. Python also scopes multi-line strings this way.
This commit reverts some bailout related changes to fix support of double quoted strings within interpolation expressions.
|
This PR seems to blow up PowerShell syntax due to context sanity limit being exceeded. In Python we explicitly excluded SQL syntax highlighting in interpolated strings to discourage interpolated queries for security reasons. Should we therefore remove SQL highlighting from C#'s verbatim format strings? It would resolve PowerShell. |
|
PowerShell explicitly disables SQL in nested C#. If this PR renames one of those contexts, it needs a change in PowerShell, too. Or do #4416 (comment) |
|
Gotcha! Actually, all are renamed. Luckily those are cheap enough to have both versions in overridng syntax. I had to rename them as I wasn't able to wrap my head around the old naming vs. naming in specs. |
This commit helps 3rd-party syntaxes to extend C# and add common patterns to string literals by adding a `string_prototype` context.
|
Good catch, BTW, on
|
|
(I wrote most of this a couple days ago but forgot to post.) For casual lurkers, C# somewhat annoyingly calls its I originally held off on approval for a while because I wanted to consider leaving |
|
I am also not very confident about the best solution as |
Addresses #4468 "Multi-line" strings.
This PR is another iteration of refactoring and improving C# string literals.
It ...
@$"""...""". Those are just verbatim strings starting with escaped quotes.$$$"""..."""and$$$$"""..."""raw strings