IDE response to raw string literals#58846
Conversation
|
|
||
| return position == token.Span.End && | ||
| (token.Span.Length == startLength || (token.Span.Length > startLength && !token.ToString().EndsWith(string.Concat(tokenStart)))); | ||
| } |
There was a problem hiding this comment.
hrmmmmmmm something seems fishy here. we likely want to talk about what's going on here and if it's necessary. i'm guessing we can answer this question without having to stringigy the token. note: the existing code seems uber suspect to me as well :)
|
overall seems fine. tests plz :) |
| if (token.IsKind(SyntaxKind.InterpolatedStringStartToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedStringEndToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedStringTextToken)) | ||
| token.IsKind(SyntaxKind.InterpolatedStringTextToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedSingleLineRawStringStartToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedSingleLineRawStringEndToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedMultiLineRawStringStartToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedMultiLineRawStringEndToken)) |
There was a problem hiding this comment.
I think we'd need another conditional branch for MultiLineRawStringLiteral and SingleLineRawStringLiteral here as well and coordinate the F1 keyword to be used with dotnet/docs team.
if (token.IsKind(SyntaxKind.MultiLineRawStringLiteral) || token.IsKind(SyntaxKind.SingleLineRawStringLiteral))
{
text = "RawStringLiteral_CSharpKeyword"; // or """_CSharpKeyword
return true;
}| if (token.IsKind(SyntaxKind.InterpolatedStringStartToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedStringEndToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedStringTextToken)) | ||
| token.IsKind(SyntaxKind.InterpolatedStringTextToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedSingleLineRawStringStartToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedSingleLineRawStringEndToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedMultiLineRawStringStartToken) || | ||
| token.IsKind(SyntaxKind.InterpolatedMultiLineRawStringEndToken)) |
There was a problem hiding this comment.
Consider refactoring this long list of syntax kinds into an extension in https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/CSharpExtensions.cs
| { | ||
| return kind >= SyntaxKind.TildeToken && kind <= SyntaxKind.QuestionQuestionEqualsToken; | ||
| return kind >= SyntaxKind.TildeToken && kind <= SyntaxKind.QuestionQuestionEqualsToken || | ||
| kind is SyntaxKind.RawInterpolationOpenToken || kind is SyntaxKind.RawInterpolationCloseToken; |
There was a problem hiding this comment.
note: tehse tokens kinds are gone now. sorry!
| } | ||
|
|
||
| [WpfFact, Trait(Traits.Feature, Traits.Features.SplitStringLiteral)] | ||
| public void TestMissingInRawStringLiteralInterpolation_MultiBrace() |
There was a problem hiding this comment.
test name seems wrong...
sharwell
left a comment
There was a problem hiding this comment.
It looks like the intender is applying one too many spaces for interpolated raw strings.
| // case 1: $"""$$ | ||
| // """ | ||
| // case 2: $""" | ||
| // text$$ | ||
| // """ |
There was a problem hiding this comment.
| // case 1: $"""$$ | |
| // """ | |
| // case 2: $""" | |
| // text$$ | |
| // """ | |
| // case 1: $"""$$ | |
| // """ | |
| // case 2: $""" | |
| // text$$ | |
| // """ |
There was a problem hiding this comment.
the indenter isn't setting where the delimiter goes here. Instead, it's stating where the caret should go when enter is typed above teh delimeter. In that case, the caret is indented the same amount as the final string.
…ing enter in a delimiter.
|
Merging in. Note that we still need tests around indentation and splitting of raw strings. I will add those myself in a followup. |
The comment isn't stating that we will indent the end quote that much, just that we'll align the caret with the indentation of the end quote.
Fixed the following bugs:
{ x }should be{x})Added tests for:
TO-DO:
$$"""{{x}}""". This is difficult with the current test infrastructure since$$is often considered the cursor position.Relatest to test plan #55306