mode-dart.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. define("ace/mode/doc_comment_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  2. "use strict";
  3. var oop = ace_require("../lib/oop");
  4. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  5. var DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. };
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. define("ace/mode/c_cpp_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  42. "use strict";
  43. var oop = ace_require("../lib/oop");
  44. var DocCommentHighlightRules = ace_require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  46. var cFunctions = exports.cFunctions = "\\b(?:hypot(?:f|l)?|s(?:scanf|ystem|nprintf|ca(?:nf|lb(?:n(?:f|l)?|ln(?:f|l)?))|i(?:n(?:h(?:f|l)?|f|l)?|gn(?:al|bit))|tr(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?)|error|pbrk|ftime|len|rchr|xfrm)|printf|et(?:jmp|vbuf|locale|buf)|qrt(?:f|l)?|w(?:scanf|printf)|rand)|n(?:e(?:arbyint(?:f|l)?|xt(?:toward(?:f|l)?|after(?:f|l)?))|an(?:f|l)?)|c(?:s(?:in(?:h(?:f|l)?|f|l)?|qrt(?:f|l)?)|cos(?:h(?:f)?|f|l)?|imag(?:f|l)?|t(?:ime|an(?:h(?:f|l)?|f|l)?)|o(?:s(?:h(?:f|l)?|f|l)?|nj(?:f|l)?|pysign(?:f|l)?)|p(?:ow(?:f|l)?|roj(?:f|l)?)|e(?:il(?:f|l)?|xp(?:f|l)?)|l(?:o(?:ck|g(?:f|l)?)|earerr)|a(?:sin(?:h(?:f|l)?|f|l)?|cos(?:h(?:f|l)?|f|l)?|tan(?:h(?:f|l)?|f|l)?|lloc|rg(?:f|l)?|bs(?:f|l)?)|real(?:f|l)?|brt(?:f|l)?)|t(?:ime|o(?:upper|lower)|an(?:h(?:f|l)?|f|l)?|runc(?:f|l)?|gamma(?:f|l)?|mp(?:nam|file))|i(?:s(?:space|n(?:ormal|an)|cntrl|inf|digit|u(?:nordered|pper)|p(?:unct|rint)|finite|w(?:space|c(?:ntrl|type)|digit|upper|p(?:unct|rint)|lower|al(?:num|pha)|graph|xdigit|blank)|l(?:ower|ess(?:equal|greater)?)|al(?:num|pha)|gr(?:eater(?:equal)?|aph)|xdigit|blank)|logb(?:f|l)?|max(?:div|abs))|di(?:v|fftime)|_Exit|unget(?:c|wc)|p(?:ow(?:f|l)?|ut(?:s|c(?:har)?|wc(?:har)?)|error|rintf)|e(?:rf(?:c(?:f|l)?|f|l)?|x(?:it|p(?:2(?:f|l)?|f|l|m1(?:f|l)?)?))|v(?:s(?:scanf|nprintf|canf|printf|w(?:scanf|printf))|printf|f(?:scanf|printf|w(?:scanf|printf))|w(?:scanf|printf)|a_(?:start|copy|end|arg))|qsort|f(?:s(?:canf|e(?:tpos|ek))|close|tell|open|dim(?:f|l)?|p(?:classify|ut(?:s|c|w(?:s|c))|rintf)|e(?:holdexcept|set(?:e(?:nv|xceptflag)|round)|clearexcept|testexcept|of|updateenv|r(?:aiseexcept|ror)|get(?:e(?:nv|xceptflag)|round))|flush|w(?:scanf|ide|printf|rite)|loor(?:f|l)?|abs(?:f|l)?|get(?:s|c|pos|w(?:s|c))|re(?:open|e|ad|xp(?:f|l)?)|m(?:in(?:f|l)?|od(?:f|l)?|a(?:f|l|x(?:f|l)?)?))|l(?:d(?:iv|exp(?:f|l)?)|o(?:ngjmp|cal(?:time|econv)|g(?:1(?:p(?:f|l)?|0(?:f|l)?)|2(?:f|l)?|f|l|b(?:f|l)?)?)|abs|l(?:div|abs|r(?:int(?:f|l)?|ound(?:f|l)?))|r(?:int(?:f|l)?|ound(?:f|l)?)|gamma(?:f|l)?)|w(?:scanf|c(?:s(?:s(?:tr|pn)|nc(?:py|at|mp)|c(?:spn|hr|oll|py|at|mp)|to(?:imax|d|u(?:l(?:l)?|max)|k|f|l(?:d|l)?|mbs)|pbrk|ftime|len|r(?:chr|tombs)|xfrm)|to(?:b|mb)|rtomb)|printf|mem(?:set|c(?:hr|py|mp)|move))|a(?:s(?:sert|ctime|in(?:h(?:f|l)?|f|l)?)|cos(?:h(?:f|l)?|f|l)?|t(?:o(?:i|f|l(?:l)?)|exit|an(?:h(?:f|l)?|2(?:f|l)?|f|l)?)|b(?:s|ort))|g(?:et(?:s|c(?:har)?|env|wc(?:har)?)|mtime)|r(?:int(?:f|l)?|ound(?:f|l)?|e(?:name|alloc|wind|m(?:ove|quo(?:f|l)?|ainder(?:f|l)?))|a(?:nd|ise))|b(?:search|towc)|m(?:odf(?:f|l)?|em(?:set|c(?:hr|py|mp)|move)|ktime|alloc|b(?:s(?:init|towcs|rtowcs)|towc|len|r(?:towc|len))))\\b";
  47. var c_cppHighlightRules = function() {
  48. var keywordControls = (
  49. "break|case|continue|default|do|else|for|goto|if|_Pragma|" +
  50. "return|switch|while|catch|operator|try|throw|using"
  51. );
  52. var storageType = (
  53. "asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
  54. "_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
  55. "class|wchar_t|template|char16_t|char32_t"
  56. );
  57. var storageModifiers = (
  58. "const|extern|register|restrict|static|volatile|inline|private|" +
  59. "protected|public|friend|explicit|virtual|export|mutable|typename|" +
  60. "constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local"
  61. );
  62. var keywordOperators = (
  63. "and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq|" +
  64. "const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace"
  65. );
  66. var builtinConstants = (
  67. "NULL|true|false|TRUE|FALSE|nullptr"
  68. );
  69. var keywordMapper = this.$keywords = this.createKeywordMapper({
  70. "keyword.control" : keywordControls,
  71. "storage.type" : storageType,
  72. "storage.modifier" : storageModifiers,
  73. "keyword.operator" : keywordOperators,
  74. "variable.language": "this",
  75. "constant.language": builtinConstants
  76. }, "identifier");
  77. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  78. var escapeRe = /\\(?:['"?\\abfnrtv]|[0-7]{1,3}|x[a-fA-F\d]{2}|u[a-fA-F\d]{4}U[a-fA-F\d]{8}|.)/.source;
  79. var formatRe = "%"
  80. + /(\d+\$)?/.source // field (argument #)
  81. + /[#0\- +']*/.source // flags
  82. + /[,;:_]?/.source // separator character (AltiVec)
  83. + /((-?\d+)|\*(-?\d+\$)?)?/.source // minimum field width
  84. + /(\.((-?\d+)|\*(-?\d+\$)?)?)?/.source // precision
  85. + /(hh|h|ll|l|j|t|z|q|L|vh|vl|v|hv|hl)?/.source // length modifier
  86. + /(\[[^"\]]+\]|[diouxXDOUeEfFgGaACcSspn%])/.source; // conversion type
  87. this.$rules = {
  88. "start" : [
  89. {
  90. token : "comment",
  91. regex : "//$",
  92. next : "start"
  93. }, {
  94. token : "comment",
  95. regex : "//",
  96. next : "singleLineComment"
  97. },
  98. DocCommentHighlightRules.getStartRule("doc-start"),
  99. {
  100. token : "comment", // multi line comment
  101. regex : "\\/\\*",
  102. next : "comment"
  103. }, {
  104. token : "string", // character
  105. regex : "'(?:" + escapeRe + "|.)?'"
  106. }, {
  107. token : "string.start",
  108. regex : '"',
  109. stateName: "qqstring",
  110. next: [
  111. { token: "string", regex: /\\\s*$/, next: "qqstring" },
  112. { token: "constant.language.escape", regex: escapeRe },
  113. { token: "constant.language.escape", regex: formatRe },
  114. { token: "string.end", regex: '"|$', next: "start" },
  115. { defaultToken: "string"}
  116. ]
  117. }, {
  118. token : "string.start",
  119. regex : 'R"\\(',
  120. stateName: "rawString",
  121. next: [
  122. { token: "string.end", regex: '\\)"', next: "start" },
  123. { defaultToken: "string"}
  124. ]
  125. }, {
  126. token : "constant.numeric", // hex
  127. regex : "0[xX][0-9a-fA-F]+(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  128. }, {
  129. token : "constant.numeric", // float
  130. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
  131. }, {
  132. token : "keyword", // pre-compiler directives
  133. regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
  134. next : "directive"
  135. }, {
  136. token : "keyword", // special case pre-compiler directive
  137. regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
  138. }, {
  139. token : "support.function.C99.c",
  140. regex : cFunctions
  141. }, {
  142. token : keywordMapper,
  143. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*"
  144. }, {
  145. token : "keyword.operator",
  146. regex : /--|\+\+|<<=|>>=|>>>=|<>|&&|\|\||\?:|[*%\/+\-&\^|~!<>=]=?/
  147. }, {
  148. token : "punctuation.operator",
  149. regex : "\\?|\\:|\\,|\\;|\\."
  150. }, {
  151. token : "paren.lparen",
  152. regex : "[[({]"
  153. }, {
  154. token : "paren.rparen",
  155. regex : "[\\])}]"
  156. }, {
  157. token : "text",
  158. regex : "\\s+"
  159. }
  160. ],
  161. "comment" : [
  162. {
  163. token : "comment", // closing comment
  164. regex : "\\*\\/",
  165. next : "start"
  166. }, {
  167. defaultToken : "comment"
  168. }
  169. ],
  170. "singleLineComment" : [
  171. {
  172. token : "comment",
  173. regex : /\\$/,
  174. next : "singleLineComment"
  175. }, {
  176. token : "comment",
  177. regex : /$/,
  178. next : "start"
  179. }, {
  180. defaultToken: "comment"
  181. }
  182. ],
  183. "directive" : [
  184. {
  185. token : "constant.other.multiline",
  186. regex : /\\/
  187. },
  188. {
  189. token : "constant.other.multiline",
  190. regex : /.*\\/
  191. },
  192. {
  193. token : "constant.other",
  194. regex : "\\s*<.+?>",
  195. next : "start"
  196. },
  197. {
  198. token : "constant.other", // single line
  199. regex : '\\s*["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]',
  200. next : "start"
  201. },
  202. {
  203. token : "constant.other", // single line
  204. regex : "\\s*['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']",
  205. next : "start"
  206. },
  207. {
  208. token : "constant.other",
  209. regex : /[^\\\/]+/,
  210. next : "start"
  211. }
  212. ]
  213. };
  214. this.embedRules(DocCommentHighlightRules, "doc-",
  215. [ DocCommentHighlightRules.getEndRule("start") ]);
  216. this.normalizeRules();
  217. };
  218. oop.inherits(c_cppHighlightRules, TextHighlightRules);
  219. exports.c_cppHighlightRules = c_cppHighlightRules;
  220. });
  221. define("ace/mode/matching_brace_outdent",["ace_require","exports","module","ace/range"], function(ace_require, exports, module) {
  222. "use strict";
  223. var Range = ace_require("../range").Range;
  224. var MatchingBraceOutdent = function() {};
  225. (function() {
  226. this.checkOutdent = function(line, input) {
  227. if (! /^\s+$/.test(line))
  228. return false;
  229. return /^\s*\}/.test(input);
  230. };
  231. this.autoOutdent = function(doc, row) {
  232. var line = doc.getLine(row);
  233. var match = line.match(/^(\s*\})/);
  234. if (!match) return 0;
  235. var column = match[1].length;
  236. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  237. if (!openBracePos || openBracePos.row == row) return 0;
  238. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  239. doc.replace(new Range(row, 0, row, column-1), indent);
  240. };
  241. this.$getIndent = function(line) {
  242. return line.match(/^\s*/)[0];
  243. };
  244. }).call(MatchingBraceOutdent.prototype);
  245. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  246. });
  247. define("ace/mode/folding/cstyle",["ace_require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(ace_require, exports, module) {
  248. "use strict";
  249. var oop = ace_require("../../lib/oop");
  250. var Range = ace_require("../../range").Range;
  251. var BaseFoldMode = ace_require("./fold_mode").FoldMode;
  252. var FoldMode = exports.FoldMode = function(commentRegex) {
  253. if (commentRegex) {
  254. this.foldingStartMarker = new RegExp(
  255. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  256. );
  257. this.foldingStopMarker = new RegExp(
  258. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  259. );
  260. }
  261. };
  262. oop.inherits(FoldMode, BaseFoldMode);
  263. (function() {
  264. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  265. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  266. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  267. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  268. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  269. this._getFoldWidgetBase = this.getFoldWidget;
  270. this.getFoldWidget = function(session, foldStyle, row) {
  271. var line = session.getLine(row);
  272. if (this.singleLineBlockCommentRe.test(line)) {
  273. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  274. return "";
  275. }
  276. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  277. if (!fw && this.startRegionRe.test(line))
  278. return "start"; // lineCommentRegionStart
  279. return fw;
  280. };
  281. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  282. var line = session.getLine(row);
  283. if (this.startRegionRe.test(line))
  284. return this.getCommentRegionBlock(session, line, row);
  285. var match = line.match(this.foldingStartMarker);
  286. if (match) {
  287. var i = match.index;
  288. if (match[1])
  289. return this.openingBracketBlock(session, match[1], row, i);
  290. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  291. if (range && !range.isMultiLine()) {
  292. if (forceMultiline) {
  293. range = this.getSectionRange(session, row);
  294. } else if (foldStyle != "all")
  295. range = null;
  296. }
  297. return range;
  298. }
  299. if (foldStyle === "markbegin")
  300. return;
  301. var match = line.match(this.foldingStopMarker);
  302. if (match) {
  303. var i = match.index + match[0].length;
  304. if (match[1])
  305. return this.closingBracketBlock(session, match[1], row, i);
  306. return session.getCommentFoldRange(row, i, -1);
  307. }
  308. };
  309. this.getSectionRange = function(session, row) {
  310. var line = session.getLine(row);
  311. var startIndent = line.search(/\S/);
  312. var startRow = row;
  313. var startColumn = line.length;
  314. row = row + 1;
  315. var endRow = row;
  316. var maxRow = session.getLength();
  317. while (++row < maxRow) {
  318. line = session.getLine(row);
  319. var indent = line.search(/\S/);
  320. if (indent === -1)
  321. continue;
  322. if (startIndent > indent)
  323. break;
  324. var subRange = this.getFoldWidgetRange(session, "all", row);
  325. if (subRange) {
  326. if (subRange.start.row <= startRow) {
  327. break;
  328. } else if (subRange.isMultiLine()) {
  329. row = subRange.end.row;
  330. } else if (startIndent == indent) {
  331. break;
  332. }
  333. }
  334. endRow = row;
  335. }
  336. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  337. };
  338. this.getCommentRegionBlock = function(session, line, row) {
  339. var startColumn = line.search(/\s*$/);
  340. var maxRow = session.getLength();
  341. var startRow = row;
  342. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  343. var depth = 1;
  344. while (++row < maxRow) {
  345. line = session.getLine(row);
  346. var m = re.exec(line);
  347. if (!m) continue;
  348. if (m[1]) depth--;
  349. else depth++;
  350. if (!depth) break;
  351. }
  352. var endRow = row;
  353. if (endRow > startRow) {
  354. return new Range(startRow, startColumn, endRow, line.length);
  355. }
  356. };
  357. }).call(FoldMode.prototype);
  358. });
  359. define("ace/mode/c_cpp",["ace_require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c_cpp_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(ace_require, exports, module) {
  360. "use strict";
  361. var oop = ace_require("../lib/oop");
  362. var TextMode = ace_require("./text").Mode;
  363. var c_cppHighlightRules = ace_require("./c_cpp_highlight_rules").c_cppHighlightRules;
  364. var MatchingBraceOutdent = ace_require("./matching_brace_outdent").MatchingBraceOutdent;
  365. var Range = ace_require("../range").Range;
  366. var CstyleBehaviour = ace_require("./behaviour/cstyle").CstyleBehaviour;
  367. var CStyleFoldMode = ace_require("./folding/cstyle").FoldMode;
  368. var Mode = function() {
  369. this.HighlightRules = c_cppHighlightRules;
  370. this.$outdent = new MatchingBraceOutdent();
  371. this.$behaviour = new CstyleBehaviour();
  372. this.foldingRules = new CStyleFoldMode();
  373. };
  374. oop.inherits(Mode, TextMode);
  375. (function() {
  376. this.lineCommentStart = "//";
  377. this.blockComment = {start: "/*", end: "*/"};
  378. this.getNextLineIndent = function(state, line, tab) {
  379. var indent = this.$getIndent(line);
  380. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  381. var tokens = tokenizedLine.tokens;
  382. var endState = tokenizedLine.state;
  383. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  384. return indent;
  385. }
  386. if (state == "start") {
  387. var match = line.match(/^.*[\{\(\[]\s*$/);
  388. if (match) {
  389. indent += tab;
  390. }
  391. } else if (state == "doc-start") {
  392. if (endState == "start") {
  393. return "";
  394. }
  395. var match = line.match(/^\s*(\/?)\*/);
  396. if (match) {
  397. if (match[1]) {
  398. indent += " ";
  399. }
  400. indent += "* ";
  401. }
  402. }
  403. return indent;
  404. };
  405. this.checkOutdent = function(state, line, input) {
  406. return this.$outdent.checkOutdent(line, input);
  407. };
  408. this.autoOutdent = function(state, doc, row) {
  409. this.$outdent.autoOutdent(doc, row);
  410. };
  411. this.$id = "ace/mode/c_cpp";
  412. this.snippetFileId = "ace/snippets/c_cpp";
  413. }).call(Mode.prototype);
  414. exports.Mode = Mode;
  415. });
  416. define("ace/mode/dart_highlight_rules",["ace_require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(ace_require, exports, module) {
  417. "use strict";
  418. var oop = ace_require("../lib/oop");
  419. var DocCommentHighlightRules = ace_require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  420. var TextHighlightRules = ace_require("./text_highlight_rules").TextHighlightRules;
  421. var DartHighlightRules = function() {
  422. var constantLanguage = "true|false|null";
  423. var variableLanguage = "this|super";
  424. var keywordControl = "try|catch|finally|throw|rethrow|assert|break|case|continue|default|do|else|for|if|in|return|switch|while|new|deferred|async|await";
  425. var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef|with|enum";
  426. var storageModifier = "static|final|const";
  427. var storageType = "void|bool|num|int|double|dynamic|var|String";
  428. var keywordMapper = this.createKeywordMapper({
  429. "constant.language.dart": constantLanguage,
  430. "variable.language.dart": variableLanguage,
  431. "keyword.control.dart": keywordControl,
  432. "keyword.declaration.dart": keywordDeclaration,
  433. "storage.modifier.dart": storageModifier,
  434. "storage.type.primitive.dart": storageType
  435. }, "identifier");
  436. var stringfill = [{
  437. token : "constant.language.escape",
  438. regex : /\\./
  439. }, {
  440. token : "text",
  441. regex : /\$(?:\w+|{[^"'}]+})?/
  442. }, {
  443. defaultToken : "string"
  444. }];
  445. this.$rules = {
  446. "start": [
  447. {
  448. token : "comment",
  449. regex : /\/\/.*$/
  450. },
  451. DocCommentHighlightRules.getStartRule("doc-start"),
  452. {
  453. token : "comment", // multi line comment
  454. regex : /\/\*/,
  455. next : "comment"
  456. },
  457. {
  458. token: ["meta.preprocessor.script.dart"],
  459. regex: "^(#!.*)$"
  460. },
  461. {
  462. token: "keyword.other.import.dart",
  463. regex: "(?:\\b)(?:library|import|export|part|of|show|hide)(?:\\b)"
  464. },
  465. {
  466. token : ["keyword.other.import.dart", "text"],
  467. regex : "(?:\\b)(prefix)(\\s*:)"
  468. },
  469. {
  470. regex: "\\bas\\b",
  471. token: "keyword.cast.dart"
  472. },
  473. {
  474. regex: "\\?|:",
  475. token: "keyword.control.ternary.dart"
  476. },
  477. {
  478. regex: "(?:\\b)(is\\!?)(?:\\b)",
  479. token: ["keyword.operator.dart"]
  480. },
  481. {
  482. regex: "(<<|>>>?|~|\\^|\\||&)",
  483. token: ["keyword.operator.bitwise.dart"]
  484. },
  485. {
  486. regex: "((?:&|\\^|\\||<<|>>>?)=)",
  487. token: ["keyword.operator.assignment.bitwise.dart"]
  488. },
  489. {
  490. regex: "(===?|!==?|<=?|>=?)",
  491. token: ["keyword.operator.comparison.dart"]
  492. },
  493. {
  494. regex: "((?:[+*/%-]|\\~)=)",
  495. token: ["keyword.operator.assignment.arithmetic.dart"]
  496. },
  497. {
  498. regex: "=",
  499. token: "keyword.operator.assignment.dart"
  500. },
  501. {
  502. token : "string",
  503. regex : "'''",
  504. next : "qdoc"
  505. },
  506. {
  507. token : "string",
  508. regex : '"""',
  509. next : "qqdoc"
  510. },
  511. {
  512. token : "string",
  513. regex : "'",
  514. next : "qstring"
  515. },
  516. {
  517. token : "string",
  518. regex : '"',
  519. next : "qqstring"
  520. },
  521. {
  522. regex: "(\\-\\-|\\+\\+)",
  523. token: ["keyword.operator.increment-decrement.dart"]
  524. },
  525. {
  526. regex: "(\\-|\\+|\\*|\\/|\\~\\/|%)",
  527. token: ["keyword.operator.arithmetic.dart"]
  528. },
  529. {
  530. regex: "(!|&&|\\|\\|)",
  531. token: ["keyword.operator.logical.dart"]
  532. },
  533. {
  534. token : "constant.numeric", // hex
  535. regex : "0[xX][0-9a-fA-F]+\\b"
  536. },
  537. {
  538. token : "constant.numeric", // float
  539. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  540. },
  541. {
  542. token : keywordMapper,
  543. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  544. }
  545. ],
  546. "comment" : [
  547. {
  548. token : "comment", // closing comment
  549. regex : "\\*\\/",
  550. next : "start"
  551. }, {
  552. defaultToken : "comment"
  553. }
  554. ],
  555. "qdoc" : [
  556. {
  557. token : "string",
  558. regex : "'''",
  559. next : "start"
  560. }
  561. ].concat(stringfill),
  562. "qqdoc" : [
  563. {
  564. token : "string",
  565. regex : '"""',
  566. next : "start"
  567. }
  568. ].concat(stringfill),
  569. "qstring" : [
  570. {
  571. token : "string",
  572. regex : "'|$",
  573. next : "start"
  574. }
  575. ].concat(stringfill),
  576. "qqstring" : [
  577. {
  578. token : "string",
  579. regex : '"|$',
  580. next : "start"
  581. }
  582. ].concat(stringfill)
  583. };
  584. this.embedRules(DocCommentHighlightRules, "doc-",
  585. [ DocCommentHighlightRules.getEndRule("start") ]);
  586. };
  587. oop.inherits(DartHighlightRules, TextHighlightRules);
  588. exports.DartHighlightRules = DartHighlightRules;
  589. });
  590. define("ace/mode/dart",["ace_require","exports","module","ace/lib/oop","ace/mode/c_cpp","ace/mode/dart_highlight_rules","ace/mode/folding/cstyle"], function(ace_require, exports, module) {
  591. "use strict";
  592. var oop = ace_require("../lib/oop");
  593. var CMode = ace_require("./c_cpp").Mode;
  594. var DartHighlightRules = ace_require("./dart_highlight_rules").DartHighlightRules;
  595. var CStyleFoldMode = ace_require("./folding/cstyle").FoldMode;
  596. var Mode = function() {
  597. CMode.call(this);
  598. this.HighlightRules = DartHighlightRules;
  599. this.foldingRules = new CStyleFoldMode();
  600. };
  601. oop.inherits(Mode, CMode);
  602. (function() {
  603. this.lineCommentStart = "//";
  604. this.blockComment = {start: "/*", end: "*/"};
  605. this.$id = "ace/mode/dart";
  606. this.snippetFileId = "ace/snippets/dart";
  607. }).call(Mode.prototype);
  608. exports.Mode = Mode;
  609. }); (function() {
  610. window.ace_require(["ace/mode/dart"], function(m) {
  611. if (typeof module == "object" && typeof exports == "object" && module) {
  612. module.exports = m;
  613. }
  614. });
  615. })();