Skip to content

Commit 78750ed

Browse files
Merge pull request #250 from nicolasstucki/fix-quoted-with-spaces-2
Fix quoted with spaces
2 parents 4a3fb2d + cd24dc8 commit 78750ed

File tree

5 files changed

+63
-26
lines changed

5 files changed

+63
-26
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: "['$]\\{(?!')",
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: "'\\[(?!')",
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: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +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

12+
' { 2 }
13+
// ^ keyword.control.flow.staging.scala
14+
// ^ punctuation.section.block.begin.scala
15+
// ^ constant.numeric.scala
16+
// ^ punctuation.section.block.end.scala
17+
18+
'
19+
// ^ punctuation.definition.character.begin.scala
20+
{ }
21+
822
'[ String ]
9-
// ^^ meta.bracket.scala
23+
// ^ keyword.control.flow.staging.scala
24+
// ^ meta.bracket.scala
1025
// ^^^^^^ entity.name.class
1126
// ^ meta.bracket.scala
1227

28+
' [ String ]
29+
// ^ keyword.control.flow.staging.scala
30+
// ^ meta.bracket.scala
31+
// ^^^^^^ entity.name.class
32+
// ^ meta.bracket.scala
1333

1434
${ 1 }
15-
// ^^ punctuation.section.block.begin.scala
35+
// ^ keyword.control.flow.staging.scala
36+
// ^ punctuation.section.block.begin.scala
1637
// ^ constant.numeric.scala
1738
// ^ punctuation.section.block.end.scala
1839

1940
case '{ x } =>
2041
// ^^^^ keyword.control.flow.scala
21-
// ^^ punctuation.section.block.begin.scala
42+
// ^ keyword.control.flow.staging.scala
43+
// ^ punctuation.section.block.begin.scala
2244
// ^ punctuation.section.block.end.scala
2345

2446
case '[ T ] =>
2547
// ^^^^ keyword.control.flow.scala
26-
// ^^ meta.bracket.scala
48+
// ^ keyword.control.flow.staging.scala
49+
// ^ meta.bracket.scala
2750
// ^ meta.bracket.scala

0 commit comments

Comments
 (0)