Skip to content

Commit 2f0a8b2

Browse files
Merge pull request #97 from nicolasstucki/fix-#69
Fix #69: Do not use type definitions to highlight `.type`
2 parents d5792f9 + 3400412 commit 2f0a8b2

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
@@ -177,6 +177,9 @@ export const scalaTmLanguage: TmLanguage = {
177177
{
178178
include: '#scala-symbol'
179179
},
180+
{
181+
include: '#singleton-type'
182+
},
180183
{
181184
include: '#scala-quoted'
182185
},
@@ -434,6 +437,14 @@ export const scalaTmLanguage: TmLanguage = {
434437
}
435438
]
436439
},
440+
'singleton-type': {
441+
match: `\\.(type)(?!${idrest}|[0-9])`,
442+
captures: {
443+
'1': {
444+
name: 'keyword.type.scala'
445+
}
446+
}
447+
},
437448
'scala-quoted': {
438449
match: "('\\{|'\\[)(?!')",
439450
name: 'constant.other.quoted.scala'
@@ -497,7 +508,7 @@ export const scalaTmLanguage: TmLanguage = {
497508
}
498509
},
499510
{
500-
match: `\\b(type)\\s+(${backQuotedId}|${plainid})`,
511+
match: `(?<!\\.)\\b(type)\\s+(${backQuotedId}|${plainid})`,
501512
captures: {
502513
'1': {
503514
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)