Skip to content

Commit

Permalink
Merge pull request #161 from nicolasstucki/fix-#156
Browse files Browse the repository at this point in the history
Identify `extends`, `with` and `derives` at the end of a line
  • Loading branch information
nicolasstucki authored Dec 9, 2020
2 parents ed085b9 + 0080fe4 commit 712cea0
Show file tree
Hide file tree
Showing 2 changed files with 56 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 @@ -1017,7 +1017,7 @@ export const scalaTmLanguage: TmLanguage = {
inheritance: {
patterns: [
{
match: `(extends|with|derives)\\s+(${idUpper}|${backQuotedId}|(?=\\([^\\)]+=>)|(?=${plainid})|(?="))`,
match: `\\b(extends|with|derives)\\b\\s*(${idUpper}|${backQuotedId}|(?=\\([^\\)]+=>)|(?=${plainid})|(?="))?`,
captures: {
'1': {
name: 'keyword.declaration.scala'
Expand Down
55 changes: 55 additions & 0 deletions tests/unit/#156.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SYNTAX TEST "source.scala"


class Foo extends
// ^^^^^ keyword.declaration.scala
// ^^^ entity.name.class.declaration
// ^^^^^^^ keyword.declaration.scala

class Foo extends Bar with Baz
// ^^^^^ keyword.declaration.scala
// ^^^ entity.name.class.declaration
// ^^^^^^^ keyword.declaration.scala
// ^^^ entity.other.inherited-class.scala
// ^^^^ keyword.declaration.scala
// ^^^ entity.other.inherited-class.scala

class Foo extends Bar with
// ^^^^^ keyword.declaration.scala
// ^^^ entity.name.class.declaration
// ^^^^^^^ keyword.declaration.scala
// ^^^ entity.other.inherited-class.scala
// ^^^^ keyword.declaration.scala


given tc: TC with {}
// ^^^^^ keyword.declaration.scala
// ^^ variable.parameter.scala
// ^^ entity.name.class
// ^^^^ keyword.declaration.scala

given Liftable[Boolean] with {
// ^^^^^ keyword.declaration.scala
// ^^^^^^^^ entity.name.class
// ^^^^^^^ entity.name.class
// ^^^^ keyword.declaration.scala

given listMonad: Monad[List] with
// ^^^^^ keyword.declaration.scala
// ^^^^^^^^^ variable.parameter.scala
// ^^^^^ entity.name.class
// ^^^^ entity.name.class
// ^^^^ keyword.declaration.scala

enum Opt[+T] derives Eq {
// ^^^^ keyword.declaration.scala
// ^^^ entity.name.class.declaration
// ^ entity.name.class
// ^^^^^^^ keyword.declaration.scala
// ^^ entity.other.inherited-class.scala

enum Opt[+T] derives
// ^^^^ keyword.declaration.scala
// ^^^ entity.name.class.declaration
// ^ entity.name.class
// ^^^^^^^ keyword.declaration.scala

0 comments on commit 712cea0

Please sign in to comment.