| 1 |
ace.define("ace/mode/zig_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 ZigHighlightRules = function () { |
| 5 |
this.$rules = { |
| 6 |
start: [{ |
| 7 |
include: "#dummy_main" |
| 8 |
}], |
| 9 |
"#block": [{ |
| 10 |
token: [ |
| 11 |
"storage.type.zig", |
| 12 |
"text", |
| 13 |
"punctuation.section.braces.begin.zig" |
| 14 |
], |
| 15 |
regex: /((?:[a-zA-Z_][\w.]*|@\".+\")?)(\s*)(\{)/, |
| 16 |
push: [{ |
| 17 |
token: "punctuation.section.braces.end.zig", |
| 18 |
regex: /\}/, |
| 19 |
next: "pop" |
| 20 |
}, { |
| 21 |
include: "#dummy_main" |
| 22 |
}] |
| 23 |
}], |
| 24 |
"#character_escapes": [{ |
| 25 |
token: "constant.character.escape.newline.zig", |
| 26 |
regex: /\\n/ |
| 27 |
}, { |
| 28 |
token: "constant.character.escape.carrigereturn.zig", |
| 29 |
regex: /\\r/ |
| 30 |
}, { |
| 31 |
token: "constant.character.escape.tabulator.zig", |
| 32 |
regex: /\\t/ |
| 33 |
}, { |
| 34 |
token: "constant.character.escape.backslash.zig", |
| 35 |
regex: /\\\\/ |
| 36 |
}, { |
| 37 |
token: "constant.character.escape.single-quote.zig", |
| 38 |
regex: /\\'/ |
| 39 |
}, { |
| 40 |
token: "constant.character.escape.double-quote.zig", |
| 41 |
regex: /\\\"/ |
| 42 |
}, { |
| 43 |
token: "constant.character.escape.hexidecimal.zig", |
| 44 |
regex: /\\x[a-fA-F\d]{2}/ |
| 45 |
}, { |
| 46 |
token: "constant.character.escape.hexidecimal.zig", |
| 47 |
regex: /\\u\{[a-fA-F\d]{1,6}\}/ |
| 48 |
}], |
| 49 |
"#comments": [{ |
| 50 |
token: "comment.line.documentation.zig", |
| 51 |
regex: /\/\/[!\/](?=[^\/])/, |
| 52 |
push: [{ |
| 53 |
token: "comment.line.documentation.zig", |
| 54 |
regex: /$/, |
| 55 |
next: "pop" |
| 56 |
}, { |
| 57 |
include: "#commentContents" |
| 58 |
}, { |
| 59 |
defaultToken: "comment.line.documentation.zig" |
| 60 |
}] |
| 61 |
}, { |
| 62 |
token: "comment.line.double-slash.zig", |
| 63 |
regex: /\/\//, |
| 64 |
push: [{ |
| 65 |
token: "comment.line.double-slash.zig", |
| 66 |
regex: /$/, |
| 67 |
next: "pop" |
| 68 |
}, { |
| 69 |
include: "#commentContents" |
| 70 |
}, { |
| 71 |
defaultToken: "comment.line.double-slash.zig" |
| 72 |
}] |
| 73 |
}], |
| 74 |
"#commentContents": [{ |
| 75 |
token: "keyword.todo.zig", |
| 76 |
regex: /\b(?:TODO|FIXME|XXX|NOTE)\b:?/ |
| 77 |
}], |
| 78 |
"#constants": [{ |
| 79 |
token: "constant.language.zig", |
| 80 |
regex: /\b(?:null|undefined|true|false)\b/ |
| 81 |
}, { |
| 82 |
token: "constant.numeric.integer.zig", |
| 83 |
regex: /\b(?!\.)-?[\d_]+(?!\.)\b/ |
| 84 |
}, { |
| 85 |
token: "constant.numeric.integer.hexadecimal.zig", |
| 86 |
regex: /\b(?!\.)0x[a-fA-F\d_]+(?!\.)\b/ |
| 87 |
}, { |
| 88 |
token: "constant.numeric.integer.octal.zig", |
| 89 |
regex: /\b(?!\.)0o[0-7_]+(?!\.)\b/ |
| 90 |
}, { |
| 91 |
token: "constant.numeric.integer.binary.zig", |
| 92 |
regex: /\b(?!\.)0b[01_]+(?!\.)\b/ |
| 93 |
}, { |
| 94 |
token: "constant.numeric.float.zig", |
| 95 |
regex: /(?!\.)-?\b[\d_]+(?:\.[\d_]+)?(?:[eE][+-]?[\d_]+)?(?!\.)\b/ |
| 96 |
}, { |
| 97 |
token: "constant.numeric.float.hexadecimal.zig", |
| 98 |
regex: /(?!\.)-?\b0x[a-fA-F\d_]+(?:\.[a-fA-F\d_]+)?[pP]?(?:[+-]?[\d_]+)?(?!\.)\b/ |
| 99 |
}], |
| 100 |
"#container_decl": [{ |
| 101 |
token: "entity.name.union.zig", |
| 102 |
regex: /\b(?!\d)(?:[a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*union\s*[(\{])/ |
| 103 |
}, { |
| 104 |
token: "entity.name.struct.zig", |
| 105 |
regex: /\b(?!\d)(?:[a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*struct\s*[(\{])/ |
| 106 |
}, { |
| 107 |
token: "entity.name.enum.zig", |
| 108 |
regex: /\b(?!\d)(?:[a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*(?:extern|packed)?\b\s*enum\s*[(\{])/ |
| 109 |
}, { |
| 110 |
token: "entity.name.error.zig", |
| 111 |
regex: /\b(?!\d)(?:[a-zA-Z_]\w*|@\".+\")?(?=\s*=\s*error\s*[(\{])/ |
| 112 |
}, { |
| 113 |
token: [ |
| 114 |
"storage.type.error.zig", |
| 115 |
"punctuation.accessor.zig", |
| 116 |
"entity.name.error.zig" |
| 117 |
], |
| 118 |
regex: /\b(error)(\.)([a-zA-Z_]\w*|@\".+\")/ |
| 119 |
}], |
| 120 |
"#dummy_main": [{ |
| 121 |
include: "#label" |
| 122 |
}, { |
| 123 |
include: "#function_type" |
| 124 |
}, { |
| 125 |
include: "#function_def" |
| 126 |
}, { |
| 127 |
include: "#punctuation" |
| 128 |
}, { |
| 129 |
include: "#storage_modifier" |
| 130 |
}, { |
| 131 |
include: "#container_decl" |
| 132 |
}, { |
| 133 |
include: "#constants" |
| 134 |
}, { |
| 135 |
include: "#comments" |
| 136 |
}, { |
| 137 |
include: "#strings" |
| 138 |
}, { |
| 139 |
include: "#storage" |
| 140 |
}, { |
| 141 |
include: "#keywords" |
| 142 |
}, { |
| 143 |
include: "#operators" |
| 144 |
}, { |
| 145 |
include: "#support" |
| 146 |
}, { |
| 147 |
include: "#field_decl" |
| 148 |
}, { |
| 149 |
include: "#block" |
| 150 |
}, { |
| 151 |
include: "#function_call" |
| 152 |
}, { |
| 153 |
include: "#enum_literal" |
| 154 |
}, { |
| 155 |
include: "#variables" |
| 156 |
}], |
| 157 |
"#enum_literal": [{ |
| 158 |
token: "constant.language.enum", |
| 159 |
regex: /(?!\w|\)|\?|\}|\]|\*|\.)\.(?:[a-zA-Z_]\w*\b|@\"[^\"]*\")(?!\(|\s*=[^=>])/ |
| 160 |
}], |
| 161 |
"#field_decl": [{ |
| 162 |
token: [ |
| 163 |
"variable.other.member.zig", |
| 164 |
"text", |
| 165 |
"punctuation.separator.zig", |
| 166 |
"text" |
| 167 |
], |
| 168 |
regex: /([a-zA-Z_]\w*|@\".+\")(\s*)(:)(\s*)/, |
| 169 |
push: [{ |
| 170 |
token: [ |
| 171 |
"storage.type.zig", |
| 172 |
"text", |
| 173 |
"punctuation.separator.zig", |
| 174 |
"keyword.operator.assignment.zig" |
| 175 |
], |
| 176 |
regex: /((?:[a-zA-Z_][\w.]*|@\".+\")?)(\s*)(?:(,)|(=)|$)/, |
| 177 |
next: "pop" |
| 178 |
}, { |
| 179 |
include: "#dummy_main" |
| 180 |
}] |
| 181 |
}], |
| 182 |
"#function_call": [{ |
| 183 |
token: "variable.function.zig", |
| 184 |
regex: /\b(?!fn)(?:[a-zA-Z_]\w*|@\".+\")(?=\s*\()/ |
| 185 |
}], |
| 186 |
"#keywords": [{ |
| 187 |
token: "keyword.control.zig", |
| 188 |
regex: /\b(?:while|for|break|return|continue|asm|defer|errdefer|unreachable)\b/ |
| 189 |
}, { |
| 190 |
token: "keyword.control.async.zig", |
| 191 |
regex: /\b(?:async|await|suspend|nosuspend|resume)\b/ |
| 192 |
}, { |
| 193 |
token: "keyword.control.conditional.zig", |
| 194 |
regex: /\b(?:if|else|switch|try|catch|orelse)\b/ |
| 195 |
}, { |
| 196 |
token: "keyword.control.import.zig", |
| 197 |
regex: /\b(?!\w)(?:@import|@cImport|@cInclude)\b/ |
| 198 |
}, { |
| 199 |
token: "keyword.other.usingnamespace.zig", |
| 200 |
regex: /\busingnamespace\b/ |
| 201 |
}], |
| 202 |
"#label": [{ |
| 203 |
token: [ |
| 204 |
"keyword.control.zig", |
| 205 |
"text", |
| 206 |
"entity.name.label.zig", |
| 207 |
"entity.name.label.zig" |
| 208 |
], |
| 209 |
regex: /\b(break|continue)(\s*:\s*)([a-zA-Z_]\w*|@\".+\")\b|\b(?!\d)([a-zA-Z_]\w*|@\".+\")\b(?=\s*:\s*(?:\{|while\b))/ |
| 210 |
}], |
| 211 |
"#operators": [{ |
| 212 |
token: "keyword.operator.zig", |
| 213 |
regex: /\b!\b/ |
| 214 |
}, { |
| 215 |
token: "keyword.operator.logical.zig", |
| 216 |
regex: /==|(?:!|>|<)=?/ |
| 217 |
}, { |
| 218 |
token: "keyword.operator.word.zig", |
| 219 |
regex: /\b(?:and|or)\b/ |
| 220 |
}, { |
| 221 |
token: "keyword.operator.assignment.zig", |
| 222 |
regex: /(?:(?:\+|-|\*)\%?|\/|%|<<|>>|&|\|(?=[^\|])|\^)?=/ |
| 223 |
}, { |
| 224 |
token: "keyword.operator.arithmetic.zig", |
| 225 |
regex: /(?:\+|-|\*)\%?|\/(?!\/)|%/ |
| 226 |
}, { |
| 227 |
token: "keyword.operator.bitwise.zig", |
| 228 |
regex: /<<|>>|&(?=[a-zA-Z_]|@\")|\|(?=[^\|])|\^|~/ |
| 229 |
}, { |
| 230 |
token: "keyword.operator.other.zig", |
| 231 |
regex: /\+\+|\*\*|->|\.\?|\.\*|&(?=[a-zA-Z_]|@\")|\?|\|\||\.{2,3}/ |
| 232 |
}], |
| 233 |
"#param_list": [{ |
| 234 |
token: [ |
| 235 |
"variable.parameter.zig", |
| 236 |
"text", |
| 237 |
"punctuation.separator.zig", |
| 238 |
"text" |
| 239 |
], |
| 240 |
regex: /([a-zA-Z_]\w*|@\".+\")(\s*)(:)(\s*)/, |
| 241 |
push: [{ |
| 242 |
token: [ |
| 243 |
"storage.type.zig", |
| 244 |
"text", |
| 245 |
"punctuation.separator.zig", |
| 246 |
"punctuation.section.parens.end.zig" |
| 247 |
], |
| 248 |
regex: /((?:[a-zA-Z_][\w.]*|@\".+\")?)(\s*)(?:(,)|(\)))/, |
| 249 |
next: "pop" |
| 250 |
}, { |
| 251 |
include: "#dummy_main" |
| 252 |
}, { |
| 253 |
token: "storage.type.zig", |
| 254 |
regex: /[a-zA-Z_][\w.]*|@\".+\"/ |
| 255 |
}] |
| 256 |
}], |
| 257 |
"#punctuation": [{ |
| 258 |
token: "punctuation.separator.zig", |
| 259 |
regex: /,/ |
| 260 |
}, { |
| 261 |
token: "punctuation.terminator.zig", |
| 262 |
regex: /;/ |
| 263 |
}, { |
| 264 |
token: "punctuation.section.parens.begin.zig", |
| 265 |
regex: /\(/ |
| 266 |
}, { |
| 267 |
token: "punctuation.section.parens.end.zig", |
| 268 |
regex: /\)/ |
| 269 |
}], |
| 270 |
"#storage": [{ |
| 271 |
token: "storage.type.zig", |
| 272 |
regex: /\b(?:bool|void|noreturn|type|anyerror|anytype)\b/ |
| 273 |
}, { |
| 274 |
token: "storage.type.integer.zig", |
| 275 |
regex: /\b(?!\.)(?:[iu]\d+|[iu]size|comptime_int)\b/ |
| 276 |
}, { |
| 277 |
token: "storage.type.float.zig", |
| 278 |
regex: /\b(?:f16|f32|f64|f128|comptime_float)\b/ |
| 279 |
}, { |
| 280 |
token: "storage.type.c_compat.zig", |
| 281 |
regex: /\b(?:c_short|c_ushort|c_int|c_uint|c_long|c_ulong|c_longlong|c_ulonglong|c_longdouble|c_void)\b/ |
| 282 |
}, { |
| 283 |
token: [ |
| 284 |
"storage.type.zig", |
| 285 |
"text", |
| 286 |
"keyword.operator.zig", |
| 287 |
"text", |
| 288 |
"storage.type.zig" |
| 289 |
], |
| 290 |
regex: /\b(anyframe)\b(\s*)((?:->)?)(\s*)(?:([a-zA-Z_][\w.]*|@\".+\")\b(?!\s*\())?/ |
| 291 |
}, { |
| 292 |
token: "storage.type.function.zig", |
| 293 |
regex: /\bfn\b/ |
| 294 |
}, { |
| 295 |
token: "storage.type.test.zig", |
| 296 |
regex: /\btest\b/ |
| 297 |
}, { |
| 298 |
token: "storage.type.struct.zig", |
| 299 |
regex: /\bstruct\b/ |
| 300 |
}, { |
| 301 |
token: "storage.type.enum.zig", |
| 302 |
regex: /\benum\b/ |
| 303 |
}, { |
| 304 |
token: "storage.type.union.zig", |
| 305 |
regex: /\bunion\b/ |
| 306 |
}, { |
| 307 |
token: "storage.type.error.zig", |
| 308 |
regex: /\berror\b/ |
| 309 |
}], |
| 310 |
"#storage_modifier": [{ |
| 311 |
token: "storage.modifier.zig", |
| 312 |
regex: /\b(?:const|var|extern|packed|export|pub|noalias|inline|noinline|comptime|volatile|align|linksection|threadlocal|allowzero)\b/ |
| 313 |
}], |
| 314 |
"#strings": [{ |
| 315 |
token: "string.quoted.single.zig", |
| 316 |
regex: /\'/, |
| 317 |
push: [{ |
| 318 |
token: "string.quoted.single.zig", |
| 319 |
regex: /\'/, |
| 320 |
next: "pop" |
| 321 |
}, { |
| 322 |
include: "#character_escapes" |
| 323 |
}, { |
| 324 |
token: "invalid.illegal.character.zig", |
| 325 |
regex: /\\[^\'][^\']*?/ |
| 326 |
}, { |
| 327 |
defaultToken: "string.quoted.single.zig" |
| 328 |
}] |
| 329 |
}, { |
| 330 |
token: "string.quoted.double.zig", |
| 331 |
regex: /c?\"/, |
| 332 |
push: [{ |
| 333 |
token: "string.quoted.double.zig", |
| 334 |
regex: /\"/, |
| 335 |
next: "pop" |
| 336 |
}, { |
| 337 |
include: "#character_escapes" |
| 338 |
}, { |
| 339 |
token: "invalid.illegal.character.zig", |
| 340 |
regex: /\\[^\'][^\']*?/ |
| 341 |
}, { |
| 342 |
defaultToken: "string.quoted.double.zig" |
| 343 |
}] |
| 344 |
}, { |
| 345 |
token: "string.quoted.other.zig", |
| 346 |
regex: /c?\\\\/, |
| 347 |
push: [{ |
| 348 |
token: "string.quoted.other.zig", |
| 349 |
regex: /$/, |
| 350 |
next: "pop" |
| 351 |
}, { |
| 352 |
defaultToken: "string.quoted.other.zig" |
| 353 |
}] |
| 354 |
}], |
| 355 |
"#function_type": [{ |
| 356 |
token: [ |
| 357 |
"storage.type.function.zig", |
| 358 |
"text", |
| 359 |
"punctuation.section.parens.begin.zig" |
| 360 |
], |
| 361 |
regex: /\b(fn)(\s*)(\()/, |
| 362 |
push: [{ |
| 363 |
token: [ |
| 364 |
"text", |
| 365 |
"storage.type.zig", |
| 366 |
"text", |
| 367 |
"keyword.operator.zig", |
| 368 |
"text", |
| 369 |
"storage.type.zig" |
| 370 |
], |
| 371 |
regex: /(\s*)(?:([a-zA-Z_]\w*|@\".+\"))?(\s*)((?:!)?)(\s*)([a-zA-Z_]\w*|@\".+\")/, |
| 372 |
next: "pop" |
| 373 |
}, { |
| 374 |
include: "#label" |
| 375 |
}, { |
| 376 |
include: "#param_list" |
| 377 |
}, { |
| 378 |
token: "storage.type.zig", |
| 379 |
regex: /[a-zA-Z_]\w*|@\".+\"/ |
| 380 |
}, { |
| 381 |
include: "#dummy_main" |
| 382 |
}, { |
| 383 |
defaultToken: "meta.function.parameters.zig" |
| 384 |
}] |
| 385 |
}], |
| 386 |
"#function_def": [{ |
| 387 |
token: [ |
| 388 |
"text", |
| 389 |
"entity.name.function", |
| 390 |
"punctuation.section.parens.begin.zig" |
| 391 |
], |
| 392 |
regex: /(?=fn\s+)(\s+)([a-zA-Z_]\w*|@\".+\")(\()/, |
| 393 |
push: [{ |
| 394 |
token: [ |
| 395 |
"text", |
| 396 |
"storage.type.zig", |
| 397 |
"keyword.operator.zig", |
| 398 |
"text", |
| 399 |
"storage.type.zig" |
| 400 |
], |
| 401 |
regex: /(\s*)((?:[a-zA-Z_][\w.]*|@\".+\")?)((?:!)?)(\s*)(?:([a-zA-Z_][\w.]*|@\".+\")?)/, |
| 402 |
next: "pop" |
| 403 |
}, { |
| 404 |
include: "#label" |
| 405 |
}, { |
| 406 |
include: "#param_list" |
| 407 |
}, { |
| 408 |
token: "storage.type.zig", |
| 409 |
regex: /[a-zA-Z_][\w.]*|@\".+\"/ |
| 410 |
}, { |
| 411 |
include: "#dummy_main" |
| 412 |
}] |
| 413 |
}], |
| 414 |
"#support": [{ |
| 415 |
token: "support.function.zig", |
| 416 |
regex: /\b@(?!\w|\"|[0-9])[a-zA-Z_]\w*\b/ |
| 417 |
}], |
| 418 |
"#variables": [{ |
| 419 |
token: "variable.constant.zig", |
| 420 |
regex: /\b[_A-Z][_A-Z0-9]+\b/ |
| 421 |
}, { |
| 422 |
token: "entity.name.type.zig", |
| 423 |
regex: /\b[_a-zA-Z][_a-zA-Z0-9]*_t\b/ |
| 424 |
}, { |
| 425 |
token: "entity.name.type.zig", |
| 426 |
regex: /\b[A-Z][a-zA-Z0-9]*\b/ |
| 427 |
}, { |
| 428 |
token: "variable.zig", |
| 429 |
regex: /\b[_a-zA-Z][_a-zA-Z0-9]*\b/ |
| 430 |
}] |
| 431 |
}; |
| 432 |
this.normalizeRules(); |
| 433 |
}; |
| 434 |
ZigHighlightRules.metaData = { |
| 435 |
fileTypes: ["zig"], |
| 436 |
keyEquivalent: "^~Z", |
| 437 |
name: "Zig", |
| 438 |
scopeName: "source.zig" |
| 439 |
}; |
| 440 |
oop.inherits(ZigHighlightRules, TextHighlightRules); |
| 441 |
exports.ZigHighlightRules = ZigHighlightRules; |
| 442 |
|
| 443 |
}); |
| 444 |
|
| 445 |
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"; |
| 446 |
var oop = require("../../lib/oop"); |
| 447 |
var Range = require("../../range").Range; |
| 448 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 449 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 450 |
if (commentRegex) { |
| 451 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 452 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 453 |
} |
| 454 |
}; |
| 455 |
oop.inherits(FoldMode, BaseFoldMode); |
| 456 |
(function () { |
| 457 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 458 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 459 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 460 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 461 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 462 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 463 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 464 |
var line = session.getLine(row); |
| 465 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 466 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 467 |
return ""; |
| 468 |
} |
| 469 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 470 |
if (!fw && this.startRegionRe.test(line)) |
| 471 |
return "start"; |
| 472 |
return fw; |
| 473 |
}; |
| 474 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 475 |
var line = session.getLine(row); |
| 476 |
if (this.startRegionRe.test(line)) |
| 477 |
return this.getCommentRegionBlock(session, line, row); |
| 478 |
var match = line.match(this.foldingStartMarker); |
| 479 |
if (match) { |
| 480 |
var i = match.index; |
| 481 |
if (match[1]) |
| 482 |
return this.openingBracketBlock(session, match[1], row, i); |
| 483 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 484 |
if (range && !range.isMultiLine()) { |
| 485 |
if (forceMultiline) { |
| 486 |
range = this.getSectionRange(session, row); |
| 487 |
} |
| 488 |
else if (foldStyle != "all") |
| 489 |
range = null; |
| 490 |
} |
| 491 |
return range; |
| 492 |
} |
| 493 |
if (foldStyle === "markbegin") |
| 494 |
return; |
| 495 |
var match = line.match(this.foldingStopMarker); |
| 496 |
if (match) { |
| 497 |
var i = match.index + match[0].length; |
| 498 |
if (match[1]) |
| 499 |
return this.closingBracketBlock(session, match[1], row, i); |
| 500 |
return session.getCommentFoldRange(row, i, -1); |
| 501 |
} |
| 502 |
}; |
| 503 |
this.getSectionRange = function (session, row) { |
| 504 |
var line = session.getLine(row); |
| 505 |
var startIndent = line.search(/\S/); |
| 506 |
var startRow = row; |
| 507 |
var startColumn = line.length; |
| 508 |
row = row + 1; |
| 509 |
var endRow = row; |
| 510 |
var maxRow = session.getLength(); |
| 511 |
while (++row < maxRow) { |
| 512 |
line = session.getLine(row); |
| 513 |
var indent = line.search(/\S/); |
| 514 |
if (indent === -1) |
| 515 |
continue; |
| 516 |
if (startIndent > indent) |
| 517 |
break; |
| 518 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 519 |
if (subRange) { |
| 520 |
if (subRange.start.row <= startRow) { |
| 521 |
break; |
| 522 |
} |
| 523 |
else if (subRange.isMultiLine()) { |
| 524 |
row = subRange.end.row; |
| 525 |
} |
| 526 |
else if (startIndent == indent) { |
| 527 |
break; |
| 528 |
} |
| 529 |
} |
| 530 |
endRow = row; |
| 531 |
} |
| 532 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 533 |
}; |
| 534 |
this.getCommentRegionBlock = function (session, line, row) { |
| 535 |
var startColumn = line.search(/\s*$/); |
| 536 |
var maxRow = session.getLength(); |
| 537 |
var startRow = row; |
| 538 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 539 |
var depth = 1; |
| 540 |
while (++row < maxRow) { |
| 541 |
line = session.getLine(row); |
| 542 |
var m = re.exec(line); |
| 543 |
if (!m) |
| 544 |
continue; |
| 545 |
if (m[1]) |
| 546 |
depth--; |
| 547 |
else |
| 548 |
depth++; |
| 549 |
if (!depth) |
| 550 |
break; |
| 551 |
} |
| 552 |
var endRow = row; |
| 553 |
if (endRow > startRow) { |
| 554 |
return new Range(startRow, startColumn, endRow, line.length); |
| 555 |
} |
| 556 |
}; |
| 557 |
}).call(FoldMode.prototype); |
| 558 |
|
| 559 |
}); |
| 560 |
|
| 561 |
ace.define("ace/mode/zig",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/zig_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){"use strict"; |
| 562 |
var oop = require("../lib/oop"); |
| 563 |
var TextMode = require("./text").Mode; |
| 564 |
var ZigHighlightRules = require("./zig_highlight_rules").ZigHighlightRules; |
| 565 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 566 |
var Mode = function () { |
| 567 |
this.HighlightRules = ZigHighlightRules; |
| 568 |
this.foldingRules = new FoldMode(); |
| 569 |
this.$behaviour = this.$defaultBehaviour; |
| 570 |
}; |
| 571 |
oop.inherits(Mode, TextMode); |
| 572 |
(function () { |
| 573 |
this.lineCommentStart = "//"; |
| 574 |
this.$id = "ace/mode/zig"; |
| 575 |
}).call(Mode.prototype); |
| 576 |
exports.Mode = Mode; |
| 577 |
|
| 578 |
}); (function() { |
| 579 |
ace.require(["ace/mode/zig"], function(m) { |
| 580 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 581 |
module.exports = m; |
| 582 |
} |
| 583 |
}); |
| 584 |
})(); |
| 585 |
|