enh(scala) - add `using` directive support (#3810)
This commit is contained in:
parent
a3e401ec4e
commit
e5e0220052
|
@ -19,6 +19,7 @@ Core Grammars:
|
|||
- enh(swift) support parameter pack keywords [Bradley Mackey][]
|
||||
- enh(swift) regex literal support [Bradley Mackey][]
|
||||
- enh(swift) `@unchecked` and `@Sendable` support [Bradley Mackey][]
|
||||
- enh(scala) add using directives support `//> using foo bar` [Jamie Thompson][]
|
||||
- enh(swift) ownership modifiers support [Bradley Mackey][]
|
||||
- enh(nsis) Add `!assert` compiler flag [idleberg][]
|
||||
- fix(haskell) do not treat double dashes inside infix operators as comments [Zlondrej][]
|
||||
|
|
|
@ -151,6 +151,34 @@ export default function(hljs) {
|
|||
beginScope: { 2: "keyword", }
|
||||
};
|
||||
|
||||
// glob all non-whitespace characters as a "string"
|
||||
// sourced from https://github.com/scala/docs.scala-lang/pull/2845
|
||||
const DIRECTIVE_VALUE = {
|
||||
className: 'string',
|
||||
begin: /\S+/,
|
||||
}
|
||||
|
||||
// directives
|
||||
// sourced from https://github.com/scala/docs.scala-lang/pull/2845
|
||||
const USING_DIRECTIVE = {
|
||||
begin: [
|
||||
'//>',
|
||||
/\s+/,
|
||||
/using/,
|
||||
/\s+/,
|
||||
/\S+/
|
||||
],
|
||||
beginScope: {
|
||||
1: "comment",
|
||||
3: "keyword",
|
||||
5: "type"
|
||||
},
|
||||
end: /$/,
|
||||
contains: [
|
||||
DIRECTIVE_VALUE,
|
||||
]
|
||||
}
|
||||
|
||||
return {
|
||||
name: 'Scala',
|
||||
keywords: {
|
||||
|
@ -158,6 +186,7 @@ export default function(hljs) {
|
|||
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 export enum given transparent'
|
||||
},
|
||||
contains: [
|
||||
USING_DIRECTIVE,
|
||||
hljs.C_LINE_COMMENT_MODE,
|
||||
hljs.C_BLOCK_COMMENT_MODE,
|
||||
STRING,
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<span class="hljs-comment">//></span> <span class="hljs-keyword">using</span> <span class="hljs-type">scala</span> <span class="hljs-string">3.3.0</span>
|
||||
<span class="hljs-comment">//></span> <span class="hljs-keyword">using</span> <span class="hljs-type">options</span> <span class="hljs-string">-source:future</span> <span class="hljs-string">-Xfatal-warnings</span>
|
||||
<span class="hljs-comment">//></span> <span class="hljs-keyword">using</span> <span class="hljs-type">test.resourceDir</span> <span class="hljs-string">./resources</span>
|
||||
<span class="hljs-comment">// using foo bar <-- this should not be highlighted</span>
|
|
@ -0,0 +1,4 @@
|
|||
//> using scala 3.3.0
|
||||
//> using options -source:future -Xfatal-warnings
|
||||
//> using test.resourceDir ./resources
|
||||
// using foo bar <-- this should not be highlighted
|
Loading…
Reference in New Issue