From 03a39c8ac744ffbb7f4ce61df47f760465dd8981 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 | 11 +++++++++++ test/markup/scala/inline.expect.txt | 15 +++++++++++++++ test/markup/scala/inline.txt | 15 +++++++++++++++ 4 files changed, 42 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 112ed8561b..96dfc0bd69 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ Grammars: - enh(scala) add missing `do` and `then` keyword (#3323) [Nicolas Stucki][] - enh(scala) add missing `enum`, `export` and `given` keywords (#3328) [Nicolas Stucki][] - enh(scala) remove symbol syntax and fix quoted code syntax (#3324) [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 ae84bff1f5..65dfa9240c 100644 --- a/src/languages/scala.js +++ b/src/languages/scala.js @@ -112,6 +112,16 @@ export default function(hljs) { contains: [ NAME ] }; + // TODO: use negative look-behind in future + // /(?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