Skip to content

Commit

Permalink
Simplify 'using' regex
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jan 18, 2021
1 parent e1277fd commit f8dcd02
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export const scalaTmLanguage: TmLanguage = {
'using': {
patterns: [
{
match: `(?<=\\()\\s*(using)\\s+(?=[\\w\\d\\(\\.\\(\\{'"$])`,
match: `(?<=\\()\\s*(using)\\s`,
captures: {
'1': {
name: 'keyword.declaration.scala'
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/#180.test.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
// SYNTAX TEST "source.scala"

case '{ Array[T]()(using $ct) =>
case '{ Array[T]()(using $ct) } =>
// ^^^^^ keyword.declaration.scala

case '{ Array[T]()(using ($ct: ClassTag[T])) } =>
// ^^^^^ keyword.declaration.scala
18 changes: 17 additions & 1 deletion tests/unit/using.test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,20 @@ given [T](using Ord[T]) as Ord[List[T]]

f(using "")
// ^^^^^ keyword.declaration.scala
// ^^ string.quoted.double.scala
// ^^ string.quoted.double.scala

val using = ...
// ^^^^^ - keyword.declaration.scala
val using: X = ...
// ^^^^^ - keyword.declaration.scala
def using() = ...
// ^^^^^ - keyword.declaration.scala

using(foo)
// ^^^^^ - keyword.declaration.scala
bar(using(foo))
// ^^^^^ - keyword.declaration.scala
bar(using.apply(foo))
// ^^^^^ - keyword.declaration.scala
using.apply(foo)
// ^^^^^ - keyword.declaration.scala

0 comments on commit f8dcd02

Please sign in to comment.