From 2608d3ade45ef7796eaf4b696becdb9d8f277c81 Mon Sep 17 00:00:00 2001 From: Alejandro Serrano Mena Date: Fri, 30 Aug 2024 12:11:23 +0200 Subject: [PATCH] [Lexer] Fix wrong interaction backtick + multi-dollar interpolation ^KT-71073 Fixed ^KT-68971 Fixed --- .../org/jetbrains/kotlin/lexer/Kotlin.flex | 6 +- .../org/jetbrains/kotlin/lexer/_JetLexer.java | 244 ++++++------- .../DisabledMultiDollarInterpolation.fir.txt | 166 ++++----- .../EnabledMultiDollarInterpolation.fir.txt | 166 ++++----- .../stringTemplates/MultiDollarBacktick.kt | 36 ++ .../stringTemplates/MultiDollarBacktick.txt | 331 ++++++++++++++++++ .../kotlin/parsing/ParsingTestGenerated.java | 5 + 7 files changed, 665 insertions(+), 289 deletions(-) create mode 100644 compiler/testData/psi/stringTemplates/MultiDollarBacktick.kt create mode 100644 compiler/testData/psi/stringTemplates/MultiDollarBacktick.txt diff --git a/compiler/psi/src/org/jetbrains/kotlin/lexer/Kotlin.flex b/compiler/psi/src/org/jetbrains/kotlin/lexer/Kotlin.flex index e27a01371a68e..bd4fb3ff11f78 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/lexer/Kotlin.flex +++ b/compiler/psi/src/org/jetbrains/kotlin/lexer/Kotlin.flex @@ -134,7 +134,7 @@ THREE_OR_MORE_QUO = ({THREE_QUO}\"*) REGULAR_STRING_PART=[^\\\"\n\$]+ SHORT_TEMPLATE_ENTRY={INTERPOLATION}{IDENTIFIER} -LONELY_DOLLAR=\$ +LONELY_DOLLAR=\$+ LONG_TEMPLATE_ENTRY_START={INTERPOLATION}\{ LONELY_BACKTICK=` @@ -181,9 +181,10 @@ LONELY_BACKTICK=` int rest = yylength() - interpolationPrefix; if (interpolationPrefix == requiredInterpolationPrefix) { pushState(SHORT_TEMPLATE_ENTRY); - yypushback(yylength() - interpolationPrefix); + yypushback(rest); return KtTokens.SHORT_TEMPLATE_ENTRY_START; } else if (interpolationPrefix < requiredInterpolationPrefix) { + yypushback(rest); return KtTokens.REGULAR_STRING_PART; } else { yypushback(requiredInterpolationPrefix + rest); @@ -204,6 +205,7 @@ LONELY_BACKTICK=` pushState(LONG_TEMPLATE_ENTRY); return KtTokens.LONG_TEMPLATE_ENTRY_START; } else if (interpolationPrefix < requiredInterpolationPrefix) { + yypushback(1); return KtTokens.REGULAR_STRING_PART; } else { yypushback(requiredInterpolationPrefix + 1); diff --git a/compiler/psi/src/org/jetbrains/kotlin/lexer/_JetLexer.java b/compiler/psi/src/org/jetbrains/kotlin/lexer/_JetLexer.java index ebdc5c1d2627a..841f8455d801d 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/lexer/_JetLexer.java +++ b/compiler/psi/src/org/jetbrains/kotlin/lexer/_JetLexer.java @@ -305,7 +305,7 @@ private static int zzUnpackcmap_blocks(String packed, int offset, int [] result) "\1\54\1\55\1\56\1\57\1\60\1\61\1\62\1\63"+ "\1\64\1\65\1\66\2\0\1\21\2\63\3\21\1\67"+ "\1\70\1\71\1\72\1\73\1\74\1\0\1\75\3\31"+ - "\1\76\4\31\1\77\1\100\1\101\12\31\1\102\2\0"+ + "\1\76\4\31\1\77\1\100\1\101\12\31\1\102\1\0"+ "\1\103\1\0\1\104\2\105\2\0\1\43\1\106\1\107"+ "\1\110\1\111\1\112\1\0\1\113\1\114\1\115\1\116"+ "\2\0\1\63\1\117\1\31\1\120\5\31\1\121\1\122"+ @@ -318,7 +318,7 @@ private static int zzUnpackcmap_blocks(String packed, int offset, int [] result) "\1\153\1\154"; private static int [] zzUnpackAction() { - int [] result = new int[237]; + int [] result = new int[236]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -359,23 +359,23 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { "\0\u01dc\0\u01dc\0\u13a8\0\u13ec\0\u1430\0\u1474\0\u14b8\0\u072c"+ "\0\u14fc\0\u1540\0\u1584\0\u15c8\0\u072c\0\u160c\0\u072c\0\u1650"+ "\0\u1694\0\u16d8\0\u171c\0\u1760\0\u17a4\0\u17e8\0\u182c\0\u1870"+ - "\0\u18b4\0\u01dc\0\u18f8\0\u0c7c\0\u193c\0\u1980\0\u01dc\0\u01dc"+ - "\0\u19c4\0\u1a08\0\u1a4c\0\u1a90\0\u01dc\0\u01dc\0\u01dc\0\u1ad4"+ - "\0\u1ad4\0\u1b18\0\u01dc\0\u01dc\0\u1b5c\0\u01dc\0\u1ba0\0\u1be4"+ - "\0\u1c28\0\u01dc\0\u01dc\0\u01dc\0\u1c6c\0\u1cb0\0\u1cf4\0\u1d38"+ - "\0\u1d7c\0\u072c\0\u072c\0\u1dc0\0\u1e04\0\u1e48\0\u1e8c\0\u1ed0"+ - "\0\u1f14\0\u1f58\0\u1f9c\0\u1fe0\0\u072c\0\u2024\0\u072c\0\u072c"+ - "\0\u2068\0\u20ac\0\u01dc\0\u20f0\0\u2134\0\u1a08\0\u01dc\0\u2178"+ - "\0\u01dc\0\u01dc\0\u01dc\0\u21bc\0\u2200\0\u2244\0\u072c\0\u2288"+ - "\0\u22cc\0\u072c\0\u2310\0\u2354\0\u2398\0\u23dc\0\u072c\0\u2420"+ - "\0\u072c\0\u2464\0\u072c\0\u24a8\0\u01dc\0\u24ec\0\u0d48\0\u072c"+ - "\0\u072c\0\u2530\0\u072c\0\u2574\0\u25b8\0\u25fc\0\u2640\0\u072c"+ - "\0\u072c\0\u2684\0\u26c8\0\u072c\0\u270c\0\u2750\0\u2794\0\u072c"+ - "\0\u27d8\0\u072c\0\u281c\0\u072c\0\u2860\0\u28a4\0\u072c\0\u28e8"+ - "\0\u072c\0\u292c\0\u2970\0\u072c\0\u072c"; + "\0\u18b4\0\u01dc\0\u18f8\0\u193c\0\u1980\0\u01dc\0\u01dc\0\u19c4"+ + "\0\u1a08\0\u1a4c\0\u1a90\0\u01dc\0\u01dc\0\u01dc\0\u1ad4\0\u1ad4"+ + "\0\u1b18\0\u01dc\0\u01dc\0\u1b5c\0\u01dc\0\u1ba0\0\u1be4\0\u1c28"+ + "\0\u01dc\0\u01dc\0\u01dc\0\u1c6c\0\u1cb0\0\u1cf4\0\u1d38\0\u1d7c"+ + "\0\u072c\0\u072c\0\u1dc0\0\u1e04\0\u1e48\0\u1e8c\0\u1ed0\0\u1f14"+ + "\0\u1f58\0\u1f9c\0\u1fe0\0\u072c\0\u2024\0\u072c\0\u072c\0\u2068"+ + "\0\u20ac\0\u01dc\0\u20f0\0\u2134\0\u1a08\0\u01dc\0\u2178\0\u01dc"+ + "\0\u01dc\0\u01dc\0\u21bc\0\u2200\0\u2244\0\u072c\0\u2288\0\u22cc"+ + "\0\u072c\0\u2310\0\u2354\0\u2398\0\u23dc\0\u072c\0\u2420\0\u072c"+ + "\0\u2464\0\u072c\0\u24a8\0\u01dc\0\u24ec\0\u0d48\0\u072c\0\u072c"+ + "\0\u2530\0\u072c\0\u2574\0\u25b8\0\u25fc\0\u2640\0\u072c\0\u072c"+ + "\0\u2684\0\u26c8\0\u072c\0\u270c\0\u2750\0\u2794\0\u072c\0\u27d8"+ + "\0\u072c\0\u281c\0\u072c\0\u2860\0\u28a4\0\u072c\0\u28e8\0\u072c"+ + "\0\u292c\0\u2970\0\u072c\0\u072c"; private static int [] zzUnpackRowMap() { - int [] result = new int[237]; + int [] result = new int[236]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -457,138 +457,138 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { "\1\42\24\0\2\42\7\0\10\42\3\0\1\42\1\0"+ "\7\42\1\201\16\42\3\0\1\42\101\0\1\202\10\0"+ "\1\203\75\0\2\71\1\0\3\71\1\0\1\71\1\0"+ - "\35\71\1\0\35\71\10\0\1\204\24\0\10\205\3\0"+ - "\1\205\1\206\26\205\1\207\3\0\2\210\1\0\71\210"+ - "\1\211\7\210\6\0\1\212\121\0\2\100\7\0\10\100"+ - "\3\0\1\100\1\0\26\100\3\0\1\100\2\213\1\0"+ - "\46\213\1\0\32\213\24\0\2\100\7\0\10\100\3\0"+ - "\1\100\1\0\7\100\1\214\16\100\3\0\1\100\23\0"+ - "\1\215\76\0\1\216\116\0\1\217\140\0\1\220\3\0"+ - "\1\221\11\0\2\112\1\0\101\112\6\0\1\13\1\0"+ + "\35\71\1\0\35\71\10\0\1\74\24\0\10\204\3\0"+ + "\1\204\1\205\26\204\1\206\3\0\2\207\1\0\71\207"+ + "\1\210\7\207\6\0\1\211\121\0\2\100\7\0\10\100"+ + "\3\0\1\100\1\0\26\100\3\0\1\100\2\212\1\0"+ + "\46\212\1\0\32\212\24\0\2\100\7\0\10\100\3\0"+ + "\1\100\1\0\7\100\1\213\16\100\3\0\1\100\23\0"+ + "\1\214\76\0\1\215\116\0\1\216\140\0\1\217\3\0"+ + "\1\220\11\0\2\112\1\0\101\112\6\0\1\13\1\0"+ "\1\113\117\0\2\114\7\0\10\114\3\0\1\114\1\0"+ - "\26\114\3\0\1\114\2\222\1\0\46\222\1\0\32\222"+ - "\2\20\1\0\101\20\22\0\1\223\5\0\1\224\77\0"+ + "\26\114\3\0\1\114\2\221\1\0\46\221\1\0\32\221"+ + "\2\20\1\0\101\20\22\0\1\222\5\0\1\223\77\0"+ "\2\131\11\0\1\140\1\141\7\0\1\131\5\0\1\140"+ - "\1\141\42\0\1\225\65\0\2\133\1\0\101\133\22\0"+ - "\1\226\1\0\2\131\100\0\1\227\1\0\2\136\11\0"+ + "\1\141\42\0\1\224\65\0\2\133\1\0\101\133\22\0"+ + "\1\225\1\0\2\131\100\0\1\226\1\0\2\136\11\0"+ "\1\140\1\141\7\0\1\136\5\0\1\140\1\141\46\0"+ - "\1\230\1\0\2\137\14\0\1\142\1\143\4\0\1\137"+ - "\14\0\1\142\6\0\1\143\26\0\1\231\1\0\1\231"+ - "\2\0\2\231\12\0\1\141\7\0\1\231\6\0\1\141"+ - "\46\0\1\230\103\0\1\230\17\0\1\142\22\0\1\142"+ - "\40\0\1\230\1\0\2\144\7\0\4\144\1\0\1\142"+ + "\1\227\1\0\2\137\14\0\1\142\1\143\4\0\1\137"+ + "\14\0\1\142\6\0\1\143\26\0\1\230\1\0\1\230"+ + "\2\0\2\230\12\0\1\141\7\0\1\230\6\0\1\141"+ + "\46\0\1\227\103\0\1\227\17\0\1\142\22\0\1\142"+ + "\40\0\1\227\1\0\2\144\7\0\4\144\1\0\1\142"+ "\1\143\4\0\1\144\1\0\6\144\5\0\1\142\6\0"+ - "\1\143\40\0\1\232\52\0\2\153\1\0\46\153\1\233"+ - "\32\153\24\0\2\42\5\0\1\234\1\0\10\42\3\0"+ + "\1\143\40\0\1\231\52\0\2\153\1\0\46\153\1\232"+ + "\32\153\24\0\2\42\5\0\1\233\1\0\10\42\3\0"+ "\1\42\1\0\26\42\3\0\1\42\24\0\2\42\7\0"+ - "\10\42\3\0\1\42\1\0\4\42\1\235\21\42\3\0"+ + "\10\42\3\0\1\42\1\0\4\42\1\234\21\42\3\0"+ "\1\42\24\0\2\42\7\0\10\42\3\0\1\42\1\0"+ - "\1\236\25\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\14\42\1\237\11\42\3\0\1\42"+ + "\1\235\25\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\14\42\1\236\11\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\20\42"+ - "\1\240\5\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\13\42\1\241\12\42\3\0\1\42"+ + "\1\237\5\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\13\42\1\240\12\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\17\42"+ - "\1\242\6\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\14\42\1\243\11\42\3\0\1\42"+ + "\1\241\6\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\14\42\1\242\11\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\21\42"+ - "\1\244\4\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\13\42\1\245\12\42\3\0\1\42"+ + "\1\243\4\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\13\42\1\244\12\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\11\42"+ - "\1\246\14\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\2\42\1\247\23\42\3\0\1\42"+ + "\1\245\14\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\2\42\1\246\23\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\21\42"+ - "\1\250\4\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\16\42\1\251\7\42\3\0\1\42"+ + "\1\247\4\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\16\42\1\250\7\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\10\42"+ - "\1\252\6\42\1\253\6\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\22\42\1\254\2\42"+ - "\1\255\3\0\1\42\24\0\2\42\7\0\10\42\3\0"+ - "\1\42\1\0\16\42\1\256\7\42\3\0\1\42\24\0"+ - "\2\42\7\0\10\42\3\0\1\42\1\0\13\42\1\257"+ - "\3\42\1\260\6\42\3\0\1\42\24\0\2\42\7\0"+ - "\10\42\3\0\1\42\1\0\4\42\1\261\3\42\1\262"+ - "\15\42\3\0\1\42\6\0\1\263\121\0\2\205\7\0"+ - "\10\205\3\0\1\205\1\0\26\205\3\0\1\205\2\264"+ - "\1\0\46\264\1\0\32\264\24\0\2\265\7\0\4\265"+ - "\11\0\6\265\32\0\1\266\75\0\2\213\1\0\46\213"+ - "\1\267\32\213\24\0\2\100\7\0\10\100\3\0\1\100"+ - "\1\0\10\100\1\270\15\100\3\0\1\100\24\0\2\271"+ - "\7\0\10\271\3\0\1\271\1\0\26\271\3\0\1\271"+ - "\2\222\1\0\46\222\1\272\32\222\23\0\1\273\104\0"+ - "\2\131\100\0\1\226\105\0\2\231\12\0\1\141\7\0"+ - "\1\231\6\0\1\141\50\0\2\42\7\0\10\42\3\0"+ - "\1\42\1\0\1\274\25\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\20\42\1\275\5\42"+ + "\1\251\6\42\1\252\6\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\22\42\1\253\2\42"+ + "\1\254\3\0\1\42\24\0\2\42\7\0\10\42\3\0"+ + "\1\42\1\0\16\42\1\255\7\42\3\0\1\42\24\0"+ + "\2\42\7\0\10\42\3\0\1\42\1\0\13\42\1\256"+ + "\3\42\1\257\6\42\3\0\1\42\24\0\2\42\7\0"+ + "\10\42\3\0\1\42\1\0\4\42\1\260\3\42\1\261"+ + "\15\42\3\0\1\42\6\0\1\262\121\0\2\204\7\0"+ + "\10\204\3\0\1\204\1\0\26\204\3\0\1\204\2\263"+ + "\1\0\46\263\1\0\32\263\24\0\2\264\7\0\4\264"+ + "\11\0\6\264\32\0\1\265\75\0\2\212\1\0\46\212"+ + "\1\266\32\212\24\0\2\100\7\0\10\100\3\0\1\100"+ + "\1\0\10\100\1\267\15\100\3\0\1\100\24\0\2\270"+ + "\7\0\10\270\3\0\1\270\1\0\26\270\3\0\1\270"+ + "\2\221\1\0\46\221\1\271\32\221\23\0\1\272\104\0"+ + "\2\131\100\0\1\225\105\0\2\230\12\0\1\141\7\0"+ + "\1\230\6\0\1\141\50\0\2\42\7\0\10\42\3\0"+ + "\1\42\1\0\1\273\25\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\20\42\1\274\5\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\21\42\1\276\4\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\4\42\1\277\21\42"+ + "\1\0\21\42\1\275\4\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\4\42\1\276\21\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\20\42\1\300\5\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\4\42\1\301\21\42"+ + "\1\0\20\42\1\277\5\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\4\42\1\300\21\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\13\42\1\302\12\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\4\42\1\303\21\42"+ + "\1\0\13\42\1\301\12\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\4\42\1\302\21\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\12\42\1\304\13\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\22\42\1\305\3\42"+ + "\1\0\12\42\1\303\13\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\22\42\1\304\3\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\4\42\1\306\21\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\20\42\1\307\5\42"+ + "\1\0\4\42\1\305\21\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\20\42\1\306\5\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\15\42\1\310\10\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\4\42\1\311\21\42"+ + "\1\0\15\42\1\307\10\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\4\42\1\310\21\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\4\42\1\312\21\42\3\0\1\42\24\0\2\42"+ - "\7\0\10\42\3\0\1\42\1\0\14\42\1\313\11\42"+ + "\1\0\4\42\1\311\21\42\3\0\1\42\24\0\2\42"+ + "\7\0\10\42\3\0\1\42\1\0\14\42\1\312\11\42"+ "\3\0\1\42\24\0\2\42\7\0\10\42\3\0\1\42"+ - "\1\0\13\42\1\314\12\42\3\0\1\42\2\264\1\0"+ - "\46\264\1\315\32\264\24\0\2\316\7\0\4\316\11\0"+ - "\6\316\50\0\2\100\7\0\10\100\3\0\1\100\1\0"+ - "\20\100\1\317\5\100\3\0\1\100\24\0\2\42\7\0"+ - "\10\42\3\0\1\42\1\0\12\42\1\320\13\42\3\0"+ + "\1\0\13\42\1\313\12\42\3\0\1\42\2\263\1\0"+ + "\46\263\1\314\32\263\24\0\2\315\7\0\4\315\11\0"+ + "\6\315\50\0\2\100\7\0\10\100\3\0\1\100\1\0"+ + "\20\100\1\316\5\100\3\0\1\100\24\0\2\42\7\0"+ + "\10\42\3\0\1\42\1\0\12\42\1\317\13\42\3\0"+ "\1\42\24\0\2\42\7\0\10\42\3\0\1\42\1\0"+ - "\20\42\1\321\5\42\3\0\1\42\24\0\2\42\7\0"+ - "\10\42\3\0\1\42\1\0\10\42\1\322\15\42\3\0"+ + "\20\42\1\320\5\42\3\0\1\42\24\0\2\42\7\0"+ + "\10\42\3\0\1\42\1\0\10\42\1\321\15\42\3\0"+ "\1\42\24\0\2\42\7\0\10\42\3\0\1\42\1\0"+ - "\4\42\1\323\21\42\3\0\1\42\24\0\2\42\7\0"+ - "\10\42\3\0\1\42\1\0\17\42\1\324\6\42\3\0"+ + "\4\42\1\322\21\42\3\0\1\42\24\0\2\42\7\0"+ + "\10\42\3\0\1\42\1\0\17\42\1\323\6\42\3\0"+ "\1\42\24\0\2\42\7\0\10\42\3\0\1\42\1\0"+ - "\2\42\1\325\23\42\3\0\1\42\24\0\2\42\7\0"+ - "\10\42\3\0\1\42\1\0\1\326\25\42\3\0\1\42"+ + "\2\42\1\324\23\42\3\0\1\42\24\0\2\42\7\0"+ + "\10\42\3\0\1\42\1\0\1\325\25\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\17\42"+ - "\1\327\6\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\17\42\1\330\6\42\3\0\1\42"+ + "\1\326\6\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\17\42\1\327\6\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\24\42"+ - "\1\331\1\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\1\332\14\42\1\333\10\42\3\0"+ + "\1\330\1\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\1\331\14\42\1\332\10\42\3\0"+ "\1\42\24\0\2\42\7\0\10\42\3\0\1\42\1\0"+ - "\4\42\1\334\21\42\3\0\1\42\24\0\2\335\7\0"+ - "\4\335\11\0\6\335\50\0\2\42\7\0\10\42\3\0"+ - "\1\42\1\0\14\42\1\336\11\42\3\0\1\42\24\0"+ - "\2\42\7\0\10\42\3\0\1\42\1\0\5\42\1\337"+ + "\4\42\1\333\21\42\3\0\1\42\24\0\2\334\7\0"+ + "\4\334\11\0\6\334\50\0\2\42\7\0\10\42\3\0"+ + "\1\42\1\0\14\42\1\335\11\42\3\0\1\42\24\0"+ + "\2\42\7\0\10\42\3\0\1\42\1\0\5\42\1\336"+ "\20\42\3\0\1\42\24\0\2\42\7\0\10\42\3\0"+ - "\1\42\1\0\21\42\1\340\4\42\3\0\1\42\24\0"+ - "\2\42\7\0\10\42\3\0\1\42\1\0\6\42\1\341"+ + "\1\42\1\0\21\42\1\337\4\42\3\0\1\42\24\0"+ + "\2\42\7\0\10\42\3\0\1\42\1\0\6\42\1\340"+ "\17\42\3\0\1\42\24\0\2\42\7\0\10\42\3\0"+ - "\1\42\1\0\14\42\1\342\11\42\3\0\1\42\24\0"+ - "\2\42\7\0\10\42\3\0\1\42\1\0\13\42\1\343"+ + "\1\42\1\0\14\42\1\341\11\42\3\0\1\42\24\0"+ + "\2\42\7\0\10\42\3\0\1\42\1\0\13\42\1\342"+ "\12\42\3\0\1\42\24\0\2\42\7\0\10\42\3\0"+ - "\1\42\1\0\5\42\1\344\20\42\3\0\1\42\24\0"+ - "\2\210\7\0\4\210\11\0\6\210\50\0\2\42\7\0"+ - "\10\42\3\0\1\42\1\0\22\42\1\345\3\42\3\0"+ + "\1\42\1\0\5\42\1\343\20\42\3\0\1\42\24\0"+ + "\2\207\7\0\4\207\11\0\6\207\50\0\2\42\7\0"+ + "\10\42\3\0\1\42\1\0\22\42\1\344\3\42\3\0"+ "\1\42\24\0\2\42\7\0\10\42\3\0\1\42\1\0"+ - "\1\346\25\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\4\42\1\347\21\42\3\0\1\42"+ + "\1\345\25\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\4\42\1\346\21\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\10\42"+ - "\1\350\15\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\4\42\1\351\21\42\3\0\1\42"+ + "\1\347\15\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\4\42\1\350\21\42\3\0\1\42"+ "\24\0\2\42\7\0\10\42\3\0\1\42\1\0\2\42"+ - "\1\352\23\42\3\0\1\42\24\0\2\42\7\0\10\42"+ - "\3\0\1\42\1\0\1\353\25\42\3\0\1\42\24\0"+ - "\2\42\7\0\10\42\3\0\1\42\1\0\4\42\1\354"+ + "\1\351\23\42\3\0\1\42\24\0\2\42\7\0\10\42"+ + "\3\0\1\42\1\0\1\352\25\42\3\0\1\42\24\0"+ + "\2\42\7\0\10\42\3\0\1\42\1\0\4\42\1\353"+ "\21\42\3\0\1\42\24\0\2\42\7\0\10\42\3\0"+ - "\1\42\1\0\20\42\1\355\5\42\3\0\1\42"; + "\1\42\1\0\20\42\1\354\5\42\3\0\1\42"; private static int [] zzUnpacktrans() { int [] result = new int[10676]; @@ -634,14 +634,14 @@ private static int zzUnpacktrans(String packed, int offset, int [] result) { "\2\1\2\11\2\1\1\11\4\1\1\11\2\1\2\11"+ "\1\1\1\0\1\1\1\0\1\1\1\0\3\11\1\1"+ "\6\11\4\1\1\11\2\0\2\1\1\11\3\1\3\11"+ - "\1\1\2\11\1\0\26\1\1\11\2\0\1\1\1\0"+ + "\1\1\2\11\1\0\26\1\1\11\1\0\1\1\1\0"+ "\2\11\1\1\2\0\1\1\3\11\2\1\1\0\2\11"+ "\1\1\1\11\2\0\1\1\3\11\26\1\1\11\2\0"+ "\1\1\1\11\1\1\3\11\21\1\1\11\1\0\16\1"+ "\1\0\20\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[237]; + int [] result = new int[236]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -1026,14 +1026,14 @@ else if (zzAtEOF) { zzStartRead = commentStart; return commentStateToTokenType(state); } // fall though - case 238: break; + case 237: break; case DOC_COMMENT: { int state = yystate(); popState(); zzStartRead = commentStart; return commentStateToTokenType(state); } // fall though - case 239: break; + case 238: break; default: return null; } @@ -1395,9 +1395,10 @@ else if (zzAtEOF) { int rest = yylength() - interpolationPrefix; if (interpolationPrefix == requiredInterpolationPrefix) { pushState(SHORT_TEMPLATE_ENTRY); - yypushback(yylength() - interpolationPrefix); + yypushback(rest); return KtTokens.SHORT_TEMPLATE_ENTRY_START; } else if (interpolationPrefix < requiredInterpolationPrefix) { + yypushback(rest); return KtTokens.REGULAR_STRING_PART; } else { yypushback(requiredInterpolationPrefix + rest); @@ -1412,6 +1413,7 @@ else if (zzAtEOF) { pushState(LONG_TEMPLATE_ENTRY); return KtTokens.LONG_TEMPLATE_ENTRY_START; } else if (interpolationPrefix < requiredInterpolationPrefix) { + yypushback(1); return KtTokens.REGULAR_STRING_PART; } else { yypushback(requiredInterpolationPrefix + 1); diff --git a/compiler/testData/diagnostics/tests/DisabledMultiDollarInterpolation.fir.txt b/compiler/testData/diagnostics/tests/DisabledMultiDollarInterpolation.fir.txt index addd457267720..af5e72298bfed 100644 --- a/compiler/testData/diagnostics/tests/DisabledMultiDollarInterpolation.fir.txt +++ b/compiler/testData/diagnostics/tests/DisabledMultiDollarInterpolation.fir.txt @@ -52,12 +52,12 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$ padding) String(padding $$$$ padding) String(padding $$$$$$$$ padding) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( padding ), R|/text|) } public final fun dollarsInStringsB(): R|kotlin/Unit| { String(padding $ padding) @@ -67,11 +67,11 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$ padding) String(padding $$$$$$$ padding) (String(padding ), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$), String( padding ), R|/text|) (String(padding ), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$), String( padding ), R|/text|) } public final fun dollarsInStringsC(): R|kotlin/Unit| { String(padding $$ padding) @@ -84,16 +84,16 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$ padding) String(padding $$$$$ padding) String(padding $$$$$$$$$ padding) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$$), String( padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfSimpleIdentifierA(): R|kotlin/Unit| { String(padding $ value padding) @@ -108,14 +108,14 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$$$$$$ value padding) (String(padding ), String($), String( value padding ), R|/text|) (String(padding ), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( value padding ), R|/text|) + (String(padding ), String($$), String( value padding ), R|/text|) + (String(padding ), String($$$$), String( value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( value padding ), R|/text|) (String(padding ), String($), String( value padding ), R|/text|) (String(padding ), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( value padding ), R|/text|) + (String(padding ), String($$), String( value padding ), R|/text|) + (String(padding ), String($$$$), String( value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( value padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfSimpleIdentifierB(): R|kotlin/Unit| { String(padding $-value padding) @@ -130,14 +130,14 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$$$$$$-value padding) (String(padding ), String($), String(-value padding ), R|/text|) (String(padding ), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(-value padding ), R|/text|) + (String(padding ), String($$), String(-value padding ), R|/text|) + (String(padding ), String($$$$), String(-value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(-value padding ), R|/text|) (String(padding ), String($), String(-value padding ), R|/text|) (String(padding ), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(-value padding ), R|/text|) + (String(padding ), String($$), String(-value padding ), R|/text|) + (String(padding ), String($$$$), String(-value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(-value padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfIdentifierInBackticks(): R|kotlin/Unit| { String(padding $`` padding) @@ -152,14 +152,14 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$$$$$$`` padding) (String(padding ), String($), String(`` padding ), R|/text|) (String(padding ), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(`` padding ), R|/text|) + (String(padding ), String($$), String(`` padding ), R|/text|) + (String(padding ), String($$$$), String(`` padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(`` padding ), R|/text|) (String(padding ), String($), String(`` padding ), R|/text|) (String(padding ), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(`` padding ), R|/text|) + (String(padding ), String($$), String(`` padding ), R|/text|) + (String(padding ), String($$$$), String(`` padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(`` padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfArbitraryExpression(): R|kotlin/Unit| { String(padding $ {0 + value} padding) @@ -174,14 +174,14 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$$$$$$ {0 + value} padding) (String(padding ), String($), String( {0 + value} padding ), R|/text|) (String(padding ), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( {0 + value} padding ), R|/text|) (String(padding ), String($), String( {0 + value} padding ), R|/text|) (String(padding ), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( {0 + value} padding ), R|/text|) } public final fun insufficientDollarForInterpolation(): R|kotlin/Unit| { String(padding $value padding) @@ -202,24 +202,24 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding ${0 + value} padding) String(padding ${0 + value} padding) String(padding ${0 + value} padding) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) } public final fun insufficientDollarsForInterpolation(): R|kotlin/Unit| { String(padding $$$value padding) @@ -234,18 +234,18 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$$$$$`value` padding) String(padding $$${0 + value} padding) String(padding $$$$$$${0 + value} padding) - (String(padding ), String($$$value), String( padding ), R|/text|) - (String(padding ), String($$$$$$$value), String( padding ), R|/text|) - (String(padding ), String($$$`value`), String( padding ), R|/text|) - (String(padding ), String($$$$$$$`value`), String( padding ), R|/text|) - (String(padding ), String($$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($$$$$$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($$$value), String( padding ), R|/text|) - (String(padding ), String($$$$$$$value), String( padding ), R|/text|) - (String(padding ), String($$$`value`), String( padding ), R|/text|) - (String(padding ), String($$$$$$$`value`), String( padding ), R|/text|) - (String(padding ), String($$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($$$$$$${), String(0 + value} padding ), R|/text|) + (String(padding ), String($$$), String(value padding ), R|/text|) + (String(padding ), String($$$$$$$), String(value padding ), R|/text|) + (String(padding ), String($$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$$$$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($$$), String(value padding ), R|/text|) + (String(padding ), String($$$$$$$), String(value padding ), R|/text|) + (String(padding ), String($$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$$$$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$), String({0 + value} padding ), R|/text|) } public final fun escapedDollarInInterpolationPrefix(): R|kotlin/Unit| { String(padding $value padding) @@ -265,19 +265,19 @@ FILE: DisabledMultiDollarInterpolation.kt String(padding $$$$$$$${0 + value} padding) (String(padding ), String($), String(value padding ), R|/text|) (String(padding ), String($), String(value padding ), R|/text|) - (String(padding ), String($), String($value), String( padding ), R|/text|) - (String(padding ), String($), String($$$value), String( padding ), R|/text|) - (String(padding ), String($), String($$$$$$$value), String( padding ), R|/text|) + (String(padding ), String($), String($), String(value padding ), R|/text|) + (String(padding ), String($), String($$$), String(value padding ), R|/text|) + (String(padding ), String($), String($$$$$$$), String(value padding ), R|/text|) (String(padding ), String($), String(`value` padding ), R|/text|) (String(padding ), String($), String(`value` padding ), R|/text|) - (String(padding ), String($), String($`value`), String( padding ), R|/text|) - (String(padding ), String($), String($$$`value`), String( padding ), R|/text|) - (String(padding ), String($), String($$$$$$$`value`), String( padding ), R|/text|) + (String(padding ), String($), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String($$$), String(`value` padding ), R|/text|) + (String(padding ), String($), String($$$$$$$), String(`value` padding ), R|/text|) (String(padding ), String($), String({0 + value} padding ), R|/text|) (String(padding ), String($), String({0 + value} padding ), R|/text|) - (String(padding ), String($), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String($), String($$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($), String($$$$$$${), String(0 + value} padding ), R|/text|) + (String(padding ), String($), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String($$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String($$$$$$$), String({0 + value} padding ), R|/text|) } public final fun stringsWithRedundantInterpolation(): R|kotlin/Unit| { (R|/text|) diff --git a/compiler/testData/diagnostics/tests/EnabledMultiDollarInterpolation.fir.txt b/compiler/testData/diagnostics/tests/EnabledMultiDollarInterpolation.fir.txt index f8fc2a5fdcf1e..9108097ec70e1 100644 --- a/compiler/testData/diagnostics/tests/EnabledMultiDollarInterpolation.fir.txt +++ b/compiler/testData/diagnostics/tests/EnabledMultiDollarInterpolation.fir.txt @@ -52,12 +52,12 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$ padding) String(padding $$$$ padding) String(padding $$$$$$$$ padding) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( padding ), R|/text|) } public final fun dollarsInStringsB(): R|kotlin/Unit| { String(padding $ padding) @@ -67,11 +67,11 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$ padding) String(padding $$$$$$$ padding) (String(padding ), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$), String( padding ), R|/text|) (String(padding ), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$), String( padding ), R|/text|) } public final fun dollarsInStringsC(): R|kotlin/Unit| { String(padding $$ padding) @@ -84,16 +84,16 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$ padding) String(padding $$$$$ padding) String(padding $$$$$$$$$ padding) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String( padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String($), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$), String( padding ), R|/text|) + (String(padding ), String($$$), String( padding ), R|/text|) + (String(padding ), String($$$$$), String( padding ), R|/text|) + (String(padding ), String($$$$$$$$$), String( padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfSimpleIdentifierA(): R|kotlin/Unit| { String(padding $ value padding) @@ -108,14 +108,14 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$$$$$$ value padding) (String(padding ), String($), String( value padding ), R|/text|) (String(padding ), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( value padding ), R|/text|) + (String(padding ), String($$), String( value padding ), R|/text|) + (String(padding ), String($$$$), String( value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( value padding ), R|/text|) (String(padding ), String($), String( value padding ), R|/text|) (String(padding ), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( value padding ), R|/text|) + (String(padding ), String($$), String( value padding ), R|/text|) + (String(padding ), String($$$$), String( value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( value padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfSimpleIdentifierB(): R|kotlin/Unit| { String(padding $-value padding) @@ -130,14 +130,14 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$$$$$$-value padding) (String(padding ), String($), String(-value padding ), R|/text|) (String(padding ), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(-value padding ), R|/text|) + (String(padding ), String($$), String(-value padding ), R|/text|) + (String(padding ), String($$$$), String(-value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(-value padding ), R|/text|) (String(padding ), String($), String(-value padding ), R|/text|) (String(padding ), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(-value padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(-value padding ), R|/text|) + (String(padding ), String($$), String(-value padding ), R|/text|) + (String(padding ), String($$$$), String(-value padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(-value padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfIdentifierInBackticks(): R|kotlin/Unit| { String(padding $`` padding) @@ -152,14 +152,14 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$$$$$$`` padding) (String(padding ), String($), String(`` padding ), R|/text|) (String(padding ), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(`` padding ), R|/text|) + (String(padding ), String($$), String(`` padding ), R|/text|) + (String(padding ), String($$$$), String(`` padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(`` padding ), R|/text|) (String(padding ), String($), String(`` padding ), R|/text|) (String(padding ), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String(`` padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String(`` padding ), R|/text|) + (String(padding ), String($$), String(`` padding ), R|/text|) + (String(padding ), String($$$$), String(`` padding ), R|/text|) + (String(padding ), String($$$$$$$$), String(`` padding ), R|/text|) } public final fun dollarsWithoutInterpolationOfArbitraryExpression(): R|kotlin/Unit| { String(padding $ {0 + value} padding) @@ -174,14 +174,14 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$$$$$$ {0 + value} padding) (String(padding ), String($), String( {0 + value} padding ), R|/text|) (String(padding ), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( {0 + value} padding ), R|/text|) (String(padding ), String($), String( {0 + value} padding ), R|/text|) (String(padding ), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) - (String(padding ), String($), String($), String($), String($), String($), String($), String($), String($), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$), String( {0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$$), String( {0 + value} padding ), R|/text|) } public final fun insufficientDollarForInterpolation(): R|kotlin/Unit| { String(padding $value padding) @@ -202,24 +202,24 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding ${0 + value} padding) String(padding ${0 + value} padding) String(padding ${0 + value} padding) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($value), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String($`value`), String( padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String(${), String(0 + value} padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(value padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String({0 + value} padding ), R|/text|) } public final fun insufficientDollarsForInterpolation(): R|kotlin/Unit| { String(padding $$$value padding) @@ -234,18 +234,18 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$$$$$`value` padding) String(padding $$${0 + value} padding) String(padding $$$$$$${0 + value} padding) - (String(padding ), String($$$value), String( padding ), R|/text|) - (String(padding ), String($$$$$$$value), String( padding ), R|/text|) - (String(padding ), String($$$`value`), String( padding ), R|/text|) - (String(padding ), String($$$$$$$`value`), String( padding ), R|/text|) - (String(padding ), String($$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($$$$$$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($$$value), String( padding ), R|/text|) - (String(padding ), String($$$$$$$value), String( padding ), R|/text|) - (String(padding ), String($$$`value`), String( padding ), R|/text|) - (String(padding ), String($$$$$$$`value`), String( padding ), R|/text|) - (String(padding ), String($$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($$$$$$${), String(0 + value} padding ), R|/text|) + (String(padding ), String($$$), String(value padding ), R|/text|) + (String(padding ), String($$$$$$$), String(value padding ), R|/text|) + (String(padding ), String($$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$$$$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($$$), String(value padding ), R|/text|) + (String(padding ), String($$$$$$$), String(value padding ), R|/text|) + (String(padding ), String($$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$$$$$), String(`value` padding ), R|/text|) + (String(padding ), String($$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($$$$$$$), String({0 + value} padding ), R|/text|) } public final fun escapedDollarInInterpolationPrefix(): R|kotlin/Unit| { String(padding $value padding) @@ -265,19 +265,19 @@ FILE: EnabledMultiDollarInterpolation.fir.kt String(padding $$$$$$$${0 + value} padding) (String(padding ), String($), String(value padding ), R|/text|) (String(padding ), String($), String(value padding ), R|/text|) - (String(padding ), String($), String($value), String( padding ), R|/text|) - (String(padding ), String($), String($$$value), String( padding ), R|/text|) - (String(padding ), String($), String($$$$$$$value), String( padding ), R|/text|) + (String(padding ), String($), String($), String(value padding ), R|/text|) + (String(padding ), String($), String($$$), String(value padding ), R|/text|) + (String(padding ), String($), String($$$$$$$), String(value padding ), R|/text|) (String(padding ), String($), String(`value` padding ), R|/text|) (String(padding ), String($), String(`value` padding ), R|/text|) - (String(padding ), String($), String($`value`), String( padding ), R|/text|) - (String(padding ), String($), String($$$`value`), String( padding ), R|/text|) - (String(padding ), String($), String($$$$$$$`value`), String( padding ), R|/text|) + (String(padding ), String($), String($), String(`value` padding ), R|/text|) + (String(padding ), String($), String($$$), String(`value` padding ), R|/text|) + (String(padding ), String($), String($$$$$$$), String(`value` padding ), R|/text|) (String(padding ), String($), String({0 + value} padding ), R|/text|) (String(padding ), String($), String({0 + value} padding ), R|/text|) - (String(padding ), String($), String(${), String(0 + value} padding ), R|/text|) - (String(padding ), String($), String($$${), String(0 + value} padding ), R|/text|) - (String(padding ), String($), String($$$$$$${), String(0 + value} padding ), R|/text|) + (String(padding ), String($), String($), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String($$$), String({0 + value} padding ), R|/text|) + (String(padding ), String($), String($$$$$$$), String({0 + value} padding ), R|/text|) } public final fun stringsWithRedundantInterpolation(): R|kotlin/Unit| { (R|/text|) diff --git a/compiler/testData/psi/stringTemplates/MultiDollarBacktick.kt b/compiler/testData/psi/stringTemplates/MultiDollarBacktick.kt new file mode 100644 index 0000000000000..0545533e11762 --- /dev/null +++ b/compiler/testData/psi/stringTemplates/MultiDollarBacktick.kt @@ -0,0 +1,36 @@ +fun parserBug() { + // No closing backtick — not an identifier + """ + ${"${"$`identifier"}"} "}"} + """.trimIndent() + + // Two backticks — everything inside is an identifier + """ + ${"${"$`identifier"}"} `"}"} + """.trimIndent() + + // Escaped dollar, not an identifier + """ + ${"${"\$`identifier"}"} `"}"} + """.trimIndent() + + // Innermost string should not grab too much + """ + ${"${$$$"$$`identifier"}"} `"}"} + """.trimIndent() + + // Three dollars is the escape sequence, everything inside the backticks is an identifier + """ + ${"${$$$"$$$`identifier"}"} `"}"} + """.trimIndent() + + // Without the closing backtick the innermost string stops where expected + """ + ${"${$$$"$$`identifier"}"} "}"} + """.trimIndent() + + // on simple strings + $$$"$$`identifier" + "${$$$"$$`identifier"} + "${$$$"$$$`identifier`"} +} \ No newline at end of file diff --git a/compiler/testData/psi/stringTemplates/MultiDollarBacktick.txt b/compiler/testData/psi/stringTemplates/MultiDollarBacktick.txt new file mode 100644 index 0000000000000..f3300ed0e3123 --- /dev/null +++ b/compiler/testData/psi/stringTemplates/MultiDollarBacktick.txt @@ -0,0 +1,331 @@ +KtFile: MultiDollarBacktick.kt + PACKAGE_DIRECTIVE + + IMPORT_LIST + + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('parserBug') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + BLOCK + PsiElement(LBRACE)('{') + PsiWhiteSpace('\n ') + PsiComment(EOL_COMMENT)('// No closing backtick — not an identifier') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"""') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('$') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('`identifier') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + PsiElement(CLOSING_QUOTE)('"""') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('trimIndent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// Two backticks — everything inside is an identifier') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"""') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + SHORT_STRING_TEMPLATE_ENTRY + PsiElement(SHORT_TEMPLATE_ENTRY_START)('$') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('`identifier"}"} `') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + PsiElement(CLOSING_QUOTE)('"""') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('trimIndent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// Escaped dollar, not an identifier') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"""') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + ESCAPE_STRING_TEMPLATE_ENTRY + PsiElement(ESCAPE_SEQUENCE)('\$') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('`identifier') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' `') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + PsiElement(CLOSING_QUOTE)('"""') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('trimIndent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// Innermost string should not grab too much') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"""') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(INTERPOLATION_PREFIX)('$$$') + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('$$') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('`identifier') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' `') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + PsiElement(CLOSING_QUOTE)('"""') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('trimIndent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// Three dollars is the escape sequence, everything inside the backticks is an identifier') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"""') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(INTERPOLATION_PREFIX)('$$$') + PsiElement(OPEN_QUOTE)('"') + SHORT_STRING_TEMPLATE_ENTRY + PsiElement(SHORT_TEMPLATE_ENTRY_START)('$$$') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('`identifier"}"} `') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + PsiElement(CLOSING_QUOTE)('"""') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('trimIndent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// Without the closing backtick the innermost string stops where expected') + PsiWhiteSpace('\n ') + DOT_QUALIFIED_EXPRESSION + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"""') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(INTERPOLATION_PREFIX)('$$$') + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('$$') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('`identifier') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('}') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('\n') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)(' ') + PsiElement(CLOSING_QUOTE)('"""') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('trimIndent') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + PsiComment(EOL_COMMENT)('// on simple strings') + PsiWhiteSpace('\n ') + STRING_TEMPLATE + PsiElement(INTERPOLATION_PREFIX)('$$$') + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('$$') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('`identifier') + PsiElement(CLOSING_QUOTE)('"') + PsiWhiteSpace('\n ') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(INTERPOLATION_PREFIX)('$$$') + PsiElement(OPEN_QUOTE)('"') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('$$') + LITERAL_STRING_TEMPLATE_ENTRY + PsiElement(REGULAR_STRING_PART)('`identifier') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiErrorElement:Expecting '"' + + PsiWhiteSpace('\n ') + STRING_TEMPLATE + PsiElement(OPEN_QUOTE)('"') + LONG_STRING_TEMPLATE_ENTRY + PsiElement(LONG_TEMPLATE_ENTRY_START)('${') + STRING_TEMPLATE + PsiElement(INTERPOLATION_PREFIX)('$$$') + PsiElement(OPEN_QUOTE)('"') + SHORT_STRING_TEMPLATE_ENTRY + PsiElement(SHORT_TEMPLATE_ENTRY_START)('$$$') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('`identifier`') + PsiElement(CLOSING_QUOTE)('"') + PsiElement(LONG_TEMPLATE_ENTRY_END)('}') + PsiErrorElement:Expecting '"' + + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java index 7e6e2ed693f31..d24a308bc3683 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/parsing/ParsingTestGenerated.java @@ -2903,6 +2903,11 @@ public void testIncorrectPaddedMultiDollarInterpolationCode() { runTest("compiler/testData/psi/stringTemplates/IncorrectPaddedMultiDollarInterpolationCode.kt"); } + @TestMetadata("MultiDollarBacktick.kt") + public void testMultiDollarBacktick() { + runTest("compiler/testData/psi/stringTemplates/MultiDollarBacktick.kt"); + } + @TestMetadata("RawStringsWithManyQuotes.kt") public void testRawStringsWithManyQuotes() { runTest("compiler/testData/psi/stringTemplates/RawStringsWithManyQuotes.kt");