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