File tree Expand file tree Collapse file tree 5 files changed +39
-3
lines changed Expand file tree Collapse file tree 5 files changed +39
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ Grammars:
21
21
- enh(scala) add Scala 3 ` extension ` soft keyword (#3326 ) [ Nicolas Stucki] [ ]
22
22
- enh(scala) add Scala 3 ` end ` soft keyword (#3327 ) [ Nicolas Stucki] [ ]
23
23
- enh(scala) add ` inline ` soft keyword (#3329 ) [ Nicolas Stucki] [ ]
24
+ - enh(scala) add ` using ` soft keyword (#3330 ) [ Nicolas Stucki] [ ]
24
25
25
26
[ Austin Schick ] : https://github.com/austin-schick
26
27
[ Josh Goebel ] : https://github.com/joshgoebel
Original file line number Diff line number Diff line change 6
6
Website: https://www.scala-lang.org
7
7
*/
8
8
9
+ import * as regex from '../lib/regex.js' ;
10
+
9
11
export default function ( hljs ) {
10
12
const ANNOTATION = {
11
13
className : 'meta' ,
@@ -107,8 +109,7 @@ export default function(hljs) {
107
109
const METHOD = {
108
110
className : 'function' ,
109
111
beginKeywords : 'def' ,
110
- end : / [: = { \[ ( \n ; ] / ,
111
- excludeEnd : true ,
112
+ end : regex . lookahead ( / [: = { \[ ( \n ; ] / ) ,
112
113
contains : [ NAME ]
113
114
} ;
114
115
@@ -146,6 +147,17 @@ export default function(hljs) {
146
147
keywords : 'inline'
147
148
} ] ;
148
149
150
+ const USING_PARAM_CLAUSE = {
151
+ begin : [
152
+ / \( \s * / , // Opening `(` of a parameter or argument list
153
+ / u s i n g / ,
154
+ / \s + (? ! \) ) / , // Spaces not followed by `)`
155
+ ] ,
156
+ beginScope : {
157
+ 2 : "keyword" ,
158
+ }
159
+ } ;
160
+
149
161
return {
150
162
name : 'Scala' ,
151
163
keywords : {
@@ -163,6 +175,7 @@ export default function(hljs) {
163
175
EXTENSION ,
164
176
END ,
165
177
...INLINE_MODES ,
178
+ USING_PARAM_CLAUSE ,
166
179
ANNOTATION
167
180
]
168
181
} ;
Original file line number Diff line number Diff line change 1
- <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span></span>(using <span class="hljs-type">Quotes</span>) = '{ <span class="hljs-keyword">val</span> x = <span class="hljs-number">1</span>; ${g('x)} }
1
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span></span>(<span class="hljs-keyword"> using</span> <span class="hljs-type">Quotes</span>) = '{ <span class="hljs-keyword">val</span> x = <span class="hljs-number">1</span>; ${g('x)} }
Original file line number Diff line number Diff line change
1
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span></span>(<span class="hljs-keyword">using</span> x: <span class="hljs-type">Int</span>) = <span class="hljs-number">1</span>
2
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">g</span></span>(<span class="hljs-keyword">using</span> <span class="hljs-type">Int</span>) = <span class="hljs-number">1</span>
3
+ <span class="hljs-keyword">given</span> (<span class="hljs-keyword">using</span> ev: <span class="hljs-type">Ev</span>): <span class="hljs-type">Foo</span> = ???
4
+
5
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">expressions</span> </span>=
6
+ f(<span class="hljs-keyword">using</span> <span class="hljs-number">2</span>)
7
+
8
+ <span class="hljs-comment">// not `using` keyword</span>
9
+ (using)
10
+ (using )
11
+ ( using )
Original file line number Diff line number Diff line change
1
+ def f(using x: Int) = 1
2
+ def g(using Int) = 1
3
+ given (using ev: Ev): Foo = ???
4
+
5
+ def expressions =
6
+ f(using 2)
7
+
8
+ // not `using` keyword
9
+ (using)
10
+ (using )
11
+ ( using )
You can’t perform that action at this time.
0 commit comments