6d3d6fa2ad6dc7f95a42c9aab746269a.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  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. token: "comment.doc.tag",
  8. regex: "@[\\w\\d_]+" // TODO: fix email addresses
  9. },
  10. DocCommentHighlightRules.getTagRule(),
  11. {
  12. defaultToken: "comment.doc",
  13. caseInsensitive: true
  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",
  27. regex: "\\/\\*(?=\\*)",
  28. next: start
  29. };
  30. };
  31. DocCommentHighlightRules.getEndRule = function (start) {
  32. return {
  33. token: "comment.doc",
  34. regex: "\\*\\/",
  35. next: start
  36. };
  37. };
  38. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  39. });
  40. ace.define("ace/mode/rust_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules","ace/mode/doc_comment_highlight_rules"], function(require, exports, module){/* This file was autogenerated from https://raw.github.com/dbp/sublime-rust/master/Rust.tmLanguage (uuid: ) */
  41. "use strict";
  42. var oop = require("../lib/oop");
  43. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  44. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var stringEscape = /\\(?:[nrt0'"\\]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\})/.source;
  46. var wordPattern = /[a-zA-Z_\xa1-\uffff][a-zA-Z0-9_\xa1-\uffff]*/.source;
  47. var RustHighlightRules = function () {
  48. var keywordMapper = this.createKeywordMapper({
  49. "keyword.source.rust": "abstract|alignof|as|async|await|become|box|break|catch|continue|const|crate|"
  50. + "default|do|dyn|else|enum|extern|for|final|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|"
  51. + "override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|"
  52. + "unsafe|unsized|use|virtual|where|while|yield|try",
  53. "storage.type.source.rust": "Self|isize|usize|char|bool|u8|u16|u32|u64|u128|f16|f32|f64|i8|i16|i32|i64|"
  54. + "i128|str|option|either|c_float|c_double|c_void|FILE|fpos_t|DIR|dirent|c_char|c_schar|c_uchar|c_short|"
  55. + "c_ushort|c_int|c_uint|c_long|c_ulong|size_t|ptrdiff_t|clock_t|time_t|c_longlong|c_ulonglong|intptr_t|"
  56. + "uintptr_t|off_t|dev_t|ino_t|pid_t|mode_t|ssize_t",
  57. "constant.language.source.rust": "true|false|Some|None|Ok|Err|FALSE|TRUE",
  58. "support.constant.source.rust": "EXIT_FAILURE|EXIT_SUCCESS|RAND_MAX|EOF|SEEK_SET|SEEK_CUR|SEEK_END|_IOFBF|"
  59. + "_IONBF|_IOLBF|"
  60. + "BUFSIZ|FOPEN_MAX|FILENAME_MAX|L_tmpnam|TMP_MAX|O_RDONLY|O_WRONLY|O_RDWR|O_APPEND|O_CREAT|O_EXCL|O_TRUNC|"
  61. + "S_IFIFO|S_IFCHR|S_IFBLK|S_IFDIR|S_IFREG|S_IFMT|S_IEXEC|S_IWRITE|S_IREAD|S_IRWXU|S_IXUSR|S_IWUSR|S_IRUSR|"
  62. + "F_OK|R_OK|W_OK|X_OK|STDIN_FILENO|STDOUT_FILENO|STDERR_FILENO",
  63. "constant.language": "macro_rules|mac_variant"
  64. }, "identifier");
  65. this.$rules = {
  66. start: [
  67. {
  68. token: 'variable.other.source.rust',
  69. regex: '\'' + wordPattern + '(?![\\\'])'
  70. }, {
  71. token: 'string.quoted.single.source.rust',
  72. regex: "'(?:[^'\\\\]|" + stringEscape + ")'"
  73. }, {
  74. token: 'identifier',
  75. regex: "r#" + wordPattern + "\\b"
  76. }, {
  77. stateName: "bracketedComment",
  78. onMatch: function (value, currentState, stack) {
  79. stack.unshift(this.next, value.length - 1, currentState);
  80. return "string.quoted.raw.source.rust";
  81. },
  82. regex: /r#*"/,
  83. next: [
  84. {
  85. onMatch: function (value, currentState, stack) {
  86. var token = "string.quoted.raw.source.rust";
  87. if (value.length >= stack[1]) {
  88. if (value.length > stack[1])
  89. token = "invalid";
  90. stack.shift();
  91. stack.shift();
  92. this.next = stack.shift();
  93. }
  94. else {
  95. this.next = "";
  96. }
  97. return token;
  98. },
  99. regex: /"#*/,
  100. next: "start"
  101. }, {
  102. defaultToken: "string.quoted.raw.source.rust"
  103. }
  104. ]
  105. }, {
  106. token: 'string.quoted.double.source.rust',
  107. regex: '"',
  108. push: [
  109. {
  110. token: 'string.quoted.double.source.rust',
  111. regex: '"',
  112. next: 'pop'
  113. }, {
  114. token: 'constant.character.escape.source.rust',
  115. regex: stringEscape
  116. }, { defaultToken: 'string.quoted.double.source.rust' }
  117. ]
  118. }, {
  119. token: ['keyword.source.rust', 'text', 'entity.name.function.source.rust', 'punctuation'],
  120. regex: '\\b(fn)(\\s+)((?:r#)?' + wordPattern + ')(<)',
  121. push: "generics"
  122. }, {
  123. token: ['keyword.source.rust', 'text', 'entity.name.function.source.rust'],
  124. regex: '\\b(fn)(\\s+)((?:r#)?' + wordPattern + ')'
  125. }, {
  126. token: ['support.constant', "punctuation"],
  127. regex: "(" + wordPattern + '::)(<)',
  128. push: "generics"
  129. }, {
  130. token: 'support.constant',
  131. regex: wordPattern + '::'
  132. }, {
  133. token: 'variable.language.source.rust',
  134. regex: '\\bself\\b'
  135. }, DocCommentHighlightRules.getStartRule("doc-start"), {
  136. token: 'comment.line.doc.source.rust',
  137. regex: '///.*$'
  138. }, {
  139. token: 'comment.line.doc.source.rust',
  140. regex: '//!.*$'
  141. }, {
  142. token: 'comment.line.double-dash.source.rust',
  143. regex: '//.*$'
  144. }, {
  145. token: 'comment.start.block.source.rust',
  146. regex: '/\\*',
  147. stateName: 'comment',
  148. push: [
  149. {
  150. token: 'comment.start.block.source.rust',
  151. regex: '/\\*',
  152. push: 'comment'
  153. }, {
  154. token: 'comment.end.block.source.rust',
  155. regex: '\\*/',
  156. next: 'pop'
  157. }, { defaultToken: 'comment.block.source.rust' }
  158. ]
  159. }, {
  160. token: ["keyword.source.rust", "identifier", "punctuaction"],
  161. regex: "(?:(impl)|(" + wordPattern + "))(<)",
  162. stateName: 'generics',
  163. push: [
  164. {
  165. token: "punctuaction",
  166. regex: "<",
  167. push: "generics"
  168. }, {
  169. token: 'variable.other.source.rust',
  170. regex: '\'' + wordPattern + '(?![\\\'])'
  171. }, {
  172. token: "storage.type.source.rust",
  173. regex: "\\b(u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize|char|bool)\\b"
  174. }, {
  175. token: "punctuation.operator",
  176. regex: "[,:]"
  177. }, {
  178. token: "keyword",
  179. regex: "\\b(?:const|dyn)\\b"
  180. }, {
  181. token: "punctuation",
  182. regex: ">",
  183. next: "pop"
  184. }, {
  185. token: "paren.lparen",
  186. regex: "[(]"
  187. }, {
  188. token: "paren.rparen",
  189. regex: "[)]"
  190. }, {
  191. token: "identifier",
  192. regex: "\\b" + wordPattern + "\\b"
  193. }, {
  194. token: 'keyword.operator',
  195. regex: "="
  196. }
  197. ]
  198. }, {
  199. token: keywordMapper,
  200. regex: wordPattern
  201. }, {
  202. token: 'keyword.operator',
  203. regex: /\$|[-=]>|[-+%^=!&|<>]=?|[*/](?![*/])=?/
  204. }, {
  205. token: "punctuation.operator",
  206. regex: /[?:,;.]/
  207. }, {
  208. token: "paren.lparen",
  209. regex: /[\[({]/
  210. }, {
  211. token: "paren.rparen",
  212. regex: /[\])}]/
  213. }, {
  214. token: 'meta.preprocessor.source.rust',
  215. regex: '\\b\\w\\(\\w\\)*!|#\\[[\\w=\\(\\)_]+\\]\\b'
  216. }, {
  217. token: 'constant.numeric.source.rust',
  218. regex: /\b(?:0x[a-fA-F0-9_]+|0o[0-7_]+|0b[01_]+|[0-9][0-9_]*(?!\.))(?:[iu](?:size|8|16|32|64|128))?\b/
  219. }, {
  220. token: 'constant.numeric.source.rust',
  221. regex: /\b(?:[0-9][0-9_]*)(?:\.[0-9][0-9_]*)?(?:[Ee][+-][0-9][0-9_]*)?(?:f32|f64)?\b/
  222. }
  223. ]
  224. };
  225. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  226. this.normalizeRules();
  227. };
  228. RustHighlightRules.metaData = { fileTypes: ['rs', 'rc'],
  229. foldingStartMarker: '^.*\\bfn\\s*(\\w+\\s*)?\\([^\\)]*\\)(\\s*\\{[^\\}]*)?\\s*$',
  230. foldingStopMarker: '^\\s*\\}',
  231. name: 'Rust',
  232. scopeName: 'source.rust' };
  233. oop.inherits(RustHighlightRules, TextHighlightRules);
  234. exports.RustHighlightRules = RustHighlightRules;
  235. });
  236. 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";
  237. var oop = require("../../lib/oop");
  238. var Range = require("../../range").Range;
  239. var BaseFoldMode = require("./fold_mode").FoldMode;
  240. var FoldMode = exports.FoldMode = function (commentRegex) {
  241. if (commentRegex) {
  242. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  243. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  244. }
  245. };
  246. oop.inherits(FoldMode, BaseFoldMode);
  247. (function () {
  248. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  249. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  250. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  251. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  252. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  253. this._getFoldWidgetBase = this.getFoldWidget;
  254. this.getFoldWidget = function (session, foldStyle, row) {
  255. var line = session.getLine(row);
  256. if (this.singleLineBlockCommentRe.test(line)) {
  257. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  258. return "";
  259. }
  260. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  261. if (!fw && this.startRegionRe.test(line))
  262. return "start"; // lineCommentRegionStart
  263. return fw;
  264. };
  265. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  266. var line = session.getLine(row);
  267. if (this.startRegionRe.test(line))
  268. return this.getCommentRegionBlock(session, line, row);
  269. var match = line.match(this.foldingStartMarker);
  270. if (match) {
  271. var i = match.index;
  272. if (match[1])
  273. return this.openingBracketBlock(session, match[1], row, i);
  274. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  275. if (range && !range.isMultiLine()) {
  276. if (forceMultiline) {
  277. range = this.getSectionRange(session, row);
  278. }
  279. else if (foldStyle != "all")
  280. range = null;
  281. }
  282. return range;
  283. }
  284. if (foldStyle === "markbegin")
  285. return;
  286. var match = line.match(this.foldingStopMarker);
  287. if (match) {
  288. var i = match.index + match[0].length;
  289. if (match[1])
  290. return this.closingBracketBlock(session, match[1], row, i);
  291. return session.getCommentFoldRange(row, i, -1);
  292. }
  293. };
  294. this.getSectionRange = function (session, row) {
  295. var line = session.getLine(row);
  296. var startIndent = line.search(/\S/);
  297. var startRow = row;
  298. var startColumn = line.length;
  299. row = row + 1;
  300. var endRow = row;
  301. var maxRow = session.getLength();
  302. while (++row < maxRow) {
  303. line = session.getLine(row);
  304. var indent = line.search(/\S/);
  305. if (indent === -1)
  306. continue;
  307. if (startIndent > indent)
  308. break;
  309. var subRange = this.getFoldWidgetRange(session, "all", row);
  310. if (subRange) {
  311. if (subRange.start.row <= startRow) {
  312. break;
  313. }
  314. else if (subRange.isMultiLine()) {
  315. row = subRange.end.row;
  316. }
  317. else if (startIndent == indent) {
  318. break;
  319. }
  320. }
  321. endRow = row;
  322. }
  323. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  324. };
  325. this.getCommentRegionBlock = function (session, line, row) {
  326. var startColumn = line.search(/\s*$/);
  327. var maxRow = session.getLength();
  328. var startRow = row;
  329. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  330. var depth = 1;
  331. while (++row < maxRow) {
  332. line = session.getLine(row);
  333. var m = re.exec(line);
  334. if (!m)
  335. continue;
  336. if (m[1])
  337. depth--;
  338. else
  339. depth++;
  340. if (!depth)
  341. break;
  342. }
  343. var endRow = row;
  344. if (endRow > startRow) {
  345. return new Range(startRow, startColumn, endRow, line.length);
  346. }
  347. };
  348. }).call(FoldMode.prototype);
  349. });
  350. ace.define("ace/mode/rust",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/rust_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){/*
  351. THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
  352. */
  353. "use strict";
  354. var oop = require("../lib/oop");
  355. var TextMode = require("./text").Mode;
  356. var RustHighlightRules = require("./rust_highlight_rules").RustHighlightRules;
  357. var FoldMode = require("./folding/cstyle").FoldMode;
  358. var Mode = function () {
  359. this.HighlightRules = RustHighlightRules;
  360. this.foldingRules = new FoldMode();
  361. this.$behaviour = this.$defaultBehaviour;
  362. };
  363. oop.inherits(Mode, TextMode);
  364. (function () {
  365. this.lineCommentStart = "//";
  366. this.blockComment = { start: "/*", end: "*/", nestable: true };
  367. this.$quotes = { '"': '"' };
  368. this.$id = "ace/mode/rust";
  369. }).call(Mode.prototype);
  370. exports.Mode = Mode;
  371. }); (function() {
  372. ace.require(["ace/mode/rust"], function(m) {
  373. if (typeof module == "object" && typeof exports == "object" && module) {
  374. module.exports = m;
  375. }
  376. });
  377. })();