Skip to content

Commit a949985

Browse files
authored
Merge pull request #120 from nicolasstucki/fix-#119
Fix #119: Detect when `using` is an identifier
2 parents 4a95953 + 373c3ff commit a949985

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export const scalaTmLanguage: TmLanguage = {
404404
'using': {
405405
patterns: [
406406
{
407-
match: `\\(\\s*(using)`,
407+
match: `(?<=\\()\\s*(using)\\s+(?=[\\w\\d\\(\\.\\(\\{'"])`,
408408
captures: {
409409
'1': {
410410
name: 'keyword.declaration.scala'

tests/unit/#119.test.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SYNTAX TEST "source.scala"
2+
3+
(using)
4+
// ^ meta.bracket.scala
5+
// ^^^^^ source.scala
6+
// ^ meta.bracket.scala
7+
8+
(using )
9+
// ^ meta.bracket.scala
10+
// ^^^^^^^ source.scala
11+
// ^ meta.bracket.scala
12+
13+
(using , )
14+
// ^ meta.bracket.scala
15+
// ^^^^^^^^ source.scala
16+
// ^ meta.bracket.scala
17+
18+
(usingSomething)
19+
// ^ meta.bracket.scala
20+
// ^^^^^^^^^^^^^^ source.scala
21+
// ^ meta.bracket.scala

tests/unit/using.test.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ def f(using x: Int): Unit = ()
77
// ^^^^^ keyword.declaration.scala
88
// ^ constant.numeric.scala
99

10+
f(using .2)
11+
// ^^^^^ keyword.declaration.scala
12+
// ^ constant.numeric.scala
13+
1014
class A(using x: Int)
1115
// ^^^^^ keyword.declaration.scala
1216

@@ -21,3 +25,20 @@ given [T](using x: Ord[T], using: Int) as Ord[List[T]]
2125

2226
given [T](using Ord[T]) as Ord[List[T]]
2327
// ^^^^^ keyword.declaration.scala
28+
29+
f(using ())
30+
// ^^^^^ keyword.declaration.scala
31+
// ^^ meta.parentheses.scala meta.bracket.scala
32+
33+
f(using {})
34+
// ^^^^^ keyword.declaration.scala
35+
// ^ punctuation.section.block.begin.scala
36+
// ^ punctuation.section.block.end.scala
37+
38+
f(using ' ')
39+
// ^^^^^ keyword.declaration.scala
40+
// ^^^ constant.character.literal.scala
41+
42+
f(using "")
43+
// ^^^^^ keyword.declaration.scala
44+
// ^^ string.quoted.double.scala

0 commit comments

Comments
 (0)