Skip to content

Commit 5b3c402

Browse files
committed
Fix #139: Add given as a possible inline definition
1 parent 2dd5afd commit 5b3c402

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,18 +577,18 @@ export const scalaTmLanguage: TmLanguage = {
577577
inline: {
578578
patterns: [
579579
{
580-
match: `\\b(inline)\\b(?=(\\s+(?:${plainid}|${backQuotedId})\\s*:)|(.*(val|def)))`,
580+
match: `\\b(inline)\\b(?=(?:.(?!val|def|given))*(if|match))`,
581581
captures: {
582582
'1': {
583-
name: 'storage.modifier.other'
583+
name: 'keyword.control.flow.scala'
584584
}
585585
}
586586
},
587587
{
588-
match: `\\b(inline)\\b(?=.*(if|match))`,
588+
match: `\\b(inline)\\s+(?=(([\\w\\s]*(val|def|given))|(${plainid}|${backQuotedId})\\s*:))`,
589589
captures: {
590590
'1': {
591-
name: 'keyword.control.flow.scala'
591+
name: 'storage.modifier.other'
592592
}
593593
}
594594
}

tests/unit/#133.test.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@ val x = inline[T]
3939
// ^^^^^^ entity.name.function.declaration
4040
// ^^^^^^ storage.modifier.other
4141
// ^^^^^^ variable.parameter.scala
42+
43+
inline if (n == 0) 1 else 2; val x = 2
44+
// ^^^^^^ keyword.control.flow.scala
45+
// ^^ keyword.control.flow.scala
46+
47+
inline if (n == 0) 1 else 2; def x = 2
48+
// ^^^^^^ keyword.control.flow.scala
49+
// ^^ keyword.control.flow.scala
50+
51+
inline f[X](x: X) match {
52+
// ^^^^^^ keyword.control.flow.scala
53+
// ^^^^^ keyword.control.flow.scala

tests/unit/#139.test.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SYNTAX TEST "source.scala"
2+
3+
4+
inline def mkDefaultTypeable[T]: Typeable[T] = ${ TypeableMacros.impl[T] }
5+
// ^^^^^^ storage.modifier.other
6+
// ^^^ keyword.declaration.scala
7+
8+
inline given [T] as Typeable[T] = mkDefaultTypeable[T]
9+
// ^^^^^^ storage.modifier.other
10+
// ^^^^^ keyword.declaration.scala

0 commit comments

Comments
 (0)