| 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/swift_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","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 lang = require("../lib/lang"); |
| 45 |
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; |
| 46 |
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 47 |
var SwiftHighlightRules = function () { |
| 48 |
var keywordMapper = this.createKeywordMapper({ |
| 49 |
"variable.language": "", |
| 50 |
"keyword": "__COLUMN__|__FILE__|__FUNCTION__|__LINE__" |
| 51 |
+ "|as|associativity|break|case|class|continue|default|deinit|didSet" |
| 52 |
+ "|do|dynamicType|else|enum|extension|fallthrough|for|func|get|if|import" |
| 53 |
+ "|in|infix|init|inout|is|left|let|let|mutating|new|none|nonmutating" |
| 54 |
+ "|operator|override|postfix|precedence|prefix|protocol|return|right" |
| 55 |
+ "|safe|Self|self|set|struct|subscript|switch|Type|typealias" |
| 56 |
+ "|unowned|unsafe|var|weak|where|while|willSet" |
| 57 |
+ "|convenience|dynamic|final|infix|lazy|mutating|nonmutating|optional|override|postfix" |
| 58 |
+ "|prefix|required|static|guard|defer", |
| 59 |
"storage.type": "bool|double|Double" |
| 60 |
+ "|extension|float|Float|int|Int|open|internal|fileprivate|private|public|string|String", |
| 61 |
"constant.language": "false|Infinity|NaN|nil|no|null|null|off|on|super|this|true|undefined|yes", |
| 62 |
"support.function": "" |
| 63 |
}, "identifier"); |
| 64 |
function string(start, options) { |
| 65 |
var nestable = options.nestable || options.interpolation; |
| 66 |
var interpStart = options.interpolation && options.interpolation.nextState || "start"; |
| 67 |
var mainRule = { |
| 68 |
regex: start + (options.multiline ? "" : "(?=.)"), |
| 69 |
token: "string.start" |
| 70 |
}; |
| 71 |
var nextState = [ |
| 72 |
options.escape && { |
| 73 |
regex: options.escape, |
| 74 |
token: "character.escape" |
| 75 |
}, |
| 76 |
options.interpolation && { |
| 77 |
token: "paren.quasi.start", |
| 78 |
regex: lang.escapeRegExp(options.interpolation.lead + options.interpolation.open), |
| 79 |
push: interpStart |
| 80 |
}, |
| 81 |
options.error && { |
| 82 |
regex: options.error, |
| 83 |
token: "error.invalid" |
| 84 |
}, |
| 85 |
{ |
| 86 |
regex: start + (options.multiline ? "" : "|$"), |
| 87 |
token: "string.end", |
| 88 |
next: nestable ? "pop" : "start" |
| 89 |
}, { |
| 90 |
defaultToken: "string" |
| 91 |
} |
| 92 |
].filter(Boolean); |
| 93 |
if (nestable) |
| 94 |
mainRule.push = nextState; |
| 95 |
else |
| 96 |
mainRule.next = nextState; |
| 97 |
if (!options.interpolation) |
| 98 |
return mainRule; |
| 99 |
var open = options.interpolation.open; |
| 100 |
var close = options.interpolation.close; |
| 101 |
var counter = { |
| 102 |
regex: "[" + lang.escapeRegExp(open + close) + "]", |
| 103 |
onMatch: function (val, state, stack) { |
| 104 |
this.next = val == open ? this.nextState : ""; |
| 105 |
if (val == open && stack.length) { |
| 106 |
stack.unshift("start", state); |
| 107 |
return "paren"; |
| 108 |
} |
| 109 |
if (val == close && stack.length) { |
| 110 |
stack.shift(); |
| 111 |
this.next = stack.shift(); |
| 112 |
if (this.next.indexOf("string") != -1) |
| 113 |
return "paren.quasi.end"; |
| 114 |
} |
| 115 |
return val == open ? "paren.lparen" : "paren.rparen"; |
| 116 |
}, |
| 117 |
nextState: interpStart |
| 118 |
}; |
| 119 |
return [counter, mainRule]; |
| 120 |
} |
| 121 |
function comments() { |
| 122 |
return [{ |
| 123 |
token: "comment", |
| 124 |
regex: /\/\//, |
| 125 |
next: [ |
| 126 |
DocCommentHighlightRules.getTagRule(), |
| 127 |
{ token: "comment", regex: "$|^", next: "start" }, |
| 128 |
{ defaultToken: "comment", caseInsensitive: true } |
| 129 |
] |
| 130 |
}, |
| 131 |
DocCommentHighlightRules.getStartRule("doc-start"), |
| 132 |
{ |
| 133 |
token: "comment.start", |
| 134 |
regex: /\/\*/, |
| 135 |
stateName: "nested_comment", |
| 136 |
push: [ |
| 137 |
DocCommentHighlightRules.getTagRule(), |
| 138 |
{ token: "comment.start", regex: /\/\*/, push: "nested_comment" }, |
| 139 |
{ token: "comment.end", regex: "\\*\\/", next: "pop" }, |
| 140 |
{ defaultToken: "comment", caseInsensitive: true } |
| 141 |
] |
| 142 |
} |
| 143 |
]; |
| 144 |
} |
| 145 |
this.$rules = { |
| 146 |
start: [ |
| 147 |
string('"""', { |
| 148 |
escape: /\\(?:[0\\tnr"']|u{[a-fA-F1-9]{0,8}})/, |
| 149 |
interpolation: { lead: "\\", open: "(", close: ")" }, |
| 150 |
error: /\\./, |
| 151 |
multiline: true |
| 152 |
}), |
| 153 |
string('"', { |
| 154 |
escape: /\\(?:[0\\tnr"']|u{[a-fA-F1-9]{0,8}})/, |
| 155 |
interpolation: { lead: "\\", open: "(", close: ")" }, |
| 156 |
error: /\\./, |
| 157 |
multiline: false |
| 158 |
}), |
| 159 |
comments(), |
| 160 |
{ |
| 161 |
regex: /@[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/, |
| 162 |
token: "variable.parameter" |
| 163 |
}, |
| 164 |
{ |
| 165 |
regex: /[a-zA-Z_$][a-zA-Z_$\d\u0080-\ufffe]*/, |
| 166 |
token: keywordMapper |
| 167 |
}, |
| 168 |
{ |
| 169 |
token: "constant.numeric", |
| 170 |
regex: /[+-]?(?:0(?:b[01]+|o[0-7]+|x[\da-fA-F])|\d+(?:(?:\.\d*)?(?:[PpEe][+-]?\d+)?)\b)/ |
| 171 |
}, { |
| 172 |
token: "keyword.operator", |
| 173 |
regex: /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/, |
| 174 |
next: "start" |
| 175 |
}, { |
| 176 |
token: "punctuation.operator", |
| 177 |
regex: /[?:,;.]/, |
| 178 |
next: "start" |
| 179 |
}, { |
| 180 |
token: "paren.lparen", |
| 181 |
regex: /[\[({]/, |
| 182 |
next: "start" |
| 183 |
}, { |
| 184 |
token: "paren.rparen", |
| 185 |
regex: /[\])}]/ |
| 186 |
} |
| 187 |
] |
| 188 |
}; |
| 189 |
this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]); |
| 190 |
this.normalizeRules(); |
| 191 |
}; |
| 192 |
oop.inherits(SwiftHighlightRules, TextHighlightRules); |
| 193 |
exports.HighlightRules = SwiftHighlightRules; |
| 194 |
|
| 195 |
}); |
| 196 |
|
| 197 |
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"; |
| 198 |
var oop = require("../../lib/oop"); |
| 199 |
var Range = require("../../range").Range; |
| 200 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 201 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 202 |
if (commentRegex) { |
| 203 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 204 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 205 |
} |
| 206 |
}; |
| 207 |
oop.inherits(FoldMode, BaseFoldMode); |
| 208 |
(function () { |
| 209 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 210 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 211 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 212 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 213 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 214 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 215 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 216 |
var line = session.getLine(row); |
| 217 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 218 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 219 |
return ""; |
| 220 |
} |
| 221 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 222 |
if (!fw && this.startRegionRe.test(line)) |
| 223 |
return "start"; |
| 224 |
return fw; |
| 225 |
}; |
| 226 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 227 |
var line = session.getLine(row); |
| 228 |
if (this.startRegionRe.test(line)) |
| 229 |
return this.getCommentRegionBlock(session, line, row); |
| 230 |
var match = line.match(this.foldingStartMarker); |
| 231 |
if (match) { |
| 232 |
var i = match.index; |
| 233 |
if (match[1]) |
| 234 |
return this.openingBracketBlock(session, match[1], row, i); |
| 235 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 236 |
if (range && !range.isMultiLine()) { |
| 237 |
if (forceMultiline) { |
| 238 |
range = this.getSectionRange(session, row); |
| 239 |
} |
| 240 |
else if (foldStyle != "all") |
| 241 |
range = null; |
| 242 |
} |
| 243 |
return range; |
| 244 |
} |
| 245 |
if (foldStyle === "markbegin") |
| 246 |
return; |
| 247 |
var match = line.match(this.foldingStopMarker); |
| 248 |
if (match) { |
| 249 |
var i = match.index + match[0].length; |
| 250 |
if (match[1]) |
| 251 |
return this.closingBracketBlock(session, match[1], row, i); |
| 252 |
return session.getCommentFoldRange(row, i, -1); |
| 253 |
} |
| 254 |
}; |
| 255 |
this.getSectionRange = function (session, row) { |
| 256 |
var line = session.getLine(row); |
| 257 |
var startIndent = line.search(/\S/); |
| 258 |
var startRow = row; |
| 259 |
var startColumn = line.length; |
| 260 |
row = row + 1; |
| 261 |
var endRow = row; |
| 262 |
var maxRow = session.getLength(); |
| 263 |
while (++row < maxRow) { |
| 264 |
line = session.getLine(row); |
| 265 |
var indent = line.search(/\S/); |
| 266 |
if (indent === -1) |
| 267 |
continue; |
| 268 |
if (startIndent > indent) |
| 269 |
break; |
| 270 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 271 |
if (subRange) { |
| 272 |
if (subRange.start.row <= startRow) { |
| 273 |
break; |
| 274 |
} |
| 275 |
else if (subRange.isMultiLine()) { |
| 276 |
row = subRange.end.row; |
| 277 |
} |
| 278 |
else if (startIndent == indent) { |
| 279 |
break; |
| 280 |
} |
| 281 |
} |
| 282 |
endRow = row; |
| 283 |
} |
| 284 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 285 |
}; |
| 286 |
this.getCommentRegionBlock = function (session, line, row) { |
| 287 |
var startColumn = line.search(/\s*$/); |
| 288 |
var maxRow = session.getLength(); |
| 289 |
var startRow = row; |
| 290 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 291 |
var depth = 1; |
| 292 |
while (++row < maxRow) { |
| 293 |
line = session.getLine(row); |
| 294 |
var m = re.exec(line); |
| 295 |
if (!m) |
| 296 |
continue; |
| 297 |
if (m[1]) |
| 298 |
depth--; |
| 299 |
else |
| 300 |
depth++; |
| 301 |
if (!depth) |
| 302 |
break; |
| 303 |
} |
| 304 |
var endRow = row; |
| 305 |
if (endRow > startRow) { |
| 306 |
return new Range(startRow, startColumn, endRow, line.length); |
| 307 |
} |
| 308 |
}; |
| 309 |
}).call(FoldMode.prototype); |
| 310 |
|
| 311 |
}); |
| 312 |
|
| 313 |
ace.define("ace/mode/swift",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/swift_highlight_rules","ace/mode/folding/cstyle"], function(require, exports, module){ |
| 314 |
|
| 315 |
|
| 316 |
"use strict"; |
| 317 |
var oop = require("../lib/oop"); |
| 318 |
var TextMode = require("./text").Mode; |
| 319 |
var HighlightRules = require("./swift_highlight_rules").HighlightRules; |
| 320 |
var FoldMode = require("./folding/cstyle").FoldMode; |
| 321 |
var Mode = function () { |
| 322 |
this.HighlightRules = HighlightRules; |
| 323 |
this.foldingRules = new FoldMode(); |
| 324 |
this.$behaviour = this.$defaultBehaviour; |
| 325 |
}; |
| 326 |
oop.inherits(Mode, TextMode); |
| 327 |
(function () { |
| 328 |
this.lineCommentStart = "//"; |
| 329 |
this.blockComment = { start: "/*", end: "*/", nestable: true }; |
| 330 |
this.$id = "ace/mode/swift"; |
| 331 |
}).call(Mode.prototype); |
| 332 |
exports.Mode = Mode; |
| 333 |
|
| 334 |
}); (function() { |
| 335 |
ace.require(["ace/mode/swift"], function(m) { |
| 336 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 337 |
module.exports = m; |
| 338 |
} |
| 339 |
}); |
| 340 |
})(); |
| 341 |
|