1
|
ace.define("ace/mode/kotlin_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
|
2
|
"use strict";
|
3
|
|
4
|
var oop = require("../lib/oop");
|
5
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
6
|
|
7
|
var KotlinHighlightRules = function() {
|
8
|
|
9
|
this.$rules = {
|
10
|
start: [{
|
11
|
include: "#comments"
|
12
|
}, {
|
13
|
token: [
|
14
|
"text",
|
15
|
"keyword.other.kotlin",
|
16
|
"text",
|
17
|
"entity.name.package.kotlin",
|
18
|
"text"
|
19
|
],
|
20
|
regex: /^(\s*)(package)\b(?:(\s*)([^ ;$]+)(\s*))?/
|
21
|
}, {
|
22
|
include: "#imports"
|
23
|
}, {
|
24
|
include: "#statements"
|
25
|
}],
|
26
|
"#classes": [{
|
27
|
token: "text",
|
28
|
regex: /(?=\s*(?:companion|class|object|interface))/,
|
29
|
push: [{
|
30
|
token: "text",
|
31
|
regex: /}|(?=$)/,
|
32
|
next: "pop"
|
33
|
}, {
|
34
|
token: ["keyword.other.kotlin", "text"],
|
35
|
regex: /\b((?:companion\s*)?)(class|object|interface)\b/,
|
36
|
push: [{
|
37
|
token: "text",
|
38
|
regex: /(?=<|{|\(|:)/,
|
39
|
next: "pop"
|
40
|
}, {
|
41
|
token: "keyword.other.kotlin",
|
42
|
regex: /\bobject\b/
|
43
|
}, {
|
44
|
token: "entity.name.type.class.kotlin",
|
45
|
regex: /\w+/
|
46
|
}]
|
47
|
}, {
|
48
|
token: "text",
|
49
|
regex: /</,
|
50
|
push: [{
|
51
|
token: "text",
|
52
|
regex: />/,
|
53
|
next: "pop"
|
54
|
}, {
|
55
|
include: "#generics"
|
56
|
}]
|
57
|
}, {
|
58
|
token: "text",
|
59
|
regex: /\(/,
|
60
|
push: [{
|
61
|
token: "text",
|
62
|
regex: /\)/,
|
63
|
next: "pop"
|
64
|
}, {
|
65
|
include: "#parameters"
|
66
|
}]
|
67
|
}, {
|
68
|
token: "keyword.operator.declaration.kotlin",
|
69
|
regex: /:/,
|
70
|
push: [{
|
71
|
token: "text",
|
72
|
regex: /(?={|$)/,
|
73
|
next: "pop"
|
74
|
}, {
|
75
|
token: "entity.other.inherited-class.kotlin",
|
76
|
regex: /\w+/
|
77
|
}, {
|
78
|
token: "text",
|
79
|
regex: /\(/,
|
80
|
push: [{
|
81
|
token: "text",
|
82
|
regex: /\)/,
|
83
|
next: "pop"
|
84
|
}, {
|
85
|
include: "#expressions"
|
86
|
}]
|
87
|
}]
|
88
|
}, {
|
89
|
token: "text",
|
90
|
regex: /\{/,
|
91
|
push: [{
|
92
|
token: "text",
|
93
|
regex: /\}/,
|
94
|
next: "pop"
|
95
|
}, {
|
96
|
include: "#statements"
|
97
|
}]
|
98
|
}]
|
99
|
}],
|
100
|
"#comments": [{
|
101
|
token: "punctuation.definition.comment.kotlin",
|
102
|
regex: /\/\*/,
|
103
|
push: [{
|
104
|
token: "punctuation.definition.comment.kotlin",
|
105
|
regex: /\*\//,
|
106
|
next: "pop"
|
107
|
}, {
|
108
|
defaultToken: "comment.block.kotlin"
|
109
|
}]
|
110
|
}, {
|
111
|
token: [
|
112
|
"text",
|
113
|
"punctuation.definition.comment.kotlin",
|
114
|
"comment.line.double-slash.kotlin"
|
115
|
],
|
116
|
regex: /(\s*)(\/\/)(.*$)/
|
117
|
}],
|
118
|
"#constants": [{
|
119
|
token: "constant.language.kotlin",
|
120
|
regex: /\b(?:true|false|null|this|super)\b/
|
121
|
}, {
|
122
|
token: "constant.numeric.kotlin",
|
123
|
regex: /\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:(?:e|E)(?:\+|-)?[0-9]+)?)(?:[LlFfUuDd]|UL|ul)?\b/
|
124
|
}, {
|
125
|
token: "constant.other.kotlin",
|
126
|
regex: /\b[A-Z][A-Z0-9_]+\b/
|
127
|
}],
|
128
|
"#expressions": [{
|
129
|
token: "text",
|
130
|
regex: /\(/,
|
131
|
push: [{
|
132
|
token: "text",
|
133
|
regex: /\)/,
|
134
|
next: "pop"
|
135
|
}, {
|
136
|
include: "#expressions"
|
137
|
}]
|
138
|
}, {
|
139
|
include: "#types"
|
140
|
}, {
|
141
|
include: "#strings"
|
142
|
}, {
|
143
|
include: "#constants"
|
144
|
}, {
|
145
|
include: "#comments"
|
146
|
}, {
|
147
|
include: "#keywords"
|
148
|
}],
|
149
|
"#functions": [{
|
150
|
token: "text",
|
151
|
regex: /(?=\s*fun)/,
|
152
|
push: [{
|
153
|
token: "text",
|
154
|
regex: /}|(?=$)/,
|
155
|
next: "pop"
|
156
|
}, {
|
157
|
token: "keyword.other.kotlin",
|
158
|
regex: /\bfun\b/,
|
159
|
push: [{
|
160
|
token: "text",
|
161
|
regex: /(?=\()/,
|
162
|
next: "pop"
|
163
|
}, {
|
164
|
token: "text",
|
165
|
regex: /</,
|
166
|
push: [{
|
167
|
token: "text",
|
168
|
regex: />/,
|
169
|
next: "pop"
|
170
|
}, {
|
171
|
include: "#generics"
|
172
|
}]
|
173
|
}, {
|
174
|
token: ["text", "entity.name.function.kotlin"],
|
175
|
regex: /((?:[\.<\?>\w]+\.)?)(\w+)/
|
176
|
}]
|
177
|
}, {
|
178
|
token: "text",
|
179
|
regex: /\(/,
|
180
|
push: [{
|
181
|
token: "text",
|
182
|
regex: /\)/,
|
183
|
next: "pop"
|
184
|
}, {
|
185
|
include: "#parameters"
|
186
|
}]
|
187
|
}, {
|
188
|
token: "keyword.operator.declaration.kotlin",
|
189
|
regex: /:/,
|
190
|
push: [{
|
191
|
token: "text",
|
192
|
regex: /(?={|=|$)/,
|
193
|
next: "pop"
|
194
|
}, {
|
195
|
include: "#types"
|
196
|
}]
|
197
|
}, {
|
198
|
token: "text",
|
199
|
regex: /\{/,
|
200
|
push: [{
|
201
|
token: "text",
|
202
|
regex: /(?=\})/,
|
203
|
next: "pop"
|
204
|
}, {
|
205
|
include: "#statements"
|
206
|
}]
|
207
|
}, {
|
208
|
token: "keyword.operator.assignment.kotlin",
|
209
|
regex: /=/,
|
210
|
push: [{
|
211
|
token: "text",
|
212
|
regex: /(?=$)/,
|
213
|
next: "pop"
|
214
|
}, {
|
215
|
include: "#expressions"
|
216
|
}]
|
217
|
}]
|
218
|
}],
|
219
|
"#generics": [{
|
220
|
token: "keyword.operator.declaration.kotlin",
|
221
|
regex: /:/,
|
222
|
push: [{
|
223
|
token: "text",
|
224
|
regex: /(?=,|>)/,
|
225
|
next: "pop"
|
226
|
}, {
|
227
|
include: "#types"
|
228
|
}]
|
229
|
}, {
|
230
|
include: "#keywords"
|
231
|
}, {
|
232
|
token: "storage.type.generic.kotlin",
|
233
|
regex: /\w+/
|
234
|
}],
|
235
|
"#getters-and-setters": [{
|
236
|
token: ["entity.name.function.kotlin", "text"],
|
237
|
regex: /\b(get)\b(\s*\(\s*\))/,
|
238
|
push: [{
|
239
|
token: "text",
|
240
|
regex: /\}|(?=\bset\b)|$/,
|
241
|
next: "pop"
|
242
|
}, {
|
243
|
token: "keyword.operator.assignment.kotlin",
|
244
|
regex: /=/,
|
245
|
push: [{
|
246
|
token: "text",
|
247
|
regex: /(?=$|\bset\b)/,
|
248
|
next: "pop"
|
249
|
}, {
|
250
|
include: "#expressions"
|
251
|
}]
|
252
|
}, {
|
253
|
token: "text",
|
254
|
regex: /\{/,
|
255
|
push: [{
|
256
|
token: "text",
|
257
|
regex: /\}/,
|
258
|
next: "pop"
|
259
|
}, {
|
260
|
include: "#expressions"
|
261
|
}]
|
262
|
}]
|
263
|
}, {
|
264
|
token: ["entity.name.function.kotlin", "text"],
|
265
|
regex: /\b(set)\b(\s*)(?=\()/,
|
266
|
push: [{
|
267
|
token: "text",
|
268
|
regex: /\}|(?=\bget\b)|$/,
|
269
|
next: "pop"
|
270
|
}, {
|
271
|
token: "text",
|
272
|
regex: /\(/,
|
273
|
push: [{
|
274
|
token: "text",
|
275
|
regex: /\)/,
|
276
|
next: "pop"
|
277
|
}, {
|
278
|
include: "#parameters"
|
279
|
}]
|
280
|
}, {
|
281
|
token: "keyword.operator.assignment.kotlin",
|
282
|
regex: /=/,
|
283
|
push: [{
|
284
|
token: "text",
|
285
|
regex: /(?=$|\bset\b)/,
|
286
|
next: "pop"
|
287
|
}, {
|
288
|
include: "#expressions"
|
289
|
}]
|
290
|
}, {
|
291
|
token: "text",
|
292
|
regex: /\{/,
|
293
|
push: [{
|
294
|
token: "text",
|
295
|
regex: /\}/,
|
296
|
next: "pop"
|
297
|
}, {
|
298
|
include: "#expressions"
|
299
|
}]
|
300
|
}]
|
301
|
}],
|
302
|
"#imports": [{
|
303
|
token: [
|
304
|
"text",
|
305
|
"keyword.other.kotlin",
|
306
|
"text",
|
307
|
"keyword.other.kotlin"
|
308
|
],
|
309
|
regex: /^(\s*)(import)(\s+[^ $]+\s+)((?:as)?)/
|
310
|
}],
|
311
|
"#keywords": [{
|
312
|
token: "storage.modifier.kotlin",
|
313
|
regex: /\b(?:var|val|public|private|protected|abstract|final|enum|open|attribute|annotation|override|inline|var|val|vararg|lazy|in|out|internal|data|tailrec|operator|infix|const|yield|typealias|typeof)\b/
|
314
|
}, {
|
315
|
token: "keyword.control.catch-exception.kotlin",
|
316
|
regex: /\b(?:try|catch|finally|throw)\b/
|
317
|
}, {
|
318
|
token: "keyword.control.kotlin",
|
319
|
regex: /\b(?:if|else|while|for|do|return|when|where|break|continue)\b/
|
320
|
}, {
|
321
|
token: "keyword.operator.kotlin",
|
322
|
regex: /\b(?:in|is|as|assert)\b/
|
323
|
}, {
|
324
|
token: "keyword.operator.comparison.kotlin",
|
325
|
regex: /==|!=|===|!==|<=|>=|<|>/
|
326
|
}, {
|
327
|
token: "keyword.operator.assignment.kotlin",
|
328
|
regex: /=/
|
329
|
}, {
|
330
|
token: "keyword.operator.declaration.kotlin",
|
331
|
regex: /:/
|
332
|
}, {
|
333
|
token: "keyword.operator.dot.kotlin",
|
334
|
regex: /\./
|
335
|
}, {
|
336
|
token: "keyword.operator.increment-decrement.kotlin",
|
337
|
regex: /\-\-|\+\+/
|
338
|
}, {
|
339
|
token: "keyword.operator.arithmetic.kotlin",
|
340
|
regex: /\-|\+|\*|\/|%/
|
341
|
}, {
|
342
|
token: "keyword.operator.arithmetic.assign.kotlin",
|
343
|
regex: /\+=|\-=|\*=|\/=/
|
344
|
}, {
|
345
|
token: "keyword.operator.logical.kotlin",
|
346
|
regex: /!|&&|\|\|/
|
347
|
}, {
|
348
|
token: "keyword.operator.range.kotlin",
|
349
|
regex: /\.\./
|
350
|
}, {
|
351
|
token: "punctuation.terminator.kotlin",
|
352
|
regex: /;/
|
353
|
}],
|
354
|
"#namespaces": [{
|
355
|
token: "keyword.other.kotlin",
|
356
|
regex: /\bnamespace\b/
|
357
|
}, {
|
358
|
token: "text",
|
359
|
regex: /\{/,
|
360
|
push: [{
|
361
|
token: "text",
|
362
|
regex: /\}/,
|
363
|
next: "pop"
|
364
|
}, {
|
365
|
include: "#statements"
|
366
|
}]
|
367
|
}],
|
368
|
"#parameters": [{
|
369
|
token: "keyword.operator.declaration.kotlin",
|
370
|
regex: /:/,
|
371
|
push: [{
|
372
|
token: "text",
|
373
|
regex: /(?=,|\)|=)/,
|
374
|
next: "pop"
|
375
|
}, {
|
376
|
include: "#types"
|
377
|
}]
|
378
|
}, {
|
379
|
token: "keyword.operator.declaration.kotlin",
|
380
|
regex: /=/,
|
381
|
push: [{
|
382
|
token: "text",
|
383
|
regex: /(?=,|\))/,
|
384
|
next: "pop"
|
385
|
}, {
|
386
|
include: "#expressions"
|
387
|
}]
|
388
|
}, {
|
389
|
include: "#keywords"
|
390
|
}, {
|
391
|
token: "variable.parameter.function.kotlin",
|
392
|
regex: /\w+/
|
393
|
}],
|
394
|
"#statements": [{
|
395
|
include: "#namespaces"
|
396
|
}, {
|
397
|
include: "#typedefs"
|
398
|
}, {
|
399
|
include: "#classes"
|
400
|
}, {
|
401
|
include: "#functions"
|
402
|
}, {
|
403
|
include: "#variables"
|
404
|
}, {
|
405
|
include: "#getters-and-setters"
|
406
|
}, {
|
407
|
include: "#expressions"
|
408
|
}],
|
409
|
"#strings": [{
|
410
|
token: "punctuation.definition.string.begin.kotlin",
|
411
|
regex: /"""/,
|
412
|
push: [{
|
413
|
token: "punctuation.definition.string.end.kotlin",
|
414
|
regex: /"""/,
|
415
|
next: "pop"
|
416
|
}, {
|
417
|
token: "variable.parameter.template.kotlin",
|
418
|
regex: /\$\w+|\$\{[^\}]+\}/
|
419
|
}, {
|
420
|
token: "constant.character.escape.kotlin",
|
421
|
regex: /\\./
|
422
|
}, {
|
423
|
defaultToken: "string.quoted.third.kotlin"
|
424
|
}]
|
425
|
}, {
|
426
|
token: "punctuation.definition.string.begin.kotlin",
|
427
|
regex: /"/,
|
428
|
push: [{
|
429
|
token: "punctuation.definition.string.end.kotlin",
|
430
|
regex: /"/,
|
431
|
next: "pop"
|
432
|
}, {
|
433
|
token: "variable.parameter.template.kotlin",
|
434
|
regex: /\$\w+|\$\{[^\}]+\}/
|
435
|
}, {
|
436
|
token: "constant.character.escape.kotlin",
|
437
|
regex: /\\./
|
438
|
}, {
|
439
|
defaultToken: "string.quoted.double.kotlin"
|
440
|
}]
|
441
|
}, {
|
442
|
token: "punctuation.definition.string.begin.kotlin",
|
443
|
regex: /'/,
|
444
|
push: [{
|
445
|
token: "punctuation.definition.string.end.kotlin",
|
446
|
regex: /'/,
|
447
|
next: "pop"
|
448
|
}, {
|
449
|
token: "constant.character.escape.kotlin",
|
450
|
regex: /\\./
|
451
|
}, {
|
452
|
defaultToken: "string.quoted.single.kotlin"
|
453
|
}]
|
454
|
}, {
|
455
|
token: "punctuation.definition.string.begin.kotlin",
|
456
|
regex: /`/,
|
457
|
push: [{
|
458
|
token: "punctuation.definition.string.end.kotlin",
|
459
|
regex: /`/,
|
460
|
next: "pop"
|
461
|
}, {
|
462
|
defaultToken: "string.quoted.single.kotlin"
|
463
|
}]
|
464
|
}],
|
465
|
"#typedefs": [{
|
466
|
token: "text",
|
467
|
regex: /(?=\s*type)/,
|
468
|
push: [{
|
469
|
token: "text",
|
470
|
regex: /(?=$)/,
|
471
|
next: "pop"
|
472
|
}, {
|
473
|
token: "keyword.other.kotlin",
|
474
|
regex: /\btype\b/
|
475
|
}, {
|
476
|
token: "text",
|
477
|
regex: /</,
|
478
|
push: [{
|
479
|
token: "text",
|
480
|
regex: />/,
|
481
|
next: "pop"
|
482
|
}, {
|
483
|
include: "#generics"
|
484
|
}]
|
485
|
}, {
|
486
|
include: "#expressions"
|
487
|
}]
|
488
|
}],
|
489
|
"#types": [{
|
490
|
token: "storage.type.buildin.kotlin",
|
491
|
regex: /\b(?:Any|Unit|String|Int|Boolean|Char|Long|Double|Float|Short|Byte|dynamic)\b/
|
492
|
}, {
|
493
|
token: "storage.type.buildin.array.kotlin",
|
494
|
regex: /\b(?:IntArray|BooleanArray|CharArray|LongArray|DoubleArray|FloatArray|ShortArray|ByteArray)\b/
|
495
|
}, {
|
496
|
token: [
|
497
|
"storage.type.buildin.collection.kotlin",
|
498
|
"text"
|
499
|
],
|
500
|
regex: /\b(Array|List|Map)(<\b)/,
|
501
|
push: [{
|
502
|
token: "text",
|
503
|
regex: />/,
|
504
|
next: "pop"
|
505
|
}, {
|
506
|
include: "#types"
|
507
|
}, {
|
508
|
include: "#keywords"
|
509
|
}]
|
510
|
}, {
|
511
|
token: "text",
|
512
|
regex: /\w+</,
|
513
|
push: [{
|
514
|
token: "text",
|
515
|
regex: />/,
|
516
|
next: "pop"
|
517
|
}, {
|
518
|
include: "#types"
|
519
|
}, {
|
520
|
include: "#keywords"
|
521
|
}]
|
522
|
}, {
|
523
|
token: ["keyword.operator.tuple.kotlin", "text"],
|
524
|
regex: /(#)(\()/,
|
525
|
push: [{
|
526
|
token: "text",
|
527
|
regex: /\)/,
|
528
|
next: "pop"
|
529
|
}, {
|
530
|
include: "#expressions"
|
531
|
}]
|
532
|
}, {
|
533
|
token: "text",
|
534
|
regex: /\{/,
|
535
|
push: [{
|
536
|
token: "text",
|
537
|
regex: /\}/,
|
538
|
next: "pop"
|
539
|
}, {
|
540
|
include: "#statements"
|
541
|
}]
|
542
|
}, {
|
543
|
token: "text",
|
544
|
regex: /\(/,
|
545
|
push: [{
|
546
|
token: "text",
|
547
|
regex: /\)/,
|
548
|
next: "pop"
|
549
|
}, {
|
550
|
include: "#types"
|
551
|
}]
|
552
|
}, {
|
553
|
token: "keyword.operator.declaration.kotlin",
|
554
|
regex: /->/
|
555
|
}],
|
556
|
"#variables": [{
|
557
|
token: "text",
|
558
|
regex: /(?=\s*(?:var|val))/,
|
559
|
push: [{
|
560
|
token: "text",
|
561
|
regex: /(?=:|=|$)/,
|
562
|
next: "pop"
|
563
|
}, {
|
564
|
token: "keyword.other.kotlin",
|
565
|
regex: /\b(?:var|val)\b/,
|
566
|
push: [{
|
567
|
token: "text",
|
568
|
regex: /(?=:|=|$)/,
|
569
|
next: "pop"
|
570
|
}, {
|
571
|
token: "text",
|
572
|
regex: /</,
|
573
|
push: [{
|
574
|
token: "text",
|
575
|
regex: />/,
|
576
|
next: "pop"
|
577
|
}, {
|
578
|
include: "#generics"
|
579
|
}]
|
580
|
}, {
|
581
|
token: ["text", "entity.name.variable.kotlin"],
|
582
|
regex: /((?:[\.<\?>\w]+\.)?)(\w+)/
|
583
|
}]
|
584
|
}, {
|
585
|
token: "keyword.operator.declaration.kotlin",
|
586
|
regex: /:/,
|
587
|
push: [{
|
588
|
token: "text",
|
589
|
regex: /(?==|$)/,
|
590
|
next: "pop"
|
591
|
}, {
|
592
|
include: "#types"
|
593
|
}, {
|
594
|
include: "#getters-and-setters"
|
595
|
}]
|
596
|
}, {
|
597
|
token: "keyword.operator.assignment.kotlin",
|
598
|
regex: /=/,
|
599
|
push: [{
|
600
|
token: "text",
|
601
|
regex: /(?=$)/,
|
602
|
next: "pop"
|
603
|
}, {
|
604
|
include: "#expressions"
|
605
|
}, {
|
606
|
include: "#getters-and-setters"
|
607
|
}]
|
608
|
}]
|
609
|
}]
|
610
|
};
|
611
|
|
612
|
this.normalizeRules();
|
613
|
};
|
614
|
|
615
|
KotlinHighlightRules.metaData = {
|
616
|
fileTypes: ["kt", "kts"],
|
617
|
name: "Kotlin",
|
618
|
scopeName: "source.Kotlin"
|
619
|
};
|
620
|
|
621
|
|
622
|
oop.inherits(KotlinHighlightRules, TextHighlightRules);
|
623
|
|
624
|
exports.KotlinHighlightRules = KotlinHighlightRules;
|
625
|
});
|
626
|
|
627
|
ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
|
628
|
"use strict";
|
629
|
|
630
|
var oop = require("../../lib/oop");
|
631
|
var Range = require("../../range").Range;
|
632
|
var BaseFoldMode = require("./fold_mode").FoldMode;
|
633
|
|
634
|
var FoldMode = exports.FoldMode = function(commentRegex) {
|
635
|
if (commentRegex) {
|
636
|
this.foldingStartMarker = new RegExp(
|
637
|
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
|
638
|
);
|
639
|
this.foldingStopMarker = new RegExp(
|
640
|
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
|
641
|
);
|
642
|
}
|
643
|
};
|
644
|
oop.inherits(FoldMode, BaseFoldMode);
|
645
|
|
646
|
(function() {
|
647
|
|
648
|
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
|
649
|
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
|
650
|
this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
|
651
|
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
|
652
|
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
|
653
|
this._getFoldWidgetBase = this.getFoldWidget;
|
654
|
this.getFoldWidget = function(session, foldStyle, row) {
|
655
|
var line = session.getLine(row);
|
656
|
|
657
|
if (this.singleLineBlockCommentRe.test(line)) {
|
658
|
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
|
659
|
return "";
|
660
|
}
|
661
|
|
662
|
var fw = this._getFoldWidgetBase(session, foldStyle, row);
|
663
|
|
664
|
if (!fw && this.startRegionRe.test(line))
|
665
|
return "start"; // lineCommentRegionStart
|
666
|
|
667
|
return fw;
|
668
|
};
|
669
|
|
670
|
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
|
671
|
var line = session.getLine(row);
|
672
|
|
673
|
if (this.startRegionRe.test(line))
|
674
|
return this.getCommentRegionBlock(session, line, row);
|
675
|
|
676
|
var match = line.match(this.foldingStartMarker);
|
677
|
if (match) {
|
678
|
var i = match.index;
|
679
|
|
680
|
if (match[1])
|
681
|
return this.openingBracketBlock(session, match[1], row, i);
|
682
|
|
683
|
var range = session.getCommentFoldRange(row, i + match[0].length, 1);
|
684
|
|
685
|
if (range && !range.isMultiLine()) {
|
686
|
if (forceMultiline) {
|
687
|
range = this.getSectionRange(session, row);
|
688
|
} else if (foldStyle != "all")
|
689
|
range = null;
|
690
|
}
|
691
|
|
692
|
return range;
|
693
|
}
|
694
|
|
695
|
if (foldStyle === "markbegin")
|
696
|
return;
|
697
|
|
698
|
var match = line.match(this.foldingStopMarker);
|
699
|
if (match) {
|
700
|
var i = match.index + match[0].length;
|
701
|
|
702
|
if (match[1])
|
703
|
return this.closingBracketBlock(session, match[1], row, i);
|
704
|
|
705
|
return session.getCommentFoldRange(row, i, -1);
|
706
|
}
|
707
|
};
|
708
|
|
709
|
this.getSectionRange = function(session, row) {
|
710
|
var line = session.getLine(row);
|
711
|
var startIndent = line.search(/\S/);
|
712
|
var startRow = row;
|
713
|
var startColumn = line.length;
|
714
|
row = row + 1;
|
715
|
var endRow = row;
|
716
|
var maxRow = session.getLength();
|
717
|
while (++row < maxRow) {
|
718
|
line = session.getLine(row);
|
719
|
var indent = line.search(/\S/);
|
720
|
if (indent === -1)
|
721
|
continue;
|
722
|
if (startIndent > indent)
|
723
|
break;
|
724
|
var subRange = this.getFoldWidgetRange(session, "all", row);
|
725
|
|
726
|
if (subRange) {
|
727
|
if (subRange.start.row <= startRow) {
|
728
|
break;
|
729
|
} else if (subRange.isMultiLine()) {
|
730
|
row = subRange.end.row;
|
731
|
} else if (startIndent == indent) {
|
732
|
break;
|
733
|
}
|
734
|
}
|
735
|
endRow = row;
|
736
|
}
|
737
|
|
738
|
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
|
739
|
};
|
740
|
this.getCommentRegionBlock = function(session, line, row) {
|
741
|
var startColumn = line.search(/\s*$/);
|
742
|
var maxRow = session.getLength();
|
743
|
var startRow = row;
|
744
|
|
745
|
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
|
746
|
var depth = 1;
|
747
|
while (++row < maxRow) {
|
748
|
line = session.getLine(row);
|
749
|
var m = re.exec(line);
|
750
|
if (!m) continue;
|
751
|
if (m[1]) depth--;
|
752
|
else depth++;
|
753
|
|
754
|
if (!depth) break;
|
755
|
}
|
756
|
|
757
|
var endRow = row;
|
758
|
if (endRow > startRow) {
|
759
|
return new Range(startRow, startColumn, endRow, line.length);
|
760
|
}
|
761
|
};
|
762
|
|
763
|
}).call(FoldMode.prototype);
|
764
|
|
765
|
});
|
766
|
|
767
|
ace.define("ace/mode/kotlin",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/kotlin_highlight_rules","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
|
768
|
"use strict";
|
769
|
|
770
|
var oop = require("../lib/oop");
|
771
|
var TextMode = require("./text").Mode;
|
772
|
var KotlinHighlightRules = require("./kotlin_highlight_rules").KotlinHighlightRules;
|
773
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
774
|
var FoldMode = require("./folding/cstyle").FoldMode;
|
775
|
|
776
|
var Mode = function() {
|
777
|
this.HighlightRules = KotlinHighlightRules;
|
778
|
this.foldingRules = new FoldMode();
|
779
|
this.$behaviour = new CstyleBehaviour();
|
780
|
};
|
781
|
oop.inherits(Mode, TextMode);
|
782
|
|
783
|
(function() {
|
784
|
this.$id = "ace/mode/kotlin";
|
785
|
}).call(Mode.prototype);
|
786
|
|
787
|
exports.Mode = Mode;
|
788
|
}); (function() {
|
789
|
ace.require(["ace/mode/kotlin"], function(m) {
|
790
|
if (typeof module == "object" && typeof exports == "object" && module) {
|
791
|
module.exports = m;
|
792
|
}
|
793
|
});
|
794
|
})();
|
795
|
|