1
1
"use strict" ;
2
2
import { TmLanguage } from "./TMLanguageModel" ;
3
3
4
+ const letter = "[_a-zA-Z\\$\\p{Lo}\\p{Lt}\\p{Nl}\\p{Ll}\\p{Lu}]"
5
+ const digit = "[0-9]"
6
+ const letterOrDigit = `${ letter } |${ digit } `
7
+ const alphaId = `${ letter } +`
8
+ const simpleInterpolatedVariable = `${ letter } (?:${ letterOrDigit } )*` // see SIP-11 https://docs.scala-lang.org/sips/string-interpolation.html
9
+
4
10
export const scalaTmLanguage : TmLanguage = {
5
11
fileTypes : [
6
12
'scala'
@@ -217,6 +223,36 @@ export const scalaTmLanguage: TmLanguage = {
217
223
} ,
218
224
name : 'string.quoted.triple.scala'
219
225
} ,
226
+ {
227
+ begin : `\\b(${ alphaId } )(""")` ,
228
+ end : '"""(?!")' ,
229
+ beginCaptures : {
230
+ '1' : {
231
+ name : 'keyword.interpolation.scala'
232
+ } ,
233
+ '2' : {
234
+ name : 'string.quoted.triple.interpolated.scala punctuation.definition.string.begin.scala'
235
+ }
236
+ } ,
237
+ patterns : [
238
+ {
239
+ "include" : "#string-interpolation"
240
+ } ,
241
+ {
242
+ match : '\\\\\\\\|\\\\u[0-9A-Fa-f]{4}' ,
243
+ name : 'constant.character.escape.scala'
244
+ } ,
245
+ {
246
+ match : '.' ,
247
+ name : 'string.quoted.triple.interpolated.scala'
248
+ }
249
+ ] ,
250
+ endCaptures : {
251
+ '0' : {
252
+ name : 'string.quoted.triple.interpolated.scala punctuation.definition.string.end.scala'
253
+ }
254
+ }
255
+ } ,
220
256
{
221
257
end : '"' ,
222
258
begin : '"' ,
@@ -241,6 +277,68 @@ export const scalaTmLanguage: TmLanguage = {
241
277
}
242
278
} ,
243
279
name : 'string.quoted.double.scala'
280
+ } ,
281
+ {
282
+ begin : `\\b(${ alphaId } )(")` ,
283
+ end : '"' ,
284
+ beginCaptures : {
285
+ '1' : {
286
+ name : 'keyword.interpolation.scala'
287
+ } ,
288
+ '2' : {
289
+ name : 'string.quoted.double.interpolated.scala punctuation.definition.string.begin.scala'
290
+ }
291
+ } ,
292
+ patterns : [
293
+ {
294
+ include : "#string-interpolation"
295
+ } ,
296
+ {
297
+ match : `\\\\(?:[btnfr\\\\"']|[0-7]{1,3}|u[0-9A-Fa-f]{4})` ,
298
+ name : 'constant.character.escape.scala'
299
+ } ,
300
+ {
301
+ match : '\\\\.' ,
302
+ name : 'invalid.illegal.unrecognized-string-escape.scala'
303
+ } ,
304
+ {
305
+ match : '.' ,
306
+ name : 'string.quoted.double.interpolated.scala'
307
+ }
308
+ ] ,
309
+ endCaptures : {
310
+ '0' : {
311
+ name : 'string.quoted.double.interpolated.scala punctuation.definition.string.end.scala'
312
+ }
313
+ }
314
+ }
315
+ ]
316
+ } ,
317
+ 'string-interpolation' : {
318
+ patterns : [
319
+ {
320
+ name : "constant.character.escape.interpolation.scala" ,
321
+ match : "\\$\\$"
322
+ } ,
323
+ {
324
+ match : `(\\$)(${ simpleInterpolatedVariable } )` ,
325
+ captures : {
326
+ "1" : {
327
+ name : "punctuation.definition.template-expression.begin.scala"
328
+ }
329
+ }
330
+ } ,
331
+ {
332
+ name : "punctuation.definition.template-expression.scala" ,
333
+ begin : "\\$\\{" ,
334
+ beginCaptures : { "0" : { name : "punctuation.definition.template-expression.begin.scala" } } ,
335
+ end : "\\}" ,
336
+ endCaptures : { "0" : { name : "punctuation.definition.template-expression.end.scala" } } ,
337
+ patterns : [
338
+ {
339
+ include : "#code"
340
+ }
341
+ ]
244
342
}
245
343
]
246
344
} ,
0 commit comments