Skip to content

Commit e5feeaa

Browse files
authored
Merge pull request #150 from nicolasstucki/fix-#133-2
Prioritize matching of inline parameters
2 parents d7aa171 + e0c824a commit e5feeaa

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-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(?=(?:.(?!\\b(?:val|def|given)\\b))*\\b(if|match)\\b)`,
580+
match: `\\b(inline)\\s+(?=(([\\w\\s]*\\b(val|def|given)\\b)|(${plainid}|${backQuotedId})\\s*:))`,
581581
captures: {
582582
'1': {
583-
name: 'keyword.control.flow.scala'
583+
name: 'storage.modifier.other'
584584
}
585585
}
586586
},
587587
{
588-
match: `\\b(inline)\\s+(?=(([\\w\\s]*\\b(val|def|given)\\b)|(${plainid}|${backQuotedId})\\s*:))`,
588+
match: `\\b(inline)\\b(?=(?:.(?!\\b(?:val|def|given)\\b))*\\b(if|match)\\b)`,
589589
captures: {
590590
'1': {
591-
name: 'storage.modifier.other'
591+
name: 'keyword.control.flow.scala'
592592
}
593593
}
594594
}

tests/unit/#133.test.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ val x = inline[T]
7171
// ^^^^^^ storage.modifier.other
7272
// ^^^^^^ variable.parameter.scala
7373

74+
inline def inline(inline x: Int): Double = if
75+
// ^^^^^^ storage.modifier.other
76+
// ^^^^^^ entity.name.function.declaration
77+
// ^^^^^^ storage.modifier.other
78+
// ^ variable.parameter.scala
79+
7480
inline if (n == 0) 1 else 2; val x = 2
7581
// ^^^^^^ keyword.control.flow.scala
7682
// ^^ keyword.control.flow.scala

0 commit comments

Comments
 (0)