File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ Grammars:
16
16
- enh(css/less/stylus/scss) add support for CSS Grid properties [ monochromer] [ ]
17
17
- enh(java) add support for Java Text Block (#3322 ) [ Teletha] [ ]
18
18
- enh(scala) add missing ` do ` and ` then ` keyword (#3323 ) [ Nicolas Stucki] [ ]
19
+ - enh(scala) add Scala 3 ` extension ` soft keyword (#3326 ) [ Nicolas Stucki] [ ]
19
20
20
21
[ Austin Schick ] : https://github.com/austin-schick
21
22
[ Josh Goebel ] : https://github.com/joshgoebel
Original file line number Diff line number Diff line change @@ -117,6 +117,11 @@ export default function(hljs) {
117
117
contains : [ NAME ]
118
118
} ;
119
119
120
+ const EXTENSION = {
121
+ className : 'keyword' ,
122
+ begin : / (?< = ^ \s * ) e x t e n s i o n (? = \s + [ \[ \( ] ) /
123
+ } ;
124
+
120
125
return {
121
126
name : 'Scala' ,
122
127
keywords : {
@@ -132,6 +137,7 @@ export default function(hljs) {
132
137
METHOD ,
133
138
CLASS ,
134
139
hljs . C_NUMBER_MODE ,
140
+ EXTENSION ,
135
141
ANNOTATION
136
142
]
137
143
} ;
Original file line number Diff line number Diff line change
1
+ <span class="hljs-keyword">extension</span> (x: <span class="hljs-type">Int</span>) <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">plus</span></span>(y: <span class="hljs-type">Int</span>) = x + y
2
+
3
+ <span class="hljs-keyword">extension</span> [<span class="hljs-type">T</span>](x: <span class="hljs-type">T</span>) <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= ()
4
+
5
+ <span class="hljs-keyword">extension</span> (x: <span class="hljs-type">Int</span>)
6
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">1</span>
7
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">2</span>
8
+
9
+ <span class="hljs-class"><span class="hljs-keyword">object</span> <span class="hljs-title">Foo</span> </span>{
10
+ <span class="hljs-keyword">extension</span> (x: <span class="hljs-type">Int</span>)
11
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">1</span>
12
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">f</span> </span>= <span class="hljs-number">2</span>
13
+ }
14
+
15
+ <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">extension</span></span>(file: <span class="hljs-type">File</span>) =
16
+ file.extension
17
+
18
+ file
19
+ .extension
Original file line number Diff line number Diff line change
1
+ extension (x: Int) def plus(y: Int) = x + y
2
+
3
+ extension [T](x: T) def f = ()
4
+
5
+ extension (x: Int)
6
+ def f = 1
7
+ def f = 2
8
+
9
+ object Foo {
10
+ extension (x: Int)
11
+ def f = 1
12
+ def f = 2
13
+ }
14
+
15
+ def extension(file: File) =
16
+ file.extension
17
+
18
+ file
19
+ .extension
You can’t perform that action at this time.
0 commit comments