From 71146853e9e267d21360adab58f433551e1d137f Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 3 Sep 2021 16:29:50 +0200 Subject: [PATCH] Add missing Scala 3 keywords Add `then` and `do` as keywords. These keywords are also keywords in Scala 2. `then` was reserved but not used as a keyword. `do` was part of `do .. while` keyword combination. See https://github.com/scala/vscode-scala-syntax/blob/57e0829cd46980699570101a68c320a20330d36c/src/typescript/Scala.tmLanguage.ts#L595 --- CHANGES.md | 2 ++ src/languages/scala.js | 2 +- test/markup/scala/for-do.expect.txt | 1 + test/markup/scala/for-do.txt | 1 + test/markup/scala/if-then-else.expect.txt | 1 + test/markup/scala/if-then-else.txt | 1 + test/markup/scala/while-do.expect.txt | 1 + test/markup/scala/while-do.txt | 1 + 8 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/markup/scala/for-do.expect.txt create mode 100644 test/markup/scala/for-do.txt create mode 100644 test/markup/scala/if-then-else.expect.txt create mode 100644 test/markup/scala/if-then-else.txt create mode 100644 test/markup/scala/while-do.expect.txt create mode 100644 test/markup/scala/while-do.txt diff --git a/CHANGES.md b/CHANGES.md index 20a40eea22..b61b84ab1e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,11 +14,13 @@ Grammars: - fix(cpp) fix `xor_eq` keyword highlighting. [Denis Kovalchuk][] - enh(c,cpp) highlight type modifiers as type (#3316) [Josh Goebel][] - enh(css/less/stylus/scss) add support for CSS Grid properties [monochromer][] +- enh(scala) add missing `do` and `then` keyword (#3323) [Nicolas Stucki][] [Austin Schick]: https://github.com/austin-schick [Josh Goebel]: https://github.com/joshgoebel [Denis Kovalchuk]: https://github.com/deniskovalchuk [monochromer]: https://github.com/monochromer +[Nicolas Stucki]: https://github.com/nicolasstucki ## Version 11.2.0 diff --git a/src/languages/scala.js b/src/languages/scala.js index 69aa988a24..e9917c5619 100644 --- a/src/languages/scala.js +++ b/src/languages/scala.js @@ -121,7 +121,7 @@ export default function(hljs) { name: 'Scala', keywords: { literal: 'true false null', - keyword: 'type yield lazy override def with val var sealed abstract private trait object if forSome for while throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit' + keyword: 'type yield lazy override def with val var sealed abstract private trait object if then forSome for while do throw finally protected extends import final return else break new catch super class case package default try this match continue throws implicit' }, contains: [ hljs.C_LINE_COMMENT_MODE, diff --git a/test/markup/scala/for-do.expect.txt b/test/markup/scala/for-do.expect.txt new file mode 100644 index 0000000000..6df2d3e0fb --- /dev/null +++ b/test/markup/scala/for-do.expect.txt @@ -0,0 +1 @@ +def f = for x <- Nil do println("hello") diff --git a/test/markup/scala/for-do.txt b/test/markup/scala/for-do.txt new file mode 100644 index 0000000000..8d72cfa663 --- /dev/null +++ b/test/markup/scala/for-do.txt @@ -0,0 +1 @@ +def f = for x <- Nil do println("hello") diff --git a/test/markup/scala/if-then-else.expect.txt b/test/markup/scala/if-then-else.expect.txt new file mode 100644 index 0000000000..4e01ad73df --- /dev/null +++ b/test/markup/scala/if-then-else.expect.txt @@ -0,0 +1 @@ +def f = if true then 1 else 2 diff --git a/test/markup/scala/if-then-else.txt b/test/markup/scala/if-then-else.txt new file mode 100644 index 0000000000..b142c6011d --- /dev/null +++ b/test/markup/scala/if-then-else.txt @@ -0,0 +1 @@ +def f = if true then 1 else 2 diff --git a/test/markup/scala/while-do.expect.txt b/test/markup/scala/while-do.expect.txt new file mode 100644 index 0000000000..d5291cc1ba --- /dev/null +++ b/test/markup/scala/while-do.expect.txt @@ -0,0 +1 @@ +def f = while true do println("hello") diff --git a/test/markup/scala/while-do.txt b/test/markup/scala/while-do.txt new file mode 100644 index 0000000000..d7874aa2af --- /dev/null +++ b/test/markup/scala/while-do.txt @@ -0,0 +1 @@ +def f = while true do println("hello")