Skip to content

Commit cd24dc8

Browse files
committed
Merge symbol and quote capturing
Syntax for quotes and symbols overlap. We can tag these as symbols and quotes at the same time.
1 parent 6839617 commit cd24dc8

File tree

5 files changed

+56
-29
lines changed

5 files changed

+56
-29
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,14 @@ export const scalaTmLanguage: TmLanguage = {
299299
{
300300
include: '#constants'
301301
},
302-
{
303-
include: '#scala-symbol'
304-
},
305302
{
306303
include: '#singleton-type'
307304
},
308305
{
309306
include: '#inline'
310307
},
311308
{
312-
include: '#scala-quoted'
309+
include: '#scala-quoted-or-symbol'
313310
},
314311
{
315312
include: '#char-literal'
@@ -710,16 +707,31 @@ export const scalaTmLanguage: TmLanguage = {
710707
}
711708
]
712709
},
713-
'scala-quoted': {
710+
'scala-quoted-or-symbol': {
714711
patterns: [
715-
{ // Start of `'{ .. }` or `${ .. }`
716-
match: "['$][ \\t]*\\{(?!')",
717-
name: 'punctuation.section.block.begin.scala'
712+
{ // `'xyz`
713+
match: `(')((?>${plainid}))(?!')`,
714+
captures: {
715+
'1': {
716+
name: 'keyword.control.flow.staging.scala constant.other.symbol.scala'
717+
},
718+
'2': {
719+
name: 'constant.other.symbol.scala'
720+
}
721+
}
722+
},
723+
{ // Start of `'{ .. }`
724+
match: `'(?=\\s*\\{(?!'))`,
725+
name: 'keyword.control.flow.staging.scala'
718726
},
719727
{ // Start of `'[ .. ]`
720-
match: "'[ \\t]*\\[(?!')",
721-
name: 'meta.bracket.scala'
722-
}
728+
match: "'(?=\\s*\\[(?!'))",
729+
name: 'keyword.control.flow.staging.scala'
730+
},
731+
{ // Start of `${ .. }`
732+
match: "\\$(?=\\s*\\{)",
733+
name: 'keyword.control.flow.staging.scala'
734+
},
723735
]
724736
},
725737
'xml-doublequotedString': {
@@ -911,10 +923,6 @@ export const scalaTmLanguage: TmLanguage = {
911923
}
912924
}
913925
},
914-
'scala-symbol': {
915-
match: `(?>'${plainid})(?!')`,
916-
name: 'constant.other.symbol.scala'
917-
},
918926
'curly-braces': {
919927
begin: '\\{',
920928
end: '\\}',

syntaxes/Scala.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tests/snap/lexical.test.scala.snap

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,20 @@
378378
> ('x, 'X, 'αρετη, '=, '+ )
379379
#^^^^ source.scala
380380
# ^ source.scala meta.bracket.scala
381-
# ^^ source.scala constant.other.symbol.scala
381+
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
382+
# ^ source.scala constant.other.symbol.scala
382383
# ^^ source.scala
383-
# ^^ source.scala constant.other.symbol.scala
384+
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
385+
# ^ source.scala constant.other.symbol.scala
384386
# ^^ source.scala
385-
# ^^^^^^ source.scala constant.other.symbol.scala
387+
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
388+
# ^^^^^ source.scala constant.other.symbol.scala
386389
# ^^ source.scala
387-
# ^^ source.scala constant.other.symbol.scala
390+
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
391+
# ^ source.scala constant.other.symbol.scala
388392
# ^^ source.scala
389-
# ^^ source.scala constant.other.symbol.scala
393+
# ^ source.scala keyword.control.flow.staging.scala constant.other.symbol.scala
394+
# ^ source.scala constant.other.symbol.scala
390395
# ^ source.scala
391396
# ^ source.scala meta.bracket.scala
392397
>}

tests/unit/lexical.test.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ object ExampleIdentifiers {
2121
// ^^^^^^^^^^^^^ variable.stable.declaration.scala
2222
val __system = 3
2323
// ^^^^^^^^ variable.stable.declaration.scala
24+
2425
val _MAX_LEN_ = 3
2526
// ^^^^^^^^^ variable.stable.declaration.scala
2627
}

tests/unit/quoted.test.scala

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,50 @@
11
// SYNTAX TEST "source.scala"
22

3+
'x
4+
// ^ keyword.control.flow.staging.scala constant.other.symbol.scala
5+
// ^ constant.other.symbol.scala
36
'{ 2 }
4-
// ^^ punctuation.section.block.begin.scala
7+
// ^ keyword.control.flow.staging.scala
8+
// ^ punctuation.section.block.begin.scala
59
// ^ constant.numeric.scala
610
// ^ punctuation.section.block.end.scala
711

812
' { 2 }
9-
// ^^^^ punctuation.section.block.begin.scala
13+
// ^ keyword.control.flow.staging.scala
14+
// ^ punctuation.section.block.begin.scala
1015
// ^ constant.numeric.scala
1116
// ^ punctuation.section.block.end.scala
1217

18+
'
19+
// ^ punctuation.definition.character.begin.scala
20+
{ }
21+
1322
'[ String ]
14-
// ^^ meta.bracket.scala
23+
// ^ keyword.control.flow.staging.scala
24+
// ^ meta.bracket.scala
1525
// ^^^^^^ entity.name.class
1626
// ^ meta.bracket.scala
1727

1828
' [ String ]
19-
// ^^^ meta.bracket.scala
29+
// ^ keyword.control.flow.staging.scala
30+
// ^ meta.bracket.scala
2031
// ^^^^^^ entity.name.class
2132
// ^ meta.bracket.scala
2233

23-
2434
${ 1 }
25-
// ^^ punctuation.section.block.begin.scala
35+
// ^ keyword.control.flow.staging.scala
36+
// ^ punctuation.section.block.begin.scala
2637
// ^ constant.numeric.scala
2738
// ^ punctuation.section.block.end.scala
2839

2940
case '{ x } =>
3041
// ^^^^ keyword.control.flow.scala
31-
// ^^ punctuation.section.block.begin.scala
42+
// ^ keyword.control.flow.staging.scala
43+
// ^ punctuation.section.block.begin.scala
3244
// ^ punctuation.section.block.end.scala
3345

3446
case '[ T ] =>
3547
// ^^^^ keyword.control.flow.scala
36-
// ^^ meta.bracket.scala
48+
// ^ keyword.control.flow.staging.scala
49+
// ^ meta.bracket.scala
3750
// ^ meta.bracket.scala

0 commit comments

Comments
 (0)