a7da972483728415ac8f250f02083cd8.js 13 KB

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