Skip to content

Commit

Permalink
Support extension on
Browse files Browse the repository at this point in the history
```
extension on ...
extension <ident> on ...
extension { ...
extension <ident> { ...
```
  • Loading branch information
nicolasstucki committed Jun 29, 2020
1 parent 0690707 commit 2d32992
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,13 +864,26 @@ export const scalaTmLanguage: TmLanguage = {
},
extension: {
patterns: [
{
match: `(extension)\\s+(?:(${plainid})\\s)?\\s*(on|(?=\\{))`,
captures: {
'1': {
name: 'keyword.declaration.scala'
},
'2': {
name: 'entity.name.class'
},
'3': {
name: 'keyword.declaration.scala'
}
}
},
{
match: `(extension)\\s+(?=[\\[\\(])`,
captures: {
'1': {
name: 'keyword.declaration.scala'
},

}
}
]
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/extension-on.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SYNTAX TEST "source.scala"

extension on (x: Rational):
// ^^^^^^^^^ keyword.declaration.scala
// ^^ keyword.declaration.scala
// ^ variable.parameter.scala
// ^^^^^^^^ entity.name.class
def > (y: Rational): Boolean = y < x

extension Ops on (x: Rational):
// ^^^^^^^^^ keyword.declaration.scala
// ^^^ entity.name.class
// ^^ keyword.declaration.scala
// ^ variable.parameter.scala
// ^^^^^^^^ entity.name.class
def > (y: Rational): Boolean = y < x

extension stringOps { }
// ^^^^^^^^^ keyword.declaration.scala
// ^^^^^^^^^ entity.name.class

extension { }
// ^^^^^^^^^ keyword.declaration.scala

0 comments on commit 2d32992

Please sign in to comment.