Debian Codegraph @

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

raw symbols SCIP
1 ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function () {
5 this.$rules = {
6 "start": [
7 {
8 token: "comment.doc.tag",
9 regex: "@\\w+(?=\\s|$)"
10 }, DocCommentHighlightRules.getTagRule(), {
11 defaultToken: "comment.doc",
12 caseInsensitive: true
13 }
14 ]
15 };
16 };
17 oop.inherits(DocCommentHighlightRules, TextHighlightRules);
18 DocCommentHighlightRules.getTagRule = function (start) {
19 return {
20 token: "comment.doc.tag.storage.type",
21 regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
22 };
23 };
24 DocCommentHighlightRules.getStartRule = function (start) {
25 return {
26 token: "comment.doc", // doc comment
27 regex: "\\/\\*(?=\\*)",
28 next: start
29 };
30 };
31 DocCommentHighlightRules.getEndRule = function (start) {
32 return {
33 token: "comment.doc", // closing comment
34 regex: "\\*\\/",
35 next: start
36 };
37 };
38 exports.DocCommentHighlightRules = DocCommentHighlightRules;
39
40 });
41
42 ace.define("ace/mode/haxe_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
43 var oop = require("../lib/oop");
44 var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
45 var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
46 var HaxeHighlightRules = function () {
47 var keywords = ("break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std");
48 var buildinConstants = ("null|true|false");
49 var keywordMapper = this.createKeywordMapper({
50 "variable.language": "this",
51 "keyword": keywords,
52 "constant.language": buildinConstants
53 }, "identifier");
54 this.$rules = {
55 "start": [
56 {
57 token: "comment",
58 regex: "\\/\\/.*$"
59 },
60 DocCommentHighlightRules.getStartRule("doc-start"),
61 {
62 token: "comment", // multi line comment
63 regex: "\\/\\*",
64 next: "comment"
65 }, {
66 token: "string.regexp",
67 regex: "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
68 }, {
69 token: "string", // single line
70 regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
71 }, {
72 token: "string", // single line
73 regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
74 }, {
75 token: "constant.numeric", // hex
76 regex: "0[xX][0-9a-fA-F]+\\b"
77 }, {
78 token: "constant.numeric", // float
79 regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
80 }, {
81 token: "constant.language.boolean",
82 regex: "(?:true|false)\\b"
83 }, {
84 token: keywordMapper,
85 regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
86 }, {
87 token: "keyword.operator",
88 regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
89 }, {
90 token: "punctuation.operator",
91 regex: "\\?|\\:|\\,|\\;|\\."
92 }, {
93 token: "paren.lparen",
94 regex: "[[({<]"
95 }, {
96 token: "paren.rparen",
97 regex: "[\\])}>]"
98 }, {
99 token: "text",
100 regex: "\\s+"
101 }
102 ],
103 "comment": [
104 {
105 token: "comment", // closing comment
106 regex: "\\*\\/",
107 next: "start"
108 }, {
109 defaultToken: "comment"
110 }
111 ]
112 };
113 this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
114 };
115 oop.inherits(HaxeHighlightRules, TextHighlightRules);
116 exports.HaxeHighlightRules = HaxeHighlightRules;
117
118 });
119
120 ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
121 var Range = require("../range").Range;
122 var MatchingBraceOutdent = function () { };
123 (function () {
124 this.checkOutdent = function (line, input) {
125 if (!/^\s+$/.test(line))
126 return false;
127 return /^\s*\}/.test(input);
128 };
129 this.autoOutdent = function (doc, row) {
130 var line = doc.getLine(row);
131 var match = line.match(/^(\s*\})/);
132 if (!match)
133 return 0;
134 var column = match[1].length;
135 var openBracePos = doc.findMatchingBracket({ row: row, column: column });
136 if (!openBracePos || openBracePos.row == row)
137 return 0;
138 var indent = this.$getIndent(doc.getLine(openBracePos.row));
139 doc.replace(new Range(row, 0, row, column - 1), indent);
140 };
141 this.$getIndent = function (line) {
142 return line.match(/^\s*/)[0];
143 };
144 }).call(MatchingBraceOutdent.prototype);
145 exports.MatchingBraceOutdent = MatchingBraceOutdent;
146
147 });
148
149 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";
150 var oop = require("../../lib/oop");
151 var Range = require("../../range").Range;
152 var BaseFoldMode = require("./fold_mode").FoldMode;
153 var FoldMode = exports.FoldMode = function (commentRegex) {
154 if (commentRegex) {
155 this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
156 this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
157 }
158 };
159 oop.inherits(FoldMode, BaseFoldMode);
160 (function () {
161 this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
162 this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
163 this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
164 this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
165 this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
166 this._getFoldWidgetBase = this.getFoldWidget;
167 this.getFoldWidget = function (session, foldStyle, row) {
168 var line = session.getLine(row);
169 if (this.singleLineBlockCommentRe.test(line)) {
170 if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
171 return "";
172 }
173 var fw = this._getFoldWidgetBase(session, foldStyle, row);
174 if (!fw && this.startRegionRe.test(line))
175 return "start"; // lineCommentRegionStart
176 return fw;
177 };
178 this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
179 var line = session.getLine(row);
180 if (this.startRegionRe.test(line))
181 return this.getCommentRegionBlock(session, line, row);
182 var match = line.match(this.foldingStartMarker);
183 if (match) {
184 var i = match.index;
185 if (match[1])
186 return this.openingBracketBlock(session, match[1], row, i);
187 var range = session.getCommentFoldRange(row, i + match[0].length, 1);
188 if (range && !range.isMultiLine()) {
189 if (forceMultiline) {
190 range = this.getSectionRange(session, row);
191 }
192 else if (foldStyle != "all")
193 range = null;
194 }
195 return range;
196 }
197 if (foldStyle === "markbegin")
198 return;
199 var match = line.match(this.foldingStopMarker);
200 if (match) {
201 var i = match.index + match[0].length;
202 if (match[1])
203 return this.closingBracketBlock(session, match[1], row, i);
204 return session.getCommentFoldRange(row, i, -1);
205 }
206 };
207 this.getSectionRange = function (session, row) {
208 var line = session.getLine(row);
209 var startIndent = line.search(/\S/);
210 var startRow = row;
211 var startColumn = line.length;
212 row = row + 1;
213 var endRow = row;
214 var maxRow = session.getLength();
215 while (++row < maxRow) {
216 line = session.getLine(row);
217 var indent = line.search(/\S/);
218 if (indent === -1)
219 continue;
220 if (startIndent > indent)
221 break;
222 var subRange = this.getFoldWidgetRange(session, "all", row);
223 if (subRange) {
224 if (subRange.start.row <= startRow) {
225 break;
226 }
227 else if (subRange.isMultiLine()) {
228 row = subRange.end.row;
229 }
230 else if (startIndent == indent) {
231 break;
232 }
233 }
234 endRow = row;
235 }
236 return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
237 };
238 this.getCommentRegionBlock = function (session, line, row) {
239 var startColumn = line.search(/\s*$/);
240 var maxRow = session.getLength();
241 var startRow = row;
242 var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
243 var depth = 1;
244 while (++row < maxRow) {
245 line = session.getLine(row);
246 var m = re.exec(line);
247 if (!m)
248 continue;
249 if (m[1])
250 depth--;
251 else
252 depth++;
253 if (!depth)
254 break;
255 }
256 var endRow = row;
257 if (endRow > startRow) {
258 return new Range(startRow, startColumn, endRow, line.length);
259 }
260 };
261 }).call(FoldMode.prototype);
262
263 });
264
265 ace.define("ace/mode/haxe",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/haxe_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
266 var oop = require("../lib/oop");
267 var TextMode = require("./text").Mode;
268 var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules;
269 var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
270 var CStyleFoldMode = require("./folding/cstyle").FoldMode;
271 var Mode = function () {
272 this.HighlightRules = HaxeHighlightRules;
273 this.$outdent = new MatchingBraceOutdent();
274 this.$behaviour = this.$defaultBehaviour;
275 this.foldingRules = new CStyleFoldMode();
276 };
277 oop.inherits(Mode, TextMode);
278 (function () {
279 this.lineCommentStart = "//";
280 this.blockComment = { start: "/*", end: "*/" };
281 this.getNextLineIndent = function (state, line, tab) {
282 var indent = this.$getIndent(line);
283 var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
284 var tokens = tokenizedLine.tokens;
285 if (tokens.length && tokens[tokens.length - 1].type == "comment") {
286 return indent;
287 }
288 if (state == "start") {
289 var match = line.match(/^.*[\{\(\[]\s*$/);
290 if (match) {
291 indent += tab;
292 }
293 }
294 return indent;
295 };
296 this.checkOutdent = function (state, line, input) {
297 return this.$outdent.checkOutdent(line, input);
298 };
299 this.autoOutdent = function (state, doc, row) {
300 this.$outdent.autoOutdent(doc, row);
301 };
302 this.$id = "ace/mode/haxe";
303 }).call(Mode.prototype);
304 exports.Mode = Mode;
305
306 }); (function() {
307 ace.require(["ace/mode/haxe"], function(m) {
308 if (typeof module == "object" && typeof exports == "object" && module) {
309 module.exports = m;
310 }
311 });
312 })();
313