From 12cd29752271dfd9af84b678b62a3b583a377463 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 6 Sep 2021 16:00:46 +0200 Subject: [PATCH] enh(scala) add `inline` soft keyword Make `inline` a keyword when it is not part of a member selection of application. Basic idea form https://github.com/scala/vscode-scala-syntax/blob/main/src/typescript/Scala.tmLanguage.ts#L665, but without the need to distinguish the two kinds of keyword. Also see https://docs.scala-lang.org/scala3/reference/soft-modifier.html --- CHANGES.md | 1 + src/languages/scala.js | 6 ++++++ test/markup/scala/inline.expect.txt | 15 +++++++++++++++ test/markup/scala/inline.txt | 15 +++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 test/markup/scala/inline.expect.txt create mode 100644 test/markup/scala/inline.txt diff --git a/CHANGES.md b/CHANGES.md index b66ef69a0f..4835c14101 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ Grammars: - enh(css/less/stylus/scss) add support for CSS Grid properties [monochromer][] - enh(java) add support for Java Text Block (#3322) [Teletha][] - enh(scala) add missing `do` and `then` keyword (#3323) [Nicolas Stucki][] +- enh(scala) add `inline` soft keyword (#3329) [Nicolas Stucki][] [Austin Schick]: https://github.com/austin-schick [Josh Goebel]: https://github.com/joshgoebel diff --git a/src/languages/scala.js b/src/languages/scala.js index e9917c5619..6a7e101af3 100644 --- a/src/languages/scala.js +++ b/src/languages/scala.js @@ -117,6 +117,11 @@ export default function(hljs) { contains: [ NAME ] }; + const INLINE = { + className: 'keyword', + begin: /(?inline def pow(inline x: Int, inline n: Int) = ??? +transparent inline def f: Int = ??? +inline val a: Int = 9 +inline given Int = 9 + +notinline given Int = 9 + +def expressions = + inline if true then () else () + inline x match ... + + x.inline + x.inline(y) + x.inline[T] + `inline` + 1 diff --git a/test/markup/scala/inline.txt b/test/markup/scala/inline.txt new file mode 100644 index 0000000000..857b82ac8c --- /dev/null +++ b/test/markup/scala/inline.txt @@ -0,0 +1,15 @@ +inline def pow(inline x: Int, inline n: Int) = ??? +transparent inline def f: Int = ??? +inline val a: Int = 9 +inline given Int = 9 + +notinline given Int = 9 + +def expressions = + inline if true then () else () + inline x match ... + + x.inline + x.inline(y) + x.inline[T] + `inline` + 1