Skip to content

Commit bb5e498

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 bb5e498

File tree

5 files changed

+49
-29
lines changed

5 files changed

+49
-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: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
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
58
// ^ constant.numeric.scala
69
// ^ punctuation.section.block.end.scala
710

811
' { 2 }
9-
// ^^^^ punctuation.section.block.begin.scala
12+
// ^ keyword.control.flow.staging.scala
1013
// ^ constant.numeric.scala
1114
// ^ punctuation.section.block.end.scala
1215

16+
'
17+
// ^ punctuation.definition.character.begin.scala
18+
{ }
19+
1320
'[ String ]
14-
// ^^ meta.bracket.scala
21+
// ^ keyword.control.flow.staging.scala
1522
// ^^^^^^ entity.name.class
1623
// ^ meta.bracket.scala
1724

1825
' [ String ]
19-
// ^^^ meta.bracket.scala
26+
// ^ keyword.control.flow.staging.scala
2027
// ^^^^^^ entity.name.class
2128
// ^ meta.bracket.scala
2229

23-
2430
${ 1 }
25-
// ^^ punctuation.section.block.begin.scala
31+
// ^ keyword.control.flow.staging.scala
2632
// ^ constant.numeric.scala
2733
// ^ punctuation.section.block.end.scala
2834

2935
case '{ x } =>
3036
// ^^^^ keyword.control.flow.scala
31-
// ^^ punctuation.section.block.begin.scala
37+
// ^ keyword.control.flow.staging.scala
3238
// ^ punctuation.section.block.end.scala
3339

3440
case '[ T ] =>
3541
// ^^^^ keyword.control.flow.scala
36-
// ^^ meta.bracket.scala
42+
// ^ keyword.control.flow.staging.scala
3743
// ^ meta.bracket.scala

0 commit comments

Comments
 (0)