2e4c8b961fd80b700a23d21f3d9bb4c5.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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/haxe_highlight_rules",["require","exports","module","ace/lib/oop","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 DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  43. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  44. var HaxeHighlightRules = function () {
  45. var keywords = ("break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std");
  46. var buildinConstants = ("null|true|false");
  47. var keywordMapper = this.createKeywordMapper({
  48. "variable.language": "this",
  49. "keyword": keywords,
  50. "constant.language": buildinConstants
  51. }, "identifier");
  52. this.$rules = {
  53. "start": [
  54. {
  55. token: "comment",
  56. regex: "\\/\\/.*$"
  57. },
  58. DocCommentHighlightRules.getStartRule("doc-start"),
  59. {
  60. token: "comment",
  61. regex: "\\/\\*",
  62. next: "comment"
  63. }, {
  64. token: "string.regexp",
  65. regex: "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  66. }, {
  67. token: "string",
  68. regex: '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  69. }, {
  70. token: "string",
  71. regex: "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  72. }, {
  73. token: "constant.numeric",
  74. regex: "0[xX][0-9a-fA-F]+\\b"
  75. }, {
  76. token: "constant.numeric",
  77. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  78. }, {
  79. token: "constant.language.boolean",
  80. regex: "(?:true|false)\\b"
  81. }, {
  82. token: keywordMapper,
  83. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  84. }, {
  85. token: "keyword.operator",
  86. regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
  87. }, {
  88. token: "punctuation.operator",
  89. regex: "\\?|\\:|\\,|\\;|\\."
  90. }, {
  91. token: "paren.lparen",
  92. regex: "[[({<]"
  93. }, {
  94. token: "paren.rparen",
  95. regex: "[\\])}>]"
  96. }, {
  97. token: "text",
  98. regex: "\\s+"
  99. }
  100. ],
  101. "comment": [
  102. {
  103. token: "comment",
  104. regex: "\\*\\/",
  105. next: "start"
  106. }, {
  107. defaultToken: "comment"
  108. }
  109. ]
  110. };
  111. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  112. };
  113. oop.inherits(HaxeHighlightRules, TextHighlightRules);
  114. exports.HaxeHighlightRules = HaxeHighlightRules;
  115. });
  116. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  117. var Range = require("../range").Range;
  118. var MatchingBraceOutdent = function () { };
  119. (function () {
  120. this.checkOutdent = function (line, input) {
  121. if (!/^\s+$/.test(line))
  122. return false;
  123. return /^\s*\}/.test(input);
  124. };
  125. this.autoOutdent = function (doc, row) {
  126. var line = doc.getLine(row);
  127. var match = line.match(/^(\s*\})/);
  128. if (!match)
  129. return 0;
  130. var column = match[1].length;
  131. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  132. if (!openBracePos || openBracePos.row == row)
  133. return 0;
  134. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  135. doc.replace(new Range(row, 0, row, column - 1), indent);
  136. };
  137. this.$getIndent = function (line) {
  138. return line.match(/^\s*/)[0];
  139. };
  140. }).call(MatchingBraceOutdent.prototype);
  141. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  142. });
  143. 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";
  144. var oop = require("../../lib/oop");
  145. var Range = require("../../range").Range;
  146. var BaseFoldMode = require("./fold_mode").FoldMode;
  147. var FoldMode = exports.FoldMode = function (commentRegex) {
  148. if (commentRegex) {
  149. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  150. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  151. }
  152. };
  153. oop.inherits(FoldMode, BaseFoldMode);
  154. (function () {
  155. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  156. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  157. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  158. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  159. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  160. this._getFoldWidgetBase = this.getFoldWidget;
  161. this.getFoldWidget = function (session, foldStyle, row) {
  162. var line = session.getLine(row);
  163. if (this.singleLineBlockCommentRe.test(line)) {
  164. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  165. return "";
  166. }
  167. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  168. if (!fw && this.startRegionRe.test(line))
  169. return "start"; // lineCommentRegionStart
  170. return fw;
  171. };
  172. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  173. var line = session.getLine(row);
  174. if (this.startRegionRe.test(line))
  175. return this.getCommentRegionBlock(session, line, row);
  176. var match = line.match(this.foldingStartMarker);
  177. if (match) {
  178. var i = match.index;
  179. if (match[1])
  180. return this.openingBracketBlock(session, match[1], row, i);
  181. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  182. if (range && !range.isMultiLine()) {
  183. if (forceMultiline) {
  184. range = this.getSectionRange(session, row);
  185. }
  186. else if (foldStyle != "all")
  187. range = null;
  188. }
  189. return range;
  190. }
  191. if (foldStyle === "markbegin")
  192. return;
  193. var match = line.match(this.foldingStopMarker);
  194. if (match) {
  195. var i = match.index + match[0].length;
  196. if (match[1])
  197. return this.closingBracketBlock(session, match[1], row, i);
  198. return session.getCommentFoldRange(row, i, -1);
  199. }
  200. };
  201. this.getSectionRange = function (session, row) {
  202. var line = session.getLine(row);
  203. var startIndent = line.search(/\S/);
  204. var startRow = row;
  205. var startColumn = line.length;
  206. row = row + 1;
  207. var endRow = row;
  208. var maxRow = session.getLength();
  209. while (++row < maxRow) {
  210. line = session.getLine(row);
  211. var indent = line.search(/\S/);
  212. if (indent === -1)
  213. continue;
  214. if (startIndent > indent)
  215. break;
  216. var subRange = this.getFoldWidgetRange(session, "all", row);
  217. if (subRange) {
  218. if (subRange.start.row <= startRow) {
  219. break;
  220. }
  221. else if (subRange.isMultiLine()) {
  222. row = subRange.end.row;
  223. }
  224. else if (startIndent == indent) {
  225. break;
  226. }
  227. }
  228. endRow = row;
  229. }
  230. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  231. };
  232. this.getCommentRegionBlock = function (session, line, row) {
  233. var startColumn = line.search(/\s*$/);
  234. var maxRow = session.getLength();
  235. var startRow = row;
  236. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  237. var depth = 1;
  238. while (++row < maxRow) {
  239. line = session.getLine(row);
  240. var m = re.exec(line);
  241. if (!m)
  242. continue;
  243. if (m[1])
  244. depth--;
  245. else
  246. depth++;
  247. if (!depth)
  248. break;
  249. }
  250. var endRow = row;
  251. if (endRow > startRow) {
  252. return new Range(startRow, startColumn, endRow, line.length);
  253. }
  254. };
  255. }).call(FoldMode.prototype);
  256. });
  257. ace.define("ace/mode/haxe",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/haxe_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  258. var oop = require("../lib/oop");
  259. var TextMode = require("./text").Mode;
  260. var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules;
  261. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  262. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  263. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  264. var Mode = function () {
  265. this.HighlightRules = HaxeHighlightRules;
  266. this.$outdent = new MatchingBraceOutdent();
  267. this.$behaviour = new CstyleBehaviour();
  268. this.foldingRules = new CStyleFoldMode();
  269. };
  270. oop.inherits(Mode, TextMode);
  271. (function () {
  272. this.lineCommentStart = "//";
  273. this.blockComment = { start: "/*", end: "*/" };
  274. this.getNextLineIndent = function (state, line, tab) {
  275. var indent = this.$getIndent(line);
  276. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  277. var tokens = tokenizedLine.tokens;
  278. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  279. return indent;
  280. }
  281. if (state == "start") {
  282. var match = line.match(/^.*[\{\(\[]\s*$/);
  283. if (match) {
  284. indent += tab;
  285. }
  286. }
  287. return indent;
  288. };
  289. this.checkOutdent = function (state, line, input) {
  290. return this.$outdent.checkOutdent(line, input);
  291. };
  292. this.autoOutdent = function (state, doc, row) {
  293. this.$outdent.autoOutdent(doc, row);
  294. };
  295. this.$id = "ace/mode/haxe";
  296. }).call(Mode.prototype);
  297. exports.Mode = Mode;
  298. }); (function() {
  299. ace.require(["ace/mode/haxe"], function(m) {
  300. if (typeof module == "object" && typeof exports == "object" && module) {
  301. module.exports = m;
  302. }
  303. });
  304. })();