Skip to content

Commit

Permalink
Fix #119: Detect when using is an identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jul 8, 2020
1 parent 5b19916 commit 373c3ff
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ export const scalaTmLanguage: TmLanguage = {
'using': {
patterns: [
{
match: `\\(\\s*(using)`,
match: `(?<=\\()\\s*(using)\\s+(?=[\\w\\d\\(\\.\\(\\{'"])`,
captures: {
'1': {
name: 'keyword.declaration.scala'
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/#119.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SYNTAX TEST "source.scala"

(using)
// ^ meta.bracket.scala
// ^^^^^ source.scala
// ^ meta.bracket.scala

(using )
// ^ meta.bracket.scala
// ^^^^^^^ source.scala
// ^ meta.bracket.scala

(using , )
// ^ meta.bracket.scala
// ^^^^^^^^ source.scala
// ^ meta.bracket.scala

(usingSomething)
// ^ meta.bracket.scala
// ^^^^^^^^^^^^^^ source.scala
// ^ meta.bracket.scala
21 changes: 21 additions & 0 deletions tests/unit/using.test.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ def f(using x: Int): Unit = ()
// ^^^^^ keyword.declaration.scala
// ^ constant.numeric.scala

f(using .2)
// ^^^^^ keyword.declaration.scala
// ^ constant.numeric.scala

class A(using x: Int)
// ^^^^^ keyword.declaration.scala

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

given [T](using Ord[T]) as Ord[List[T]]
// ^^^^^ keyword.declaration.scala

f(using ())
// ^^^^^ keyword.declaration.scala
// ^^ meta.parentheses.scala meta.bracket.scala

f(using {})
// ^^^^^ keyword.declaration.scala
// ^ punctuation.section.block.begin.scala
// ^ punctuation.section.block.end.scala

f(using ' ')
// ^^^^^ keyword.declaration.scala
// ^^^ constant.character.literal.scala

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

0 comments on commit 373c3ff

Please sign in to comment.