Skip to content

Commit

Permalink
Add top level rule for identifiers inside the backticks
Browse files Browse the repository at this point in the history
  • Loading branch information
PanAeon committed Jun 25, 2019
1 parent 07c397d commit f50e487
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/typescript/Scala.tmLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ export const scalaTmLanguage: TmLanguage = {
{
include: '#qualifiedClassName'
},
{
include: '#backQuotedVariable'
},
{
include: '#meta-brackets'
},
Expand Down Expand Up @@ -624,6 +627,12 @@ export const scalaTmLanguage: TmLanguage = {
}
}
},
backQuotedVariable: {
// capture back quoted variables in code so special symbols inside them do not
// interfere with the rest of the rules. But don't assign any extra scope, to make them
// consistent with the rest of variables
match: `${backQuotedId}`
},
'storage-modifiers': {
patterns: [
{
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/Scala.tmLanguage.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions tests/snap/backticks.test.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

object `Backtics test` {
val x = MediaRange.`*/*`

val y = `MediaRange`.`*/*`

val z = `Media Range`

def `*/*`(`a b`: `C D`): `e f` = ???



val `*/*` = 5
}
74 changes: 74 additions & 0 deletions tests/snap/backticks.test.scala.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
>
>object `Backtics test` {
#^^^^^^ source.scala keyword.declaration.scala
# ^ source.scala
# ^^^^^^^^^ source.scala entity.name.class.declaration
# ^^^^^^^ source.scala
# ^ source.scala punctuation.section.block.begin.scala
> val x = MediaRange.`*/*`
#^^^^ source.scala
# ^^^ source.scala keyword.declaration.stable.scala
# ^ source.scala
# ^ source.scala variable.other.declaration.scala
# ^ source.scala
# ^ source.scala keyword.operator.comparison.scala
# ^ source.scala
# ^^^^^^^^^^ source.scala entity.name.class
# ^ source.scala
# ^^^^^ source.scala
>
> val y = `MediaRange`.`*/*`
#^^^^ source.scala
# ^^^ source.scala keyword.declaration.stable.scala
# ^ source.scala
# ^ source.scala variable.other.declaration.scala
# ^ source.scala
# ^ source.scala keyword.operator.comparison.scala
# ^ source.scala
# ^^^^^^^^^^^^ source.scala
# ^ source.scala
# ^^^^^ source.scala
>
> val z = `Media Range`
#^^^^ source.scala
# ^^^ source.scala keyword.declaration.stable.scala
# ^ source.scala
# ^ source.scala variable.other.declaration.scala
# ^ source.scala
# ^ source.scala keyword.operator.comparison.scala
# ^ source.scala
# ^^^^^^^^^^^^^ source.scala
>
> def `*/*`(`a b`: `C D`): `e f` = ???
#^^^^ source.scala
# ^^^ source.scala keyword.declaration.scala
# ^ source.scala
# ^^^^^ source.scala entity.name.function.declaration
# ^ source.scala meta.bracket.scala
# ^^^^^ source.scala variable.parameter.scala
# ^ source.scala meta.colon.scala
# ^ source.scala
# ^^^^^ source.scala
# ^ source.scala meta.bracket.scala
# ^ source.scala keyword.operator.scala
# ^ source.scala
# ^^^^^ source.scala
# ^ source.scala
# ^ source.scala keyword.operator.comparison.scala
# ^ source.scala
# ^^^ source.scala keyword.operator.scala
>
>
>
> val `*/*` = 5
#^^^^ source.scala
# ^^^ source.scala keyword.declaration.stable.scala
# ^ source.scala
# ^^^^^ source.scala variable.other.declaration.scala
# ^ source.scala
# ^ source.scala keyword.operator.comparison.scala
# ^ source.scala
# ^ source.scala constant.numeric.scala
> }
#^ source.scala
# ^ source.scala punctuation.section.block.end.scala
4 changes: 3 additions & 1 deletion tests/snap/scala_spec.test.scala.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,9 @@
> case `y` =>
#^^^^^^^^ source.scala
# ^^^^ source.scala keyword.control.flow.scala
# ^^^^^ source.scala
# ^ source.scala
# ^^^ source.scala
# ^ source.scala
# ^ source.scala keyword.operator.comparison.scala
# ^ source.scala keyword.operator.comparison.scala
# ^^ source.scala
Expand Down

0 comments on commit f50e487

Please sign in to comment.