Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/smithy_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* This file was autogenerated from https://raw.githubusercontent.com/awslabs/smithy-vscode/master/syntaxes/smithy.tmLanguage (uuid: ) */
2 "use strict";
3 var oop = require("../lib/oop");
4 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
5 var SmithyHighlightRules = function () {
6 this.$rules = {
7 start: [{
8 include: "#comment"
9 }, {
10 token: [
11 "meta.keyword.statement.smithy",
12 "variable.other.smithy",
13 "text",
14 "keyword.operator.smithy"
15 ],
16 regex: /^(\$)(\s+.+)(\s*)(=)/
17 }, {
18 token: [
19 "keyword.statement.smithy",
20 "text",
21 "entity.name.type.namespace.smithy"
22 ],
23 regex: /^(namespace)(\s+)([A-Z-a-z0-9_\.#$-]+)/
24 }, {
25 token: [
26 "keyword.statement.smithy",
27 "text",
28 "keyword.statement.smithy",
29 "text",
30 "entity.name.type.smithy"
31 ],
32 regex: /^(use)(\s+)(shape|trait)(\s+)([A-Z-a-z0-9_\.#$-]+)\b/
33 }, {
34 token: [
35 "keyword.statement.smithy",
36 "variable.other.smithy",
37 "text",
38 "keyword.operator.smithy"
39 ],
40 regex: /^(metadata)(\s+.+)(\s*)(=)/
41 }, {
42 token: [
43 "keyword.statement.smithy",
44 "text",
45 "entity.name.type.smithy"
46 ],
47 regex: /^(apply|byte|short|integer|long|float|double|bigInteger|bigDecimal|boolean|blob|string|timestamp|service|resource|trait|list|map|set|structure|union|document)(\s+)([A-Z-a-z0-9_\.#$-]+)\b/
48 }, {
49 token: [
50 "keyword.operator.smithy",
51 "text",
52 "entity.name.type.smithy",
53 "text",
54 "text",
55 "support.function.smithy",
56 "text",
57 "text",
58 "support.function.smithy"
59 ],
60 regex: /^(operation)(\s+)([A-Z-a-z0-9_\.#$-]+)(\(.*\))(?:(\s*)(->)(\s*[A-Z-a-z0-9_\.#$-]+))?(?:(\s+)(errors))?/
61 }, {
62 include: "#trait"
63 }, {
64 token: [
65 "support.type.property-name.smithy",
66 "punctuation.separator.dictionary.pair.smithy"
67 ],
68 regex: /([A-Z-a-z0-9_\.#$-]+)(:)/
69 }, {
70 include: "#value"
71 }, {
72 token: "keyword.other.smithy",
73 regex: /\->/
74 }],
75 "#comment": [{
76 include: "#doc_comment"
77 }, {
78 include: "#line_comment"
79 }],
80 "#doc_comment": [{
81 token: "comment.block.documentation.smithy",
82 regex: /\/\/\/.*/
83 }],
84 "#line_comment": [{
85 token: "comment.line.double-slash.smithy",
86 regex: /\/\/.*/
87 }],
88 "#trait": [{
89 token: [
90 "punctuation.definition.annotation.smithy",
91 "storage.type.annotation.smithy"
92 ],
93 regex: /(@)([0-9a-zA-Z\.#-]+)/
94 }, {
95 token: [
96 "punctuation.definition.annotation.smithy",
97 "punctuation.definition.object.end.smithy",
98 "meta.structure.smithy"
99 ],
100 regex: /(@)([0-9a-zA-Z\.#-]+)(\()/,
101 push: [{
102 token: "punctuation.definition.object.end.smithy",
103 regex: /\)/,
104 next: "pop"
105 }, {
106 include: "#value"
107 }, {
108 include: "#object_inner"
109 }, {
110 defaultToken: "meta.structure.smithy"
111 }]
112 }],
113 "#value": [{
114 include: "#constant"
115 }, {
116 include: "#number"
117 }, {
118 include: "#string"
119 }, {
120 include: "#array"
121 }, {
122 include: "#object"
123 }],
124 "#array": [{
125 token: "punctuation.definition.array.begin.smithy",
126 regex: /\[/,
127 push: [{
128 token: "punctuation.definition.array.end.smithy",
129 regex: /\]/,
130 next: "pop"
131 }, {
132 include: "#comment"
133 }, {
134 include: "#value"
135 }, {
136 token: "punctuation.separator.array.smithy",
137 regex: /,/
138 }, {
139 token: "invalid.illegal.expected-array-separator.smithy",
140 regex: /[^\s\]]/
141 }, {
142 defaultToken: "meta.structure.array.smithy"
143 }]
144 }],
145 "#constant": [{
146 token: "constant.language.smithy",
147 regex: /\b(?:true|false|null)\b/
148 }],
149 "#number": [{
150 token: "constant.numeric.smithy",
151 regex: /-?(?:0|[1-9]\d*)(?:(?:\.\d+)?(?:[eE][+-]?\d+)?)?/
152 }],
153 "#object": [{
154 token: "punctuation.definition.dictionary.begin.smithy",
155 regex: /\{/,
156 push: [{
157 token: "punctuation.definition.dictionary.end.smithy",
158 regex: /\}/,
159 next: "pop"
160 }, {
161 include: "#trait"
162 }, {
163 include: "#object_inner"
164 }, {
165 defaultToken: "meta.structure.dictionary.smithy"
166 }]
167 }],
168 "#object_inner": [{
169 include: "#comment"
170 }, {
171 include: "#string_key"
172 }, {
173 token: "punctuation.separator.dictionary.key-value.smithy",
174 regex: /:/,
175 push: [{
176 token: "punctuation.separator.dictionary.pair.smithy",
177 regex: /,|(?=\})/,
178 next: "pop"
179 }, {
180 include: "#value"
181 }, {
182 token: "invalid.illegal.expected-dictionary-separator.smithy",
183 regex: /[^\s,]/
184 }, {
185 defaultToken: "meta.structure.dictionary.value.smithy"
186 }]
187 }, {
188 token: "invalid.illegal.expected-dictionary-separator.smithy",
189 regex: /[^\s\}]/
190 }],
191 "#string_key": [{
192 include: "#identifier_key"
193 }, {
194 include: "#dquote_key"
195 }, {
196 include: "#squote_key"
197 }],
198 "#identifier_key": [{
199 token: "support.type.property-name.smithy",
200 regex: /[A-Z-a-z0-9_\.#$-]+/
201 }],
202 "#dquote_key": [{
203 include: "#dquote"
204 }],
205 "#squote_key": [{
206 include: "#squote"
207 }],
208 "#string": [{
209 include: "#textblock"
210 }, {
211 include: "#dquote"
212 }, {
213 include: "#squote"
214 }, {
215 include: "#identifier"
216 }],
217 "#textblock": [{
218 token: "punctuation.definition.string.begin.smithy",
219 regex: /"""/,
220 push: [{
221 token: "punctuation.definition.string.end.smithy",
222 regex: /"""/,
223 next: "pop"
224 }, {
225 token: "constant.character.escape.smithy",
226 regex: /\\./
227 }, {
228 defaultToken: "string.quoted.double.smithy"
229 }]
230 }],
231 "#dquote": [{
232 token: "punctuation.definition.string.begin.smithy",
233 regex: /"/,
234 push: [{
235 token: "punctuation.definition.string.end.smithy",
236 regex: /"/,
237 next: "pop"
238 }, {
239 token: "constant.character.escape.smithy",
240 regex: /\\./
241 }, {
242 defaultToken: "string.quoted.double.smithy"
243 }]
244 }],
245 "#squote": [{
246 token: "punctuation.definition.string.begin.smithy",
247 regex: /'/,
248 push: [{
249 token: "punctuation.definition.string.end.smithy",
250 regex: /'/,
251 next: "pop"
252 }, {
253 token: "constant.character.escape.smithy",
254 regex: /\\./
255 }, {
256 defaultToken: "string.quoted.single.smithy"
257 }]
258 }],
259 "#identifier": [{
260 token: "storage.type.smithy",
261 regex: /[A-Z-a-z_][A-Z-a-z0-9_\.#$-]*/
262 }]
263 };
264 this.normalizeRules();
265 };
266 SmithyHighlightRules.metaData = {
267 name: "Smithy",
268 fileTypes: ["smithy"],
269 scopeName: "source.smithy",
270 foldingStartMarker: "(\\{|\\[)\\s*",
271 foldingStopMarker: "\\s*(\\}|\\])"
272 };
273 oop.inherits(SmithyHighlightRules, TextHighlightRules);
274 exports.SmithyHighlightRules = SmithyHighlightRules;
275
276 });
277
278 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
279 var Range = require("../range").Range;
280 var MatchingBraceOutdent = function () { };
281 (function () {
282 this.checkOutdent = function (line, input) {
283 if (!/^\s+$/.test(line))
284 return false;
285 return /^\s*\}/.test(input);
286 };
287 this.autoOutdent = function (doc, row) {
288 var line = doc.getLine(row);
289 var match = line.match(/^(\s*\})/);
290 if (!match)
291 return 0;
292 var column = match[1].length;
293 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
294 if (!openBracePos || openBracePos.row == row)
295 return 0;
296 var indent = this.$getIndent(doc.getLine(openBracePos.row));
297 doc.replace(new Range(row, 0, row, column - 1), indent);
298 };
299 this.$getIndent = function (line) {
300 return line.match(/^\s*/)[0];
301 };
302 }).call(MatchingBraceOutdent.prototype);
303 exports.MatchingBraceOutdent = MatchingBraceOutdent;
304
305 });
306
307 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";
308 var oop = require("../../lib/oop");
309 var Range = require("../../range").Range;
310 var BaseFoldMode = require("./fold_mode").FoldMode;
311 var FoldMode = exports.FoldMode = function (commentRegex) {
312 if (commentRegex) {
313 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
314 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
315 }
316 };
317 oop.inherits(FoldMode, BaseFoldMode);
318 (function () {
319 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
320 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
321 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
322 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
323 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
324 this._getFoldWidgetBase = this.getFoldWidget;
325 this.getFoldWidget = function (session, foldStyle, row) {
326 var line = session.getLine(row);
327 if (this.singleLineBlockCommentRe.test(line)) {
328 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
329 return "";
330 }
331 var fw = this._getFoldWidgetBase(session, foldStyle, row);
332 if (!fw && this.startRegionRe.test(line))
333 return "start"; // lineCommentRegionStart
334 return fw;
335 };
336 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
337 var line = session.getLine(row);
338 if (this.startRegionRe.test(line))
339 return this.getCommentRegionBlock(session, line, row);
340 var match = line.match(this.foldingStartMarker);
341 if (match) {
342 var i = match.index;
343 if (match[1])
344 return this.openingBracketBlock(session, match[1], row, i);
345 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
346 if (range && !range.isMultiLine()) {
347 if (forceMultiline) {
348 range = this.getSectionRange(session, row);
349 }
350 else if (foldStyle != "all")
351 range = null;
352 }
353 return range;
354 }
355 if (foldStyle === "markbegin")
356 return;
357 var match = line.match(this.foldingStopMarker);
358 if (match) {
359 var i = match.index + match[0].length;
360 if (match[1])
361 return this.closingBracketBlock(session, match[1], row, i);
362 return session.getCommentFoldRange(row, i, -1);
363 }
364 };
365 this.getSectionRange = function (session, row) {
366 var line = session.getLine(row);
367 var startIndent = line.search(/\S/);
368 var startRow = row;
369 var startColumn = line.length;
370 row = row + 1;
371 var endRow = row;
372 var maxRow = session.getLength();
373 while (++row < maxRow) {
374 line = session.getLine(row);
375 var indent = line.search(/\S/);
376 if (indent === -1)
377 continue;
378 if (startIndent > indent)
379 break;
380 var subRange = this.getFoldWidgetRange(session, "all", row);
381 if (subRange) {
382 if (subRange.start.row <= startRow) {
383 break;
384 }
385 else if (subRange.isMultiLine()) {
386 row = subRange.end.row;
387 }
388 else if (startIndent == indent) {
389 break;
390 }
391 }
392 endRow = row;
393 }
394 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
395 };
396 this.getCommentRegionBlock = function (session, line, row) {
397 var startColumn = line.search(/\s*$/);
398 var maxRow = session.getLength();
399 var startRow = row;
400 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
401 var depth = 1;
402 while (++row < maxRow) {
403 line = session.getLine(row);
404 var m = re.exec(line);
405 if (!m)
406 continue;
407 if (m[1])
408 depth--;
409 else
410 depth++;
411 if (!depth)
412 break;
413 }
414 var endRow = row;
415 if (endRow > startRow) {
416 return new Range(startRow, startColumn, endRow, line.length);
417 }
418 };
419 }).call(FoldMode.prototype);
420
421 });
422
423 ace.define("ace/mode/smithy",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/smithy_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
424 var oop = require("../lib/oop");
425 var TextMode = require("./text").Mode;
426 var SmithyHighlightRules = require("./smithy_highlight_rules").SmithyHighlightRules;
427 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
428 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
429 var Mode = function () {
430 this.HighlightRules = SmithyHighlightRules;
431 this.$outdent = new MatchingBraceOutdent();
432 this.$behaviour = this.$defaultBehaviour;
433 this.foldingRules = new CStyleFoldMode();
434 };
435 oop.inherits(Mode, TextMode);
436 (function () {
437 this.lineCommentStart = "//";
438 this.$quotes = { '"': '"' };
439 this.checkOutdent = function (state, line, input) {
440 return this.$outdent.checkOutdent(line, input);
441 };
442 this.autoOutdent = function (state, doc, row) {
443 this.$outdent.autoOutdent(doc, row);
444 };
445 this.$id = "ace/mode/smithy";
446 }).call(Mode.prototype);
447 exports.Mode = Mode;
448
449 }); (function() {
450 ace.require(["ace/mode/smithy"], function(m) {
451 if (typeof module == "object" && typeof exports == "object" && module) {
452 module.exports = m;
453 }
454 });
455 })();
456