Skip to content

Commit 3400412

Browse files
committed
Fix #69: Do not use type definitions to highlight .type
1 parent 6c995f9 commit 3400412

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@ export const scalaTmLanguage: TmLanguage = {
174174
{
175175
include: '#scala-symbol'
176176
},
177+
{
178+
include: '#singleton-type'
179+
},
177180
{
178181
include: '#scala-quoted'
179182
},
@@ -431,6 +434,14 @@ export const scalaTmLanguage: TmLanguage = {
431434
}
432435
]
433436
},
437+
'singleton-type': {
438+
match: `\\.(type)(?!${idrest}|[0-9])`,
439+
captures: {
440+
'1': {
441+
name: 'keyword.type.scala'
442+
}
443+
}
444+
},
434445
'scala-quoted': {
435446
match: "('\\{|'\\[)(?!')",
436447
name: 'constant.other.quoted.scala'
@@ -494,7 +505,7 @@ export const scalaTmLanguage: TmLanguage = {
494505
}
495506
},
496507
{
497-
match: `\\b(type)\\s+(${backQuotedId}|${plainid})`,
508+
match: `(?<!\\.)\\b(type)\\s+(${backQuotedId}|${plainid})`,
498509
captures: {
499510
'1': {
500511
name: 'keyword.declaration.scala'

tests/unit/#69.test.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SYNTAX TEST "source.scala"
2+
3+
val x = ???
4+
trait Foo[T <: x.type]
5+
// ^^^^ keyword.type.scala
6+
7+
val a: x.type = ???
8+
// ^^^^ keyword.type.scala
9+
10+
val b: Foo[x.type] = ???
11+
// ^^^^ keyword.type.scala

0 commit comments

Comments
 (0)