Skip to content

Commit c4c054f

Browse files
authored
Merge pull request #168 from camilaagw/Fix-155-highlight-all-soft-modifiers
Highlight all soft modifiers
2 parents eb1692e + 5885a19 commit c4c054f

File tree

3 files changed

+82
-15
lines changed

3 files changed

+82
-15
lines changed

src/typescript/Scala.tmLanguage.ts

+10-14
Original file line numberDiff line numberDiff line change
@@ -578,21 +578,13 @@ export const scalaTmLanguage: TmLanguage = {
578578
},
579579
inline: {
580580
patterns: [
581-
{
582-
match: `\\b(inline)\\s+(?=(([\\w\\s]*\\b(val|def|given)\\b)|(${plainid}|${backQuotedId})\\s*:))`,
583-
captures: {
584-
'1': {
585-
name: 'storage.modifier.other'
586-
}
587-
}
581+
{ // inline parameters
582+
match: `\\b(inline)(?=\\s+(${plainid}|${backQuotedId})\\s*:)`,
583+
name: 'storage.modifier.other'
588584
},
589585
{
590586
match: `\\b(inline)\\b(?=(?:.(?!\\b(?:val|def|given)\\b))*\\b(if|match)\\b)`,
591-
captures: {
592-
'1': {
593-
name: 'keyword.control.flow.scala'
594-
}
595-
}
587+
name: 'keyword.control.flow.scala'
596588
}
597589
]
598590
},
@@ -645,7 +637,7 @@ export const scalaTmLanguage: TmLanguage = {
645637
}
646638
},
647639
{
648-
match: `\\b(?:(case|open)\\s+)?(class|object|enum)\\s+([^\\s\\{\\(\\[;]+)(?<![^${opchar}]:)`,
640+
match: `\\b(?:(case)\\s+)?(class|object|enum)\\s+([^\\s\\{\\(\\[;]+)(?<![^${opchar}]:)`,
649641
captures: {
650642
'1': {
651643
name: 'keyword.declaration.scala'
@@ -840,7 +832,11 @@ export const scalaTmLanguage: TmLanguage = {
840832
name: 'storage.modifier.access'
841833
},
842834
{
843-
match: '\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|opaque |override|@transient|@native)\\b',
835+
match: '\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|override|@transient|@native)\\b',
836+
name: 'storage.modifier.other'
837+
},
838+
{
839+
match: '(?<=^|\\s)\\b(transparent|opaque|infix|open|inline)\\b(?=[a-z\\s]*\\b(def|val|var|given|type|class|trait|object|enum)\\b)',
844840
name: 'storage.modifier.other'
845841
}
846842
]

tests/unit/#155.test.scala

+71
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

+1-1
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)