Skip to content

Commit

Permalink
Merge pull request #168 from camilaagw/Fix-155-highlight-all-soft-mod…
Browse files Browse the repository at this point in the history
…ifiers

Highlight all soft modifiers
  • Loading branch information
MaximeKjaer authored Dec 11, 2020
2 parents eb1692e + 5885a19 commit c4c054f
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 15 deletions.
24 changes: 10 additions & 14 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,21 +578,13 @@ export const scalaTmLanguage: TmLanguage = {
},
inline: {
patterns: [
{
match: `\\b(inline)\\s+(?=(([\\w\\s]*\\b(val|def|given)\\b)|(${plainid}|${backQuotedId})\\s*:))`,
captures: {
'1': {
name: 'storage.modifier.other'
}
}
{ // inline parameters
match: `\\b(inline)(?=\\s+(${plainid}|${backQuotedId})\\s*:)`,
name: 'storage.modifier.other'
},
{
match: `\\b(inline)\\b(?=(?:.(?!\\b(?:val|def|given)\\b))*\\b(if|match)\\b)`,
captures: {
'1': {
name: 'keyword.control.flow.scala'
}
}
name: 'keyword.control.flow.scala'
}
]
},
Expand Down Expand Up @@ -645,7 +637,7 @@ export const scalaTmLanguage: TmLanguage = {
}
},
{
match: `\\b(?:(case|open)\\s+)?(class|object|enum)\\s+([^\\s\\{\\(\\[;]+)(?<![^${opchar}]:)`,
match: `\\b(?:(case)\\s+)?(class|object|enum)\\s+([^\\s\\{\\(\\[;]+)(?<![^${opchar}]:)`,
captures: {
'1': {
name: 'keyword.declaration.scala'
Expand Down Expand Up @@ -840,7 +832,11 @@ export const scalaTmLanguage: TmLanguage = {
name: 'storage.modifier.access'
},
{
match: '\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|opaque |override|@transient|@native)\\b',
match: '\\b(synchronized|@volatile|abstract|final|lazy|sealed|implicit|override|@transient|@native)\\b',
name: 'storage.modifier.other'
},
{
match: '(?<=^|\\s)\\b(transparent|opaque|infix|open|inline)\\b(?=[a-z\\s]*\\b(def|val|var|given|type|class|trait|object|enum)\\b)',
name: 'storage.modifier.other'
}
]
Expand Down
71 changes: 71 additions & 0 deletions tests/unit/#155.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// SYNTAX TEST "source.scala"

transparent inline def foo
// ^^^^^^^^^^^ storage.modifier.other
// ^^^^^^ storage.modifier.other

transparent inline xdef foo
// ^^^^^^^^^^^ - storage.modifier.other
// ^^^^^^ - storage.modifier.other

transparent inline defx foo
// ^^^^^^^^^^^ - storage.modifier.other
// ^^^^^^ - storage.modifier.other

transparent inline final def assert
// ^^^^^^^^^^^ storage.modifier.other
// ^^^^^^ storage.modifier.other

transparent badkeyword inline override def alternative
// ^^^^^^^^^^^ storage.modifier.other
// ^^^^^^ storage.modifier.other

transparent trait Enum extends Any with Product with Serializable
// ^^^^^^^^^^^ storage.modifier.other

opaque type Logarithm = Double
// ^^^^^^ storage.modifier.other

opaque private type Matching = Option[Tuple]
// ^^^^^^ storage.modifier.other

infix def + (that: Rational) =
// ^^^^^ storage.modifier.other

infix type +[X <: Int | String, Y <: Int | String] = (X, Y) match
// ^^^^^ storage.modifier.other

open class Open
// ^^^^ storage.modifier.other

open final class Foo1
// ^^^^ storage.modifier.other

open final class Foo1
// <---- storage.modifier.other

@inline def
// ^^^^^^ - storage.modifier.other

@infix def
// ^^^^^ - storage.modifier.other

@transparent def
// ^^^^^^^^^^^ - storage.modifier.other

@opaque def
// ^^^^^^ - storage.modifier.other

@open def
// ^^^^ - storage.modifier.other

@scala.inline def
// ^^^^^^ - storage.modifier.other

@infix inline def
// ^^^^^ - storage.modifier.other
// ^^^^^^ storage.modifier.other

file.open()
// ^^^^ - storage.modifier.other

2 changes: 1 addition & 1 deletion tests/unit/#91.test.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SYNTAX TEST "source.scala"

open class A
// ^^^^ keyword.declaration.scala
// ^^^^ storage.modifier.other
// ^^^^^ keyword.declaration.scala
// ^ entity.name.class.declaration

0 comments on commit c4c054f

Please sign in to comment.