From 0300040c466d5a64e8c126eb8bfb0975bdb683c3 Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Fri, 18 Mar 2022 15:24:57 -0700 Subject: [PATCH 1/2] Implement classification for UTF8 String Literals --- .../CSharp/Portable/CSharpExtensions.cs | 2 +- .../SyntacticClassifierTests.cs | 337 +++++++++++++++++- .../ClassificationTypeDefinitions.cs | 10 + .../FormattedClassifications.cs | 8 + .../Classification/ClassificationHelpers.cs | 17 +- .../Classification/ClassificationTypeNames.cs | 2 + .../Core/Portable/PublicAPI.Unshipped.txt | 2 + 7 files changed, 369 insertions(+), 9 deletions(-) diff --git a/src/Compilers/CSharp/Portable/CSharpExtensions.cs b/src/Compilers/CSharp/Portable/CSharpExtensions.cs index d2ae4cdd4d06f..2518175c5c544 100644 --- a/src/Compilers/CSharp/Portable/CSharpExtensions.cs +++ b/src/Compilers/CSharp/Portable/CSharpExtensions.cs @@ -232,7 +232,7 @@ public static bool IsReservedKeyword(this SyntaxToken token) public static bool IsVerbatimStringLiteral(this SyntaxToken token) { - return token.IsKind(SyntaxKind.StringLiteralToken) && token.Text.Length > 0 && token.Text[0] == '@'; + return token.Kind() is (SyntaxKind.StringLiteralToken or SyntaxKind.UTF8StringLiteralToken) && token.Text.Length > 0 && token.Text[0] == '@'; } public static bool IsVerbatimIdentifier(this SyntaxToken token) diff --git a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs index fd5fcbb83f2a5..48cfad92e9cb8 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs @@ -349,6 +349,24 @@ await TestInMethodAsync(@"@""goo""", Verbatim(@"@""goo""")); } + [Theory] + [CombinatorialData] + public async Task VerbatimStringLiteralsUTF8_01(TestHost testHost) + { + await TestInMethodAsync(@"@""goo""u8", + testHost, + UTF8Verbatim(@"@""goo""u8")); + } + + [Theory] + [CombinatorialData] + public async Task VerbatimStringLiteralsUTF8_02(TestHost testHost) + { + await TestInMethodAsync(@"@""goo""U8", + testHost, + UTF8Verbatim(@"@""goo""U8")); + } + /// /// Should show up as soon as we get the @\" typed out /// @@ -366,7 +384,7 @@ await TestAsync(@"@""", /// [Theory] [CombinatorialData] - public async Task VerbatimStringLiteral3(TestHost testHost) + public async Task VerbatimStringLiterals3(TestHost testHost) { await TestAsync(@"goo @""", testHost, @@ -379,7 +397,7 @@ await TestAsync(@"goo @""", /// [Theory] [CombinatorialData] - public async Task VerbatimStringLiteral4(TestHost testHost) + public async Task VerbatimStringLiterals4(TestHost testHost) { var code = @" @@ -395,7 +413,7 @@ await TestAsync(code, [Theory] [CombinatorialData] - public async Task VerbatimStringLiteral5(TestHost testHost) + public async Task VerbatimStringLiterals5(TestHost testHost) { var code = @" @@ -412,10 +430,48 @@ await TestInMethodAsync(code, Local("stuff")); } + [Theory] + [CombinatorialData] + public async Task VerbatimStringLiteralsUTF8_03(TestHost testHost) + { + var code = @" + +@"" goo bar +and +on a new line ""u8 +more stuff"; + await TestInMethodAsync(code, + testHost, + UTF8Verbatim(@"@"" goo bar +and +on a new line ""u8"), + Identifier("more"), + Local("stuff")); + } + + [Theory] + [CombinatorialData] + public async Task VerbatimStringLiteralsUTF8_04(TestHost testHost) + { + var code = @" + +@"" goo bar +and +on a new line ""U8 +more stuff"; + await TestInMethodAsync(code, + testHost, + UTF8Verbatim(@"@"" goo bar +and +on a new line ""U8"), + Identifier("more"), + Local("stuff")); + } + [Theory] [WorkItem(44423, "https://github.com/dotnet/roslyn/issues/44423")] [CombinatorialData] - public async Task VerbatimStringLiteral6(bool script, TestHost testHost) + public async Task VerbatimStringLiterals6(bool script, TestHost testHost) { var code = @"string s = @""""""/*"";"; @@ -433,6 +489,46 @@ await TestAsync( Punctuation.Semicolon); } + [Theory] + [CombinatorialData] + public async Task VerbatimStringLiteralsUTF8_05(bool script, TestHost testHost) + { + var code = @"string s = @""""""/*""u8;"; + + var parseOptions = script ? Options.Script : null; + + await TestAsync( + code, + code, + testHost, + parseOptions, + Keyword("string"), + script ? Field("s") : Local("s"), + Operators.Equals, + UTF8Verbatim(@"@""""""/*""u8"), + Punctuation.Semicolon); + } + + [Theory] + [CombinatorialData] + public async Task VerbatimStringLiteralsUTF8_06(bool script, TestHost testHost) + { + var code = @"string s = @""""""/*""u8;"; + + var parseOptions = script ? Options.Script : null; + + await TestAsync( + code, + code, + testHost, + parseOptions, + Keyword("string"), + script ? Field("s") : Local("s"), + Operators.Equals, + UTF8Verbatim(@"@""""""/*""u8"), + Punctuation.Semicolon); + } + [Theory] [CombinatorialData] public async Task StringLiteral1(TestHost testHost) @@ -442,6 +538,24 @@ await TestAsync(@"""goo""", String(@"""goo""")); } + [Theory] + [CombinatorialData] + public async Task StringLiteralUTF8_01(TestHost testHost) + { + await TestAsync(@"""goo""u8", + testHost, + UTF8String(@"""goo""u8")); + } + + [Theory] + [CombinatorialData] + public async Task StringLiteralUTF8_02(TestHost testHost) + { + await TestAsync(@"""goo""U8", + testHost, + UTF8String(@"""goo""U8")); + } + [Theory] [CombinatorialData] public async Task StringLiteral2(TestHost testHost) @@ -451,6 +565,24 @@ await TestAsync(@"""""", String(@"""""")); } + [Theory] + [CombinatorialData] + public async Task StringLiteralUTF8_03(TestHost testHost) + { + await TestAsync(@"""""u8", + testHost, + UTF8String(@"""""u8")); + } + + [Theory] + [CombinatorialData] + public async Task StringLiteralUTF8_04(TestHost testHost) + { + await TestAsync(@"""""U8", + testHost, + UTF8String(@"""""U8")); + } + [Theory] [CombinatorialData] public async Task CharacterLiteral1(TestHost testHost) @@ -5745,6 +5877,203 @@ await TestAsync(code, Punctuation.CloseCurly); } + [Theory] + [CombinatorialData] + public async Task TestRawStringLiteralUTF8_01(TestHost testHost) + { + var code = @" +class C +{ + public static void M(int x) + { + var s = """"""Hello world""""""u8; + } +}"; + + await TestAsync(code, + testHost, + Keyword("class"), + Class("C"), + Punctuation.OpenCurly, + Keyword("public"), + Keyword("static"), + Keyword("void"), + Method("M"), + Static("M"), + Punctuation.OpenParen, + Keyword("int"), + Parameter("x"), + Punctuation.CloseParen, + Punctuation.OpenCurly, + Keyword("var"), + Local("s"), + Operators.Equals, + UTF8String("\"\"\"Hello world\"\"\"u8"), + Punctuation.Semicolon, + Punctuation.CloseCurly, + Punctuation.CloseCurly); + } + + [Theory] + [CombinatorialData] + public async Task TestRawStringLiteralUTF8_02(TestHost testHost) + { + var code = @" +class C +{ + public static void M(int x) + { + var s = """"""Hello world""""""U8; + } +}"; + + await TestAsync(code, + testHost, + Keyword("class"), + Class("C"), + Punctuation.OpenCurly, + Keyword("public"), + Keyword("static"), + Keyword("void"), + Method("M"), + Static("M"), + Punctuation.OpenParen, + Keyword("int"), + Parameter("x"), + Punctuation.CloseParen, + Punctuation.OpenCurly, + Keyword("var"), + Local("s"), + Operators.Equals, + UTF8String("\"\"\"Hello world\"\"\"U8"), + Punctuation.Semicolon, + Punctuation.CloseCurly, + Punctuation.CloseCurly); + } + + [Theory] + [CombinatorialData] + public async Task TestRawStringLiteralMultiline(TestHost testHost) + { + var code = @" +class C +{ + public static void M(int x) + { + var s = """""" + Hello world + """"""; + } +}"; + + await TestAsync(code, + testHost, + Keyword("class"), + Class("C"), + Punctuation.OpenCurly, + Keyword("public"), + Keyword("static"), + Keyword("void"), + Method("M"), + Static("M"), + Punctuation.OpenParen, + Keyword("int"), + Parameter("x"), + Punctuation.CloseParen, + Punctuation.OpenCurly, + Keyword("var"), + Local("s"), + Operators.Equals, + String(@""""""" + Hello world + """""""), + Punctuation.Semicolon, + Punctuation.CloseCurly, + Punctuation.CloseCurly); + } + + [Theory] + [CombinatorialData] + public async Task TestRawStringLiteralMultilineUTF8_01(TestHost testHost) + { + var code = @" +class C +{ + public static void M(int x) + { + var s = """""" + Hello world + """"""u8; + } +}"; + + await TestAsync(code, + testHost, + Keyword("class"), + Class("C"), + Punctuation.OpenCurly, + Keyword("public"), + Keyword("static"), + Keyword("void"), + Method("M"), + Static("M"), + Punctuation.OpenParen, + Keyword("int"), + Parameter("x"), + Punctuation.CloseParen, + Punctuation.OpenCurly, + Keyword("var"), + Local("s"), + Operators.Equals, + UTF8String(@""""""" + Hello world + """"""u8"), + Punctuation.Semicolon, + Punctuation.CloseCurly, + Punctuation.CloseCurly); + } + + [Theory] + [CombinatorialData] + public async Task TestRawStringLiteralMultilineUTF8_02(TestHost testHost) + { + var code = @" +class C +{ + public static void M(int x) + { + var s = """""" + Hello world + """"""U8; + } +}"; + + await TestAsync(code, + testHost, + Keyword("class"), + Class("C"), + Punctuation.OpenCurly, + Keyword("public"), + Keyword("static"), + Keyword("void"), + Method("M"), + Static("M"), + Punctuation.OpenParen, + Keyword("int"), + Parameter("x"), + Punctuation.CloseParen, + Punctuation.OpenCurly, + Keyword("var"), + Local("s"), + Operators.Equals, + UTF8String(@""""""" + Hello world + """"""U8"), + Punctuation.Semicolon, + Punctuation.CloseCurly, + Punctuation.CloseCurly); + } + [Theory] [CombinatorialData] public async Task TestRawStringLiteralInterpolation1(TestHost testHost) diff --git a/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs b/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs index ce30c28c46592..e133b95d81244 100644 --- a/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs +++ b/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs @@ -31,6 +31,16 @@ internal sealed class ClassificationTypeDefinitions [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StringVerbatimTypeDefinition; + [Export] + [Name(ClassificationTypeNames.UTF8StringLiteral)] + [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] + internal readonly ClassificationTypeDefinition UTF8StringTypeDefinition; + + [Export] + [Name(ClassificationTypeNames.UTF8VerbatimStringLiteral)] + [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] + internal readonly ClassificationTypeDefinition UTF8StringVerbatimTypeDefinition; + [Export] [Name(ClassificationTypeNames.StringEscapeCharacter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] diff --git a/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs b/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs index f3bb35e15a5da..a118dd5efc483 100644 --- a/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs +++ b/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs @@ -98,10 +98,18 @@ public static FormattedClassification Static(string text) public static FormattedClassification String(string text) => New(text, ClassificationTypeNames.StringLiteral); + [DebuggerStepThrough] + public static FormattedClassification UTF8String(string text) + => New(text, ClassificationTypeNames.UTF8StringLiteral); + [DebuggerStepThrough] public static FormattedClassification Verbatim(string text) => New(text, ClassificationTypeNames.VerbatimStringLiteral); + [DebuggerStepThrough] + public static FormattedClassification UTF8Verbatim(string text) + => New(text, ClassificationTypeNames.UTF8VerbatimStringLiteral); + [DebuggerStepThrough] public static FormattedClassification Escape(string text) => New(text, ClassificationTypeNames.StringEscapeCharacter); diff --git a/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs b/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs index 4df12c5b2b8e8..d36e7a96ff38a 100644 --- a/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs +++ b/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs @@ -46,9 +46,15 @@ internal static class ClassificationHelpers } else if (IsStringToken(token)) { - return IsVerbatimStringToken(token) - ? ClassificationTypeNames.VerbatimStringLiteral - : ClassificationTypeNames.StringLiteral; + if (IsVerbatimStringToken(token)) + { + return token.IsKind(SyntaxKind.UTF8StringLiteralToken) ? ClassificationTypeNames.UTF8VerbatimStringLiteral : ClassificationTypeNames.VerbatimStringLiteral; + } + else + { + return token.Kind() is (SyntaxKind.UTF8StringLiteralToken or SyntaxKind.UTF8SingleLineRawStringLiteralToken or SyntaxKind.UTF8MultiLineRawStringLiteralToken) ? + ClassificationTypeNames.UTF8StringLiteral : ClassificationTypeNames.StringLiteral; + } } else if (token.Kind() == SyntaxKind.NumericLiteralToken) { @@ -141,6 +147,7 @@ private static bool IsControlStatementKind(SyntaxKind kind) private static bool IsStringToken(SyntaxToken token) { return token.IsKind(SyntaxKind.StringLiteralToken) + || token.IsKind(SyntaxKind.UTF8StringLiteralToken) || token.IsKind(SyntaxKind.CharacterLiteralToken) || token.IsKind(SyntaxKind.InterpolatedStringStartToken) || token.IsKind(SyntaxKind.InterpolatedVerbatimStringStartToken) @@ -150,7 +157,9 @@ private static bool IsStringToken(SyntaxToken token) || token.IsKind(SyntaxKind.InterpolatedSingleLineRawStringStartToken) || token.IsKind(SyntaxKind.InterpolatedMultiLineRawStringStartToken) || token.IsKind(SyntaxKind.SingleLineRawStringLiteralToken) - || token.IsKind(SyntaxKind.MultiLineRawStringLiteralToken); + || token.IsKind(SyntaxKind.UTF8SingleLineRawStringLiteralToken) + || token.IsKind(SyntaxKind.MultiLineRawStringLiteralToken) + || token.IsKind(SyntaxKind.UTF8MultiLineRawStringLiteralToken); } private static bool IsVerbatimStringToken(SyntaxToken token) diff --git a/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs b/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs index df5baaccd9d47..53348dd9e2633 100644 --- a/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs +++ b/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs @@ -27,6 +27,7 @@ public static class ClassificationTypeNames public const string OperatorOverloaded = "operator - overloaded"; public const string PreprocessorKeyword = "preprocessor keyword"; public const string StringLiteral = "string"; + public const string UTF8StringLiteral = "UTF8 string"; public const string WhiteSpace = "whitespace"; public const string Text = "text"; @@ -36,6 +37,7 @@ public static class ClassificationTypeNames public const string PreprocessorText = "preprocessor text"; public const string Punctuation = "punctuation"; public const string VerbatimStringLiteral = "string - verbatim"; + public const string UTF8VerbatimStringLiteral = "UTF8 string - verbatim"; public const string StringEscapeCharacter = "string - escape character"; public const string ClassName = "class name"; diff --git a/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt b/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt index 2bada5d42e0b8..0431069023dde 100644 --- a/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt @@ -1,3 +1,5 @@ +const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.UTF8StringLiteral = "UTF8 string" -> string +const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.UTF8VerbatimStringLiteral = "UTF8 string - verbatim" -> string Microsoft.CodeAnalysis.Editing.SyntaxEditor.SyntaxEditor(Microsoft.CodeAnalysis.SyntaxNode root, Microsoft.CodeAnalysis.Host.HostWorkspaceServices services) -> void *REMOVED*static Microsoft.CodeAnalysis.Editing.SyntaxGenerator.DefaultRemoveOptions -> Microsoft.CodeAnalysis.SyntaxRemoveOptions static readonly Microsoft.CodeAnalysis.Editing.SyntaxGenerator.DefaultRemoveOptions -> Microsoft.CodeAnalysis.SyntaxRemoveOptions From b7a6de874bc332ac1cd2b4e545b3091b015afd77 Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Mon, 21 Mar 2022 08:32:26 -0700 Subject: [PATCH 2/2] Remove UTF8 specofic ClassificationTypeNames. --- .../SyntacticClassifierTests.cs | 28 +++++++++---------- .../ClassificationTypeDefinitions.cs | 10 ------- .../FormattedClassifications.cs | 8 ------ .../Classification/ClassificationHelpers.cs | 12 ++------ .../Classification/ClassificationTypeNames.cs | 2 -- .../Core/Portable/PublicAPI.Unshipped.txt | 2 -- 6 files changed, 17 insertions(+), 45 deletions(-) diff --git a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs index 48cfad92e9cb8..fb627ba3d85b0 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests.cs @@ -355,7 +355,7 @@ public async Task VerbatimStringLiteralsUTF8_01(TestHost testHost) { await TestInMethodAsync(@"@""goo""u8", testHost, - UTF8Verbatim(@"@""goo""u8")); + Verbatim(@"@""goo""u8")); } [Theory] @@ -364,7 +364,7 @@ public async Task VerbatimStringLiteralsUTF8_02(TestHost testHost) { await TestInMethodAsync(@"@""goo""U8", testHost, - UTF8Verbatim(@"@""goo""U8")); + Verbatim(@"@""goo""U8")); } /// @@ -442,7 +442,7 @@ public async Task VerbatimStringLiteralsUTF8_03(TestHost testHost) more stuff"; await TestInMethodAsync(code, testHost, - UTF8Verbatim(@"@"" goo bar + Verbatim(@"@"" goo bar and on a new line ""u8"), Identifier("more"), @@ -461,7 +461,7 @@ public async Task VerbatimStringLiteralsUTF8_04(TestHost testHost) more stuff"; await TestInMethodAsync(code, testHost, - UTF8Verbatim(@"@"" goo bar + Verbatim(@"@"" goo bar and on a new line ""U8"), Identifier("more"), @@ -505,7 +505,7 @@ await TestAsync( Keyword("string"), script ? Field("s") : Local("s"), Operators.Equals, - UTF8Verbatim(@"@""""""/*""u8"), + Verbatim(@"@""""""/*""u8"), Punctuation.Semicolon); } @@ -525,7 +525,7 @@ await TestAsync( Keyword("string"), script ? Field("s") : Local("s"), Operators.Equals, - UTF8Verbatim(@"@""""""/*""u8"), + Verbatim(@"@""""""/*""u8"), Punctuation.Semicolon); } @@ -544,7 +544,7 @@ public async Task StringLiteralUTF8_01(TestHost testHost) { await TestAsync(@"""goo""u8", testHost, - UTF8String(@"""goo""u8")); + String(@"""goo""u8")); } [Theory] @@ -553,7 +553,7 @@ public async Task StringLiteralUTF8_02(TestHost testHost) { await TestAsync(@"""goo""U8", testHost, - UTF8String(@"""goo""U8")); + String(@"""goo""U8")); } [Theory] @@ -571,7 +571,7 @@ public async Task StringLiteralUTF8_03(TestHost testHost) { await TestAsync(@"""""u8", testHost, - UTF8String(@"""""u8")); + String(@"""""u8")); } [Theory] @@ -580,7 +580,7 @@ public async Task StringLiteralUTF8_04(TestHost testHost) { await TestAsync(@"""""U8", testHost, - UTF8String(@"""""U8")); + String(@"""""U8")); } [Theory] @@ -5908,7 +5908,7 @@ await TestAsync(code, Keyword("var"), Local("s"), Operators.Equals, - UTF8String("\"\"\"Hello world\"\"\"u8"), + String("\"\"\"Hello world\"\"\"u8"), Punctuation.Semicolon, Punctuation.CloseCurly, Punctuation.CloseCurly); @@ -5945,7 +5945,7 @@ await TestAsync(code, Keyword("var"), Local("s"), Operators.Equals, - UTF8String("\"\"\"Hello world\"\"\"U8"), + String("\"\"\"Hello world\"\"\"U8"), Punctuation.Semicolon, Punctuation.CloseCurly, Punctuation.CloseCurly); @@ -6025,7 +6025,7 @@ await TestAsync(code, Keyword("var"), Local("s"), Operators.Equals, - UTF8String(@""""""" + String(@""""""" Hello world """"""u8"), Punctuation.Semicolon, @@ -6066,7 +6066,7 @@ await TestAsync(code, Keyword("var"), Local("s"), Operators.Equals, - UTF8String(@""""""" + String(@""""""" Hello world """"""U8"), Punctuation.Semicolon, diff --git a/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs b/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs index e133b95d81244..ce30c28c46592 100644 --- a/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs +++ b/src/EditorFeatures/Core/Classification/ClassificationTypeDefinitions.cs @@ -31,16 +31,6 @@ internal sealed class ClassificationTypeDefinitions [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] internal readonly ClassificationTypeDefinition StringVerbatimTypeDefinition; - [Export] - [Name(ClassificationTypeNames.UTF8StringLiteral)] - [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] - internal readonly ClassificationTypeDefinition UTF8StringTypeDefinition; - - [Export] - [Name(ClassificationTypeNames.UTF8VerbatimStringLiteral)] - [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] - internal readonly ClassificationTypeDefinition UTF8StringVerbatimTypeDefinition; - [Export] [Name(ClassificationTypeNames.StringEscapeCharacter)] [BaseDefinition(PredefinedClassificationTypeNames.FormalLanguage)] diff --git a/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs b/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs index a118dd5efc483..f3bb35e15a5da 100644 --- a/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs +++ b/src/EditorFeatures/TestUtilities/Classification/FormattedClassifications.cs @@ -98,18 +98,10 @@ public static FormattedClassification Static(string text) public static FormattedClassification String(string text) => New(text, ClassificationTypeNames.StringLiteral); - [DebuggerStepThrough] - public static FormattedClassification UTF8String(string text) - => New(text, ClassificationTypeNames.UTF8StringLiteral); - [DebuggerStepThrough] public static FormattedClassification Verbatim(string text) => New(text, ClassificationTypeNames.VerbatimStringLiteral); - [DebuggerStepThrough] - public static FormattedClassification UTF8Verbatim(string text) - => New(text, ClassificationTypeNames.UTF8VerbatimStringLiteral); - [DebuggerStepThrough] public static FormattedClassification Escape(string text) => New(text, ClassificationTypeNames.StringEscapeCharacter); diff --git a/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs b/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs index d36e7a96ff38a..6581f6b1470f9 100644 --- a/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs +++ b/src/Workspaces/CSharp/Portable/Classification/ClassificationHelpers.cs @@ -46,15 +46,9 @@ internal static class ClassificationHelpers } else if (IsStringToken(token)) { - if (IsVerbatimStringToken(token)) - { - return token.IsKind(SyntaxKind.UTF8StringLiteralToken) ? ClassificationTypeNames.UTF8VerbatimStringLiteral : ClassificationTypeNames.VerbatimStringLiteral; - } - else - { - return token.Kind() is (SyntaxKind.UTF8StringLiteralToken or SyntaxKind.UTF8SingleLineRawStringLiteralToken or SyntaxKind.UTF8MultiLineRawStringLiteralToken) ? - ClassificationTypeNames.UTF8StringLiteral : ClassificationTypeNames.StringLiteral; - } + return IsVerbatimStringToken(token) + ? ClassificationTypeNames.VerbatimStringLiteral + : ClassificationTypeNames.StringLiteral; } else if (token.Kind() == SyntaxKind.NumericLiteralToken) { diff --git a/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs b/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs index 53348dd9e2633..df5baaccd9d47 100644 --- a/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs +++ b/src/Workspaces/Core/Portable/Classification/ClassificationTypeNames.cs @@ -27,7 +27,6 @@ public static class ClassificationTypeNames public const string OperatorOverloaded = "operator - overloaded"; public const string PreprocessorKeyword = "preprocessor keyword"; public const string StringLiteral = "string"; - public const string UTF8StringLiteral = "UTF8 string"; public const string WhiteSpace = "whitespace"; public const string Text = "text"; @@ -37,7 +36,6 @@ public static class ClassificationTypeNames public const string PreprocessorText = "preprocessor text"; public const string Punctuation = "punctuation"; public const string VerbatimStringLiteral = "string - verbatim"; - public const string UTF8VerbatimStringLiteral = "UTF8 string - verbatim"; public const string StringEscapeCharacter = "string - escape character"; public const string ClassName = "class name"; diff --git a/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt b/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt index 0431069023dde..2bada5d42e0b8 100644 --- a/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt +++ b/src/Workspaces/Core/Portable/PublicAPI.Unshipped.txt @@ -1,5 +1,3 @@ -const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.UTF8StringLiteral = "UTF8 string" -> string -const Microsoft.CodeAnalysis.Classification.ClassificationTypeNames.UTF8VerbatimStringLiteral = "UTF8 string - verbatim" -> string Microsoft.CodeAnalysis.Editing.SyntaxEditor.SyntaxEditor(Microsoft.CodeAnalysis.SyntaxNode root, Microsoft.CodeAnalysis.Host.HostWorkspaceServices services) -> void *REMOVED*static Microsoft.CodeAnalysis.Editing.SyntaxGenerator.DefaultRemoveOptions -> Microsoft.CodeAnalysis.SyntaxRemoveOptions static readonly Microsoft.CodeAnalysis.Editing.SyntaxGenerator.DefaultRemoveOptions -> Microsoft.CodeAnalysis.SyntaxRemoveOptions