Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/mode-kotlin.js

raw symbols SCIP
1 ace.define("ace/mode/kotlin_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
2 var oop = require("../lib/oop");
3 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
4 var KotlinHighlightRules = function () {
5 var keywordMapper = this.$keywords = this.createKeywordMapper({
6 "storage.modifier.kotlin": "var|val|public|private|protected|abstract|final|enum|open|attribute|"
7 + "annotation|override|inline|var|val|vararg|lazy|in|out|internal|data|tailrec|operator|infix|const|"
8 + "yield|typealias|typeof|sealed|inner|value|lateinit|external|suspend|noinline|crossinline|reified|"
9 + "expect|actual",
10 "keyword": "companion|class|object|interface|namespace|type|fun|constructor|if|else|while|for|do|return|when|"
11 + "where|break|continue|try|catch|finally|throw|in|is|as|assert|constructor",
12 "constant.language.kotlin": "true|false|null|this|super",
13 "entity.name.function.kotlin": "get|set"
14 }, "identifier");
15 this.$rules = {
16 start: [{
17 include: "#comments"
18 }, {
19 token: [
20 "text",
21 "keyword.other.kotlin",
22 "text",
23 "entity.name.package.kotlin",
24 "text"
25 ],
26 regex: /^(\s*)(package)\b(?:(\s*)([^ ;$]+)(\s*))?/
27 }, {
28 token: "comment",
29 regex: /^\s*#!.*$/
30 }, {
31 include: "#imports"
32 }, {
33 include: "#expressions"
34 }, {
35 token: "string",
36 regex: /@[a-zA-Z][a-zA-Z:]*\b/
37 }, {
38 token: ["keyword.other.kotlin", "text", "entity.name.variable.kotlin"],
39 regex: /\b(var|val)(\s+)([a-zA-Z_][\w]*)\b/
40 }, {
41 token: ["keyword.other.kotlin", "text", "entity.name.variable.kotlin", "paren.lparen"],
42 regex: /(fun)(\s+)(\w+)(\()/,
43 push: [{
44 token: ["variable.parameter.function.kotlin", "text", "keyword.operator"],
45 regex: /(\w+)(\s*)(:)/
46 }, {
47 token: "paren.rparen",
48 regex: /\)/,
49 next: "pop"
50 }, {
51 include: "#comments"
52 }, {
53 include: "#types"
54 }, {
55 include: "#expressions"
56 }]
57 }, {
58 token: ["text", "keyword", "text", "identifier"],
59 regex: /^(\s*)(class)(\s*)([a-zA-Z]+)/,
60 next: "#classes"
61 }, {
62 token: ["identifier", "punctuaction"],
63 regex: /([a-zA-Z_][\w]*)(<)/,
64 push: [{
65 include: "#generics"
66 }, {
67 include: "#defaultTypes"
68 }, {
69 token: "punctuation",
70 regex: />/,
71 next: "pop"
72 }]
73 }, {
74 token: keywordMapper,
75 regex: /[a-zA-Z_][\w]*\b/
76 }, {
77 token: "paren.lparen",
78 regex: /[{(\[]/
79 }, {
80 token: "paren.rparen",
81 regex: /[})\]]/
82 }],
83 "#comments": [{
84 token: "comment",
85 regex: /\/\*/,
86 push: [{
87 token: "comment",
88 regex: /\*\//,
89 next: "pop"
90 }, {
91 defaultToken: "comment"
92 }]
93 }, {
94 token: [
95 "text",
96 "comment"
97 ],
98 regex: /(\s*)(\/\/.*$)/
99 }],
100 "#constants": [{
101 token: "constant.numeric.kotlin",
102 regex: /\b(?:0(?:x|X)[0-9a-fA-F]*|(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:(?:e|E)(?:\+|-)?[0-9]+)?)(?:[LlFfUuDd]|UL|ul)?\b/
103 }, {
104 token: "constant.other.kotlin",
105 regex: /\b[A-Z][A-Z0-9_]+\b/
106 }],
107 "#expressions": [{
108 include: "#strings"
109 }, {
110 include: "#constants"
111 }, {
112 include: "#keywords"
113 }],
114 "#imports": [{
115 token: [
116 "text",
117 "keyword.other.kotlin",
118 "text",
119 "keyword.other.kotlin"
120 ],
121 regex: /^(\s*)(import)(\s+[^ $]+\s+)((?:as)?)/
122 }],
123 "#generics": [{
124 token: "punctuation",
125 regex: /</,
126 push: [{
127 token: "punctuation",
128 regex: />/,
129 next: "pop"
130 }, {
131 token: "storage.type.generic.kotlin",
132 regex: /\w+/
133 }, {
134 token: "keyword.operator",
135 regex: /:/
136 }, {
137 token: "punctuation",
138 regex: /,/
139 }, {
140 include: "#generics"
141 }]
142 }],
143 "#classes": [{
144 include: "#generics"
145 }, {
146 token: "keyword",
147 regex: /public|private|constructor/
148 }, {
149 token: "string",
150 regex: /@[a-zA-Z][a-zA-Z:]*\b/
151 }, {
152 token: "text",
153 regex: /(?=$|\(|{)/,
154 next: "start"
155 }],
156 "#keywords": [{
157 token: "keyword.operator.kotlin",
158 regex: /==|!=|===|!==|<=|>=|<|>|=>|->|::|\?:/
159 }, {
160 token: "keyword.operator.assignment.kotlin",
161 regex: /=/
162 }, {
163 token: "keyword.operator.declaration.kotlin",
164 regex: /:/,
165 push: [{
166 token: "text",
167 regex: /(?=$|{|=|,)/,
168 next: "pop"
169 }, {
170 include: "#types"
171 }]
172 }, {
173 token: "keyword.operator.dot.kotlin",
174 regex: /\./
175 }, {
176 token: "keyword.operator.increment-decrement.kotlin",
177 regex: /\-\-|\+\+/
178 }, {
179 token: "keyword.operator.arithmetic.kotlin",
180 regex: /\-|\+|\*|\/|%/
181 }, {
182 token: "keyword.operator.arithmetic.assign.kotlin",
183 regex: /\+=|\-=|\*=|\/=/
184 }, {
185 token: "keyword.operator.logical.kotlin",
186 regex: /!|&&|\|\|/
187 }, {
188 token: "keyword.operator.range.kotlin",
189 regex: /\.\./
190 }, {
191 token: "punctuation.kotlin",
192 regex: /[;,]/
193 }],
194 "#types": [{
195 include: "#defaultTypes"
196 }, {
197 token: "paren.lparen",
198 regex: /\(/,
199 push: [{
200 token: "paren.rparen",
201 regex: /\)/,
202 next: "pop"
203 }, {
204 include: "#defaultTypes"
205 }, {
206 token: "punctuation",
207 regex: /,/
208 }]
209 }, {
210 include: "#generics"
211 }, {
212 token: "keyword.operator.declaration.kotlin",
213 regex: /->/
214 }, {
215 token: "paren.rparen",
216 regex: /\)/
217 }, {
218 token: "keyword.operator.declaration.kotlin",
219 regex: /:/,
220 push: [{
221 token: "text",
222 regex: /(?=$|{|=|,)/,
223 next: "pop"
224 }, {
225 include: "#types"
226 }]
227 }],
228 "#defaultTypes": [{
229 token: "storage.type.buildin.kotlin",
230 regex: /\b(Any|Unit|String|Int|Boolean|Char|Long|Double|Float|Short|Byte|dynamic|IntArray|BooleanArray|CharArray|LongArray|DoubleArray|FloatArray|ShortArray|ByteArray|Array|List|Map|Nothing|Enum|Throwable|Comparable)\b/
231 }],
232 "#strings": [{
233 token: "string",
234 regex: /"""/,
235 push: [{
236 token: "string",
237 regex: /"""/,
238 next: "pop"
239 }, {
240 token: "variable.parameter.template.kotlin",
241 regex: /\$\w+|\${[^}]+}/
242 }, {
243 token: "constant.character.escape.kotlin",
244 regex: /\\./
245 }, {
246 defaultToken: "string"
247 }]
248 }, {
249 token: "string",
250 regex: /"/,
251 push: [{
252 token: "string",
253 regex: /"/,
254 next: "pop"
255 }, {
256 token: "variable.parameter.template.kotlin",
257 regex: /\$\w+|\$\{[^\}]+\}/
258 }, {
259 token: "constant.character.escape.kotlin",
260 regex: /\\./
261 }, {
262 defaultToken: "string"
263 }]
264 }, {
265 token: "string",
266 regex: /'/,
267 push: [{
268 token: "string",
269 regex: /'/,
270 next: "pop"
271 }, {
272 token: "constant.character.escape.kotlin",
273 regex: /\\./
274 }, {
275 defaultToken: "string"
276 }]
277 }, {
278 token: "string",
279 regex: /`/,
280 push: [{
281 token: "string",
282 regex: /`/,
283 next: "pop"
284 }, {
285 defaultToken: "string"
286 }]
287 }]
288 };
289 this.normalizeRules();
290 };
291 KotlinHighlightRules.metaData = {
292 fileTypes: ["kt", "kts"],
293 name: "Kotlin",
294 scopeName: "source.Kotlin"
295 };
296 oop.inherits(KotlinHighlightRules, TextHighlightRules);
297 exports.KotlinHighlightRules = KotlinHighlightRules;
298
299 });
300
301 ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
302 var oop = require("../../lib/oop");
303 var Range = require("../../range").Range;
304 var BaseFoldMode = require("./fold_mode").FoldMode;
305 var FoldMode = exports.FoldMode = function (commentRegex) {
306 if (commentRegex) {
307 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
308 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
309 }
310 };
311 oop.inherits(FoldMode, BaseFoldMode);
312 (function () {
313 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
314 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
315 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
316 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
317 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
318 this._getFoldWidgetBase = this.getFoldWidget;
319 this.getFoldWidget = function (session, foldStyle, row) {
320 var line = session.getLine(row);
321 if (this.singleLineBlockCommentRe.test(line)) {
322 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
323 return "";
324 }
325 var fw = this._getFoldWidgetBase(session, foldStyle, row);
326 if (!fw && this.startRegionRe.test(line))
327 return "start"; // lineCommentRegionStart
328 return fw;
329 };
330 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
331 var line = session.getLine(row);
332 if (this.startRegionRe.test(line))
333 return this.getCommentRegionBlock(session, line, row);
334 var match = line.match(this.foldingStartMarker);
335 if (match) {
336 var i = match.index;
337 if (match[1])
338 return this.openingBracketBlock(session, match[1], row, i);
339 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
340 if (range && !range.isMultiLine()) {
341 if (forceMultiline) {
342 range = this.getSectionRange(session, row);
343 }
344 else if (foldStyle != "all")
345 range = null;
346 }
347 return range;
348 }
349 if (foldStyle === "markbegin")
350 return;
351 var match = line.match(this.foldingStopMarker);
352 if (match) {
353 var i = match.index + match[0].length;
354 if (match[1])
355 return this.closingBracketBlock(session, match[1], row, i);
356 return session.getCommentFoldRange(row, i, -1);
357 }
358 };
359 this.getSectionRange = function (session, row) {
360 var line = session.getLine(row);
361 var startIndent = line.search(/\S/);
362 var startRow = row;
363 var startColumn = line.length;
364 row = row + 1;
365 var endRow = row;
366 var maxRow = session.getLength();
367 while (++row < maxRow) {
368 line = session.getLine(row);
369 var indent = line.search(/\S/);
370 if (indent === -1)
371 continue;
372 if (startIndent > indent)
373 break;
374 var subRange = this.getFoldWidgetRange(session, "all", row);
375 if (subRange) {
376 if (subRange.start.row <= startRow) {
377 break;
378 }
379 else if (subRange.isMultiLine()) {
380 row = subRange.end.row;
381 }
382 else if (startIndent == indent) {
383 break;
384 }
385 }
386 endRow = row;
387 }
388 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
389 };
390 this.getCommentRegionBlock = function (session, line, row) {
391 var startColumn = line.search(/\s*$/);
392 var maxRow = session.getLength();
393 var startRow = row;
394 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
395 var depth = 1;
396 while (++row < maxRow) {
397 line = session.getLine(row);
398 var m = re.exec(line);
399 if (!m)
400 continue;
401 if (m[1])
402 depth--;
403 else
404 depth++;
405 if (!depth)
406 break;
407 }
408 var endRow = row;
409 if (endRow > startRow) {
410 return new Range(startRow, startColumn, endRow, line.length);
411 }
412 };
413 }).call(FoldMode.prototype);
414
415 });
416
417 ace.define("ace/mode/kotlin",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/kotlin_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
418 THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
419 */
420 "use strict";
421 var oop = require("../lib/oop");
422 var TextMode = require("./text").Mode;
423 var KotlinHighlightRules = require("./kotlin_highlight_rules").KotlinHighlightRules;
424 var FoldMode = require("./folding/cstyle").FoldMode;
425 var Mode = function () {
426 this.HighlightRules = KotlinHighlightRules;
427 this.foldingRules = new FoldMode();
428 this.$behaviour = this.$defaultBehaviour;
429 };
430 oop.inherits(Mode, TextMode);
431 (function () {
432 this.lineCommentStart = "//";
433 this.blockComment = { start: "/*", end: "*/" };
434 this.$id = "ace/mode/kotlin";
435 }).call(Mode.prototype);
436 exports.Mode = Mode;
437
438 }); (function() {
439 ace.require(["ace/mode/kotlin"], function(m) {
440 if (typeof module == "object" && typeof exports == "object" && module) {
441 module.exports = m;
442 }
443 });
444 })();
445