Skip to content

Commit 5885a19

Browse files
committed
Highlight all soft modifiers
1 parent 933611f commit 5885a19

File tree

3 files changed

+82
-15
lines changed

3 files changed

+82
-15
lines changed

src/typescript/Scala.tmLanguage.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -584,21 +584,13 @@ export const scalaTmLanguage: TmLanguage = {
584584
},
585585
inline: {
586586
patterns: [
587-
{
588-
match: `\\b(inline)\\s+(?=(([\\w\\s]*\\b(val|def|given)\\b)|(${plainid}|${backQuotedId})\\s*:))`,
589-
captures: {
590-
'1': {
591-
name: 'storage.modifier.other'
592-
}
593-
}
587+
{ // inline parameters
588+
match: `\\b(inline)(?=\\s+(${plainid}|${backQuotedId})\\s*:)`,
589+
name: 'storage.modifier.other'
594590
},
595591
{
596592
match: `\\b(inline)\\b(?=(?:.(?!\\b(?:val|def|given)\\b))*\\b(if|match)\\b)`,
597-
captures: {
598-
'1': {
599-
name: 'keyword.control.flow.scala'
600-
}
601-
}
593+
name: 'keyword.control.flow.scala'
602594
}
603595
]
604596
},
@@ -651,7 +643,7 @@ export const scalaTmLanguage: TmLanguage = {
651643
}
652644
},
653645
{
654-
match: `\\b(?:(case|open)\\s+)?(class|object|enum)\\s+([^\\s\\{\\(\\[;]+)(?<![^${opchar}]:)`,
646+
match: `\\b(?:(case)\\s+)?(class|object|enum)\\s+([^\\s\\{\\(\\[;]+)(?<![^${opchar}]:)`,
655647
captures: {
656648
'1': {
657649
name: 'keyword.declaration.scala'
@@ -846,7 +838,11 @@ export const scalaTmLanguage: TmLanguage = {
846838
name: 'storage.modifier.access'
847839
},
848840
{
849-
match: '\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|opaque |override|@transient|@native)\\b',
841+
match: '\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|override|@transient|@native)\\b',
842+
name: 'storage.modifier.other'
843+
},
844+
{
845+
match: '(?<=^|\\s)\\b(transparent|opaque|infix|open|inline)\\b(?=[a-z\\s]*\\b(def|val|var|given|type|class|trait|object|enum)\\b)',
850846
name: 'storage.modifier.other'
851847
}
852848
]

tests/unit/#155.test.scala

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// SYNTAX TEST "source.scala"
2+
3+
transparent inline def foo
4+
// ^^^^^^^^^^^ storage.modifier.other
5+
// ^^^^^^ storage.modifier.other
6+
7+
transparent inline xdef foo
8+
// ^^^^^^^^^^^ - storage.modifier.other
9+
// ^^^^^^ - storage.modifier.other
10+
11+
transparent inline defx foo
12+
// ^^^^^^^^^^^ - storage.modifier.other
13+
// ^^^^^^ - storage.modifier.other
14+
15+
transparent inline final def assert
16+
// ^^^^^^^^^^^ storage.modifier.other
17+
// ^^^^^^ storage.modifier.other
18+
19+
transparent badkeyword inline override def alternative
20+
// ^^^^^^^^^^^ storage.modifier.other
21+
// ^^^^^^ storage.modifier.other
22+
23+
transparent trait Enum extends Any with Product with Serializable
24+
// ^^^^^^^^^^^ storage.modifier.other
25+
26+
opaque type Logarithm = Double
27+
// ^^^^^^ storage.modifier.other
28+
29+
opaque private type Matching = Option[Tuple]
30+
// ^^^^^^ storage.modifier.other
31+
32+
infix def + (that: Rational) =
33+
// ^^^^^ storage.modifier.other
34+
35+
infix type +[X <: Int | String, Y <: Int | String] = (X, Y) match
36+
// ^^^^^ storage.modifier.other
37+
38+
open class Open
39+
// ^^^^ storage.modifier.other
40+
41+
open final class Foo1
42+
// ^^^^ storage.modifier.other
43+
44+
open final class Foo1
45+
// <---- storage.modifier.other
46+
47+
@inline def
48+
// ^^^^^^ - storage.modifier.other
49+
50+
@infix def
51+
// ^^^^^ - storage.modifier.other
52+
53+
@transparent def
54+
// ^^^^^^^^^^^ - storage.modifier.other
55+
56+
@opaque def
57+
// ^^^^^^ - storage.modifier.other
58+
59+
@open def
60+
// ^^^^ - storage.modifier.other
61+
62+
@scala.inline def
63+
// ^^^^^^ - storage.modifier.other
64+
65+
@infix inline def
66+
// ^^^^^ - storage.modifier.other
67+
// ^^^^^^ storage.modifier.other
68+
69+
file.open()
70+
// ^^^^ - storage.modifier.other
71+

tests/unit/#91.test.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SYNTAX TEST "source.scala"
22

33
open class A
4-
// ^^^^ keyword.declaration.scala
4+
// ^^^^ storage.modifier.other
55
// ^^^^^ keyword.declaration.scala
66
// ^ entity.name.class.declaration

0 commit comments

Comments
 (0)