Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/coffee_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 oop.inherits(CoffeeHighlightRules, TextHighlightRules);
5 function CoffeeHighlightRules() {
6 var identifier = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*";
7 var keywords = ("this|throw|then|try|typeof|super|switch|return|break|by|continue|" +
8 "catch|class|in|instanceof|is|isnt|if|else|extends|for|own|" +
9 "finally|function|while|when|new|no|not|delete|debugger|do|loop|of|off|" +
10 "or|on|unless|until|and|yes|yield|export|import|default");
11 var langConstant = ("true|false|null|undefined|NaN|Infinity");
12 var illegal = ("case|const|function|var|void|with|enum|implements|" +
13 "interface|let|package|private|protected|public|static");
14 var supportClass = ("Array|Boolean|Date|Function|Number|Object|RegExp|ReferenceError|String|" +
15 "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
16 "SyntaxError|TypeError|URIError|" +
17 "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
18 "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray");
19 var supportFunction = ("Math|JSON|isNaN|isFinite|parseInt|parseFloat|encodeURI|" +
20 "encodeURIComponent|decodeURI|decodeURIComponent|String|");
21 var variableLanguage = ("window|arguments|prototype|document");
22 var keywordMapper = this.createKeywordMapper({
23 "keyword": keywords,
24 "constant.language": langConstant,
25 "invalid.illegal": illegal,
26 "language.support.class": supportClass,
27 "language.support.function": supportFunction,
28 "variable.language": variableLanguage
29 }, "identifier");
30 var functionRule = {
31 token: ["paren.lparen", "variable.parameter", "paren.rparen", "text", "storage.type"],
32 regex: /(?:(\()((?:"[^")]*?"|'[^')]*?'|\/[^\/)]*?\/|[^()"'\/])*?)(\))(\s*))?([\-=]>)/.source
33 };
34 var stringEscape = /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|[0-2][0-7]{0,2}|3[0-6][0-7]?|37[0-7]?|[4-7][0-7]?|.)/;
35 this.$rules = {
36 start: [
37 {
38 token: "constant.numeric",
39 regex: "(?:0x[\\da-fA-F]+|(?:\\d+(?:\\.\\d+)?|\\.\\d+)(?:[eE][+-]?\\d+)?)"
40 }, {
41 stateName: "qdoc",
42 token: "string", regex: "'''", next: [
43 { token: "string", regex: "'''", next: "start" },
44 { token: "constant.language.escape", regex: stringEscape },
45 { defaultToken: "string" }
46 ]
47 }, {
48 stateName: "qqdoc",
49 token: "string",
50 regex: '"""',
51 next: [
52 { token: "string", regex: '"""', next: "start" },
53 { token: "paren.string", regex: '#{', push: "start" },
54 { token: "constant.language.escape", regex: stringEscape },
55 { defaultToken: "string" }
56 ]
57 }, {
58 stateName: "qstring",
59 token: "string", regex: "'", next: [
60 { token: "string", regex: "'", next: "start" },
61 { token: "constant.language.escape", regex: stringEscape },
62 { defaultToken: "string" }
63 ]
64 }, {
65 stateName: "qqstring",
66 token: "string.start", regex: '"', next: [
67 { token: "string.end", regex: '"', next: "start" },
68 { token: "paren.string", regex: '#{', push: "start" },
69 { token: "constant.language.escape", regex: stringEscape },
70 { defaultToken: "string" }
71 ]
72 }, {
73 stateName: "js",
74 token: "string", regex: "`", next: [
75 { token: "string", regex: "`", next: "start" },
76 { token: "constant.language.escape", regex: stringEscape },
77 { defaultToken: "string" }
78 ]
79 }, {
80 regex: "[{}]", onMatch: function (val, state, stack) {
81 this.next = "";
82 if (val == "{" && stack.length) {
83 stack.unshift("start", state);
84 return "paren";
85 }
86 if (val == "}" && stack.length) {
87 stack.shift();
88 this.next = stack.shift() || "";
89 if (this.next.indexOf("string") != -1)
90 return "paren.string";
91 }
92 return "paren";
93 }
94 }, {
95 token: "string.regex",
96 regex: "///",
97 next: "heregex"
98 }, {
99 token: "string.regex",
100 regex: /(?:\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)(?:[imgy]{0,4})(?!\w)/
101 }, {
102 token: "comment",
103 regex: "###(?!#)",
104 next: "comment"
105 }, {
106 token: "comment",
107 regex: "#.*"
108 }, {
109 token: ["punctuation.operator", "text", "identifier"],
110 regex: "(\\.)(\\s*)(" + illegal + ")"
111 }, {
112 token: "punctuation.operator",
113 regex: "\\.{1,3}"
114 }, {
115 token: ["keyword", "text", "language.support.class",
116 "text", "keyword", "text", "language.support.class"],
117 regex: "(class)(\\s+)(" + identifier + ")(?:(\\s+)(extends)(\\s+)(" + identifier + "))?"
118 }, {
119 token: ["entity.name.function", "text", "keyword.operator", "text"].concat(functionRule.token),
120 regex: "(" + identifier + ")(\\s*)([=:])(\\s*)" + functionRule.regex
121 },
122 functionRule,
123 {
124 token: "variable",
125 regex: "@(?:" + identifier + ")?"
126 }, {
127 token: keywordMapper,
128 regex: identifier
129 }, {
130 token: "punctuation.operator",
131 regex: "\\,|\\."
132 }, {
133 token: "storage.type",
134 regex: "[\\-=]>"
135 }, {
136 token: "keyword.operator",
137 regex: "(?:[-+*/%<>&|^!?=]=|>>>=?|\\-\\-|\\+\\+|::|&&=|\\|\\|=|<<=|>>=|\\?\\.|\\.{2,3}|[!*+-=><])"
138 }, {
139 token: "paren.lparen",
140 regex: "[({[]"
141 }, {
142 token: "paren.rparen",
143 regex: "[\\]})]"
144 }, {
145 token: "text",
146 regex: "\\s+"
147 }
148 ],
149 heregex: [{
150 token: "string.regex",
151 regex: '.*?///[imgy]{0,4}',
152 next: "start"
153 }, {
154 token: "comment.regex",
155 regex: "\\s+(?:#.*)?"
156 }, {
157 token: "string.regex",
158 regex: "\\S+"
159 }],
160 comment: [{
161 token: "comment",
162 regex: '###',
163 next: "start"
164 }, {
165 defaultToken: "comment"
166 }]
167 };
168 this.normalizeRules();
169 }
170 exports.CoffeeHighlightRules = CoffeeHighlightRules;
171
172 });
173
174 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
175 var Range = require("../range").Range;
176 var MatchingBraceOutdent = function () { };
177 (function () {
178 this.checkOutdent = function (line, input) {
179 if (!/^\s+$/.test(line))
180 return false;
181 return /^\s*\}/.test(input);
182 };
183 this.autoOutdent = function (doc, row) {
184 var line = doc.getLine(row);
185 var match = line.match(/^(\s*\})/);
186 if (!match)
187 return 0;
188 var column = match[1].length;
189 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
190 if (!openBracePos || openBracePos.row == row)
191 return 0;
192 var indent = this.$getIndent(doc.getLine(openBracePos.row));
193 doc.replace(new Range(row, 0, row, column - 1), indent);
194 };
195 this.$getIndent = function (line) {
196 return line.match(/^\s*/)[0];
197 };
198 }).call(MatchingBraceOutdent.prototype);
199 exports.MatchingBraceOutdent = MatchingBraceOutdent;
200
201 });
202
203 ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module){"use strict";
204 var oop = require("../../lib/oop");
205 var BaseFoldMode = require("./fold_mode").FoldMode;
206 var Range = require("../../range").Range;
207 var FoldMode = exports.FoldMode = function () { };
208 oop.inherits(FoldMode, BaseFoldMode);
209 (function () {
210 this.commentBlock = function (session, row) {
211 var re = /\S/;
212 var line = session.getLine(row);
213 var startLevel = line.search(re);
214 if (startLevel == -1 || line[startLevel] != "#")
215 return;
216 var startColumn = line.length;
217 var maxRow = session.getLength();
218 var startRow = row;
219 var endRow = row;
220 while (++row < maxRow) {
221 line = session.getLine(row);
222 var level = line.search(re);
223 if (level == -1)
224 continue;
225 if (line[level] != "#")
226 break;
227 endRow = row;
228 }
229 if (endRow > startRow) {
230 var endColumn = session.getLine(endRow).length;
231 return new Range(startRow, startColumn, endRow, endColumn);
232 }
233 };
234 this.getFoldWidgetRange = function (session, foldStyle, row) {
235 var range = this.indentationBlock(session, row);
236 if (range)
237 return range;
238 range = this.commentBlock(session, row);
239 if (range)
240 return range;
241 };
242 this.getFoldWidget = function (session, foldStyle, row) {
243 var line = session.getLine(row);
244 var indent = line.search(/\S/);
245 var next = session.getLine(row + 1);
246 var prev = session.getLine(row - 1);
247 var prevIndent = prev.search(/\S/);
248 var nextIndent = next.search(/\S/);
249 if (indent == -1) {
250 session.foldWidgets[row - 1] = prevIndent != -1 && prevIndent < nextIndent ? "start" : "";
251 return "";
252 }
253 if (prevIndent == -1) {
254 if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
255 session.foldWidgets[row - 1] = "";
256 session.foldWidgets[row + 1] = "";
257 return "start";
258 }
259 }
260 else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
261 if (session.getLine(row - 2).search(/\S/) == -1) {
262 session.foldWidgets[row - 1] = "start";
263 session.foldWidgets[row + 1] = "";
264 return "";
265 }
266 }
267 if (prevIndent != -1 && prevIndent < indent)
268 session.foldWidgets[row - 1] = "start";
269 else
270 session.foldWidgets[row - 1] = "";
271 if (indent < nextIndent)
272 return "start";
273 else
274 return "";
275 };
276 }).call(FoldMode.prototype);
277
278 });
279
280 ace.define("ace/mode/coffee",["require","exports","module","ace/mode/coffee_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/coffee","ace/range","ace/mode/text","ace/worker/worker_client","ace/lib/oop"], function(require, exports, module){"use strict";
281 var Rules = require("./coffee_highlight_rules").CoffeeHighlightRules;
282 var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent;
283 var FoldMode = require("./folding/coffee").FoldMode;
284 var Range = require("../range").Range;
285 var TextMode = require("./text").Mode;
286 var WorkerClient = require("../worker/worker_client").WorkerClient;
287 var oop = require("../lib/oop");
288 function Mode() {
289 this.HighlightRules = Rules;
290 this.$outdent = new Outdent();
291 this.foldingRules = new FoldMode();
292 }
293 oop.inherits(Mode, TextMode);
294 (function () {
295 var indenter = /(?:[({[=:]|[-=]>|\b(?:else|try|(?:swi|ca)tch(?:\s+[$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)?|finally))\s*$|^\s*(else\b\s*)?(?:if|for|while|loop)\b(?!.*\bthen\b)/;
296 this.lineCommentStart = "#";
297 this.blockComment = { start: "###", end: "###" };
298 this.getNextLineIndent = function (state, line, tab) {
299 var indent = this.$getIndent(line);
300 var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
301 if (!(tokens.length && tokens[tokens.length - 1].type === 'comment') &&
302 state === 'start' && indenter.test(line))
303 indent += tab;
304 return indent;
305 };
306 this.checkOutdent = function (state, line, input) {
307 return this.$outdent.checkOutdent(line, input);
308 };
309 this.autoOutdent = function (state, doc, row) {
310 this.$outdent.autoOutdent(doc, row);
311 };
312 this.createWorker = function (session) {
313 var worker = new WorkerClient(["ace"], "ace/mode/coffee_worker", "Worker");
314 worker.attachToDocument(session.getDocument());
315 worker.on("annotate", function (e) {
316 session.setAnnotations(e.data);
317 });
318 worker.on("terminate", function () {
319 session.clearAnnotations();
320 });
321 return worker;
322 };
323 this.$id = "ace/mode/coffee";
324 this.snippetFileId = "ace/snippets/coffee";
325 }).call(Mode.prototype);
326 exports.Mode = Mode;
327
328 }); (function() {
329 ace.require(["ace/mode/coffee"], function(m) {
330 if (typeof module == "object" && typeof exports == "object" && module) {
331 module.exports = m;
332 }
333 });
334 })();
335