Skip to content

Commit

Permalink
Fix #69: Do not use type definitions to highlight .type
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Jun 29, 2020
1 parent 6c995f9 commit 3400412
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ export const scalaTmLanguage: TmLanguage = {
{
include: '#scala-symbol'
},
{
include: '#singleton-type'
},
{
include: '#scala-quoted'
},
Expand Down Expand Up @@ -431,6 +434,14 @@ export const scalaTmLanguage: TmLanguage = {
}
]
},
'singleton-type': {
match: `\\.(type)(?!${idrest}|[0-9])`,
captures: {
'1': {
name: 'keyword.type.scala'
}
}
},
'scala-quoted': {
match: "('\\{|'\\[)(?!')",
name: 'constant.other.quoted.scala'
Expand Down Expand Up @@ -494,7 +505,7 @@ export const scalaTmLanguage: TmLanguage = {
}
},
{
match: `\\b(type)\\s+(${backQuotedId}|${plainid})`,
match: `(?<!\\.)\\b(type)\\s+(${backQuotedId}|${plainid})`,
captures: {
'1': {
name: 'keyword.declaration.scala'
Expand Down
11 changes: 11 additions & 0 deletions tests/unit/#69.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SYNTAX TEST "source.scala"

val x = ???
trait Foo[T <: x.type]
// ^^^^ keyword.type.scala

val a: x.type = ???
// ^^^^ keyword.type.scala

val b: Foo[x.type] = ???
// ^^^^ keyword.type.scala

0 comments on commit 3400412

Please sign in to comment.