16ae728a78f1cb04d40f77b322eb133d.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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/csharp_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 CSharpHighlightRules = function () {
  45. var keywordMapper = this.createKeywordMapper({
  46. "variable.language": "this",
  47. "keyword": "abstract|async|await|event|new|struct|as|explicit|null|switch|base|extern|object|this|bool|false|operator|throw|break|finally|out|true|byte|fixed|override|try|case|float|params|typeof|catch|for|private|uint|char|foreach|protected|ulong|checked|goto|public|unchecked|class|if|readonly|unsafe|const|implicit|ref|ushort|continue|in|return|using|decimal|int|sbyte|virtual|default|interface|sealed|volatile|delegate|internal|partial|short|void|do|is|sizeof|while|double|lock|stackalloc|else|long|static|enum|namespace|string|var|dynamic",
  48. "constant.language": "null|true|false"
  49. }, "identifier");
  50. this.$rules = {
  51. "start": [
  52. {
  53. token: "comment",
  54. regex: "\\/\\/.*$"
  55. },
  56. DocCommentHighlightRules.getStartRule("doc-start"),
  57. {
  58. token: "comment",
  59. regex: "\\/\\*",
  60. next: "comment"
  61. }, {
  62. token: "string",
  63. regex: /'(?:.|\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n]))?'/
  64. }, {
  65. token: "string", start: '"', end: '"|$', next: [
  66. { token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/ },
  67. { token: "invalid", regex: /\\./ }
  68. ]
  69. }, {
  70. token: "string", start: '@"', end: '"', next: [
  71. { token: "constant.language.escape", regex: '""' }
  72. ]
  73. }, {
  74. token: "string", start: /\$"/, end: '"|$', next: [
  75. { token: "constant.language.escape", regex: /\\(:?$)|{{/ },
  76. { token: "constant.language.escape", regex: /\\(:?u[\da-fA-F]+|x[\da-fA-F]+|[tbrf'"n])/ },
  77. { token: "invalid", regex: /\\./ }
  78. ]
  79. }, {
  80. token: "constant.numeric",
  81. regex: "0[xX][0-9a-fA-F]+\\b"
  82. }, {
  83. token: "constant.numeric",
  84. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  85. }, {
  86. token: "constant.language.boolean",
  87. regex: "(?:true|false)\\b"
  88. }, {
  89. token: keywordMapper,
  90. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  91. }, {
  92. token: "keyword.operator",
  93. regex: "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
  94. }, {
  95. token: "keyword",
  96. regex: "^\\s*#(if|else|elif|endif|define|undef|warning|error|line|region|endregion|pragma)"
  97. }, {
  98. token: "punctuation.operator",
  99. regex: "\\?|\\:|\\,|\\;|\\."
  100. }, {
  101. token: "paren.lparen",
  102. regex: "[[({]"
  103. }, {
  104. token: "paren.rparen",
  105. regex: "[\\])}]"
  106. }, {
  107. token: "text",
  108. regex: "\\s+"
  109. }
  110. ],
  111. "comment": [
  112. {
  113. token: "comment",
  114. regex: "\\*\\/",
  115. next: "start"
  116. }, {
  117. defaultToken: "comment"
  118. }
  119. ]
  120. };
  121. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  122. this.normalizeRules();
  123. };
  124. oop.inherits(CSharpHighlightRules, TextHighlightRules);
  125. exports.CSharpHighlightRules = CSharpHighlightRules;
  126. });
  127. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module){"use strict";
  128. var Range = require("../range").Range;
  129. var MatchingBraceOutdent = function () { };
  130. (function () {
  131. this.checkOutdent = function (line, input) {
  132. if (!/^\s+$/.test(line))
  133. return false;
  134. return /^\s*\}/.test(input);
  135. };
  136. this.autoOutdent = function (doc, row) {
  137. var line = doc.getLine(row);
  138. var match = line.match(/^(\s*\})/);
  139. if (!match)
  140. return 0;
  141. var column = match[1].length;
  142. var openBracePos = doc.findMatchingBracket({ row: row, column: column });
  143. if (!openBracePos || openBracePos.row == row)
  144. return 0;
  145. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  146. doc.replace(new Range(row, 0, row, column - 1), indent);
  147. };
  148. this.$getIndent = function (line) {
  149. return line.match(/^\s*/)[0];
  150. };
  151. }).call(MatchingBraceOutdent.prototype);
  152. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  153. });
  154. 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";
  155. var oop = require("../../lib/oop");
  156. var Range = require("../../range").Range;
  157. var BaseFoldMode = require("./fold_mode").FoldMode;
  158. var FoldMode = exports.FoldMode = function (commentRegex) {
  159. if (commentRegex) {
  160. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  161. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  162. }
  163. };
  164. oop.inherits(FoldMode, BaseFoldMode);
  165. (function () {
  166. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  167. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  168. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  169. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  170. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  171. this._getFoldWidgetBase = this.getFoldWidget;
  172. this.getFoldWidget = function (session, foldStyle, row) {
  173. var line = session.getLine(row);
  174. if (this.singleLineBlockCommentRe.test(line)) {
  175. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  176. return "";
  177. }
  178. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  179. if (!fw && this.startRegionRe.test(line))
  180. return "start"; // lineCommentRegionStart
  181. return fw;
  182. };
  183. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  184. var line = session.getLine(row);
  185. if (this.startRegionRe.test(line))
  186. return this.getCommentRegionBlock(session, line, row);
  187. var match = line.match(this.foldingStartMarker);
  188. if (match) {
  189. var i = match.index;
  190. if (match[1])
  191. return this.openingBracketBlock(session, match[1], row, i);
  192. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  193. if (range && !range.isMultiLine()) {
  194. if (forceMultiline) {
  195. range = this.getSectionRange(session, row);
  196. }
  197. else if (foldStyle != "all")
  198. range = null;
  199. }
  200. return range;
  201. }
  202. if (foldStyle === "markbegin")
  203. return;
  204. var match = line.match(this.foldingStopMarker);
  205. if (match) {
  206. var i = match.index + match[0].length;
  207. if (match[1])
  208. return this.closingBracketBlock(session, match[1], row, i);
  209. return session.getCommentFoldRange(row, i, -1);
  210. }
  211. };
  212. this.getSectionRange = function (session, row) {
  213. var line = session.getLine(row);
  214. var startIndent = line.search(/\S/);
  215. var startRow = row;
  216. var startColumn = line.length;
  217. row = row + 1;
  218. var endRow = row;
  219. var maxRow = session.getLength();
  220. while (++row < maxRow) {
  221. line = session.getLine(row);
  222. var indent = line.search(/\S/);
  223. if (indent === -1)
  224. continue;
  225. if (startIndent > indent)
  226. break;
  227. var subRange = this.getFoldWidgetRange(session, "all", row);
  228. if (subRange) {
  229. if (subRange.start.row <= startRow) {
  230. break;
  231. }
  232. else if (subRange.isMultiLine()) {
  233. row = subRange.end.row;
  234. }
  235. else if (startIndent == indent) {
  236. break;
  237. }
  238. }
  239. endRow = row;
  240. }
  241. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  242. };
  243. this.getCommentRegionBlock = function (session, line, row) {
  244. var startColumn = line.search(/\s*$/);
  245. var maxRow = session.getLength();
  246. var startRow = row;
  247. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  248. var depth = 1;
  249. while (++row < maxRow) {
  250. line = session.getLine(row);
  251. var m = re.exec(line);
  252. if (!m)
  253. continue;
  254. if (m[1])
  255. depth--;
  256. else
  257. depth++;
  258. if (!depth)
  259. break;
  260. }
  261. var endRow = row;
  262. if (endRow > startRow) {
  263. return new Range(startRow, startColumn, endRow, line.length);
  264. }
  265. };
  266. }).call(FoldMode.prototype);
  267. });
  268. ace.define("ace/mode/folding/csharp",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  269. var oop = require("../../lib/oop");
  270. var Range = require("../../range").Range;
  271. var CFoldMode = require("./cstyle").FoldMode;
  272. var FoldMode = exports.FoldMode = function (commentRegex) {
  273. if (commentRegex) {
  274. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  275. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  276. }
  277. };
  278. oop.inherits(FoldMode, CFoldMode);
  279. (function () {
  280. this.usingRe = /^\s*using \S/;
  281. this.getFoldWidgetRangeBase = this.getFoldWidgetRange;
  282. this.getFoldWidgetBase = this.getFoldWidget;
  283. this.getFoldWidget = function (session, foldStyle, row) {
  284. var fw = this.getFoldWidgetBase(session, foldStyle, row);
  285. if (!fw) {
  286. var line = session.getLine(row);
  287. if (/^\s*#region\b/.test(line))
  288. return "start";
  289. var usingRe = this.usingRe;
  290. if (usingRe.test(line)) {
  291. var prev = session.getLine(row - 1);
  292. var next = session.getLine(row + 1);
  293. if (!usingRe.test(prev) && usingRe.test(next))
  294. return "start";
  295. }
  296. }
  297. return fw;
  298. };
  299. this.getFoldWidgetRange = function (session, foldStyle, row) {
  300. var range = this.getFoldWidgetRangeBase(session, foldStyle, row);
  301. if (range)
  302. return range;
  303. var line = session.getLine(row);
  304. if (this.usingRe.test(line))
  305. return this.getUsingStatementBlock(session, line, row);
  306. if (/^\s*#region\b/.test(line))
  307. return this.getRegionBlock(session, line, row);
  308. };
  309. this.getUsingStatementBlock = function (session, line, row) {
  310. var startColumn = line.match(this.usingRe)[0].length - 1;
  311. var maxRow = session.getLength();
  312. var startRow = row;
  313. var endRow = row;
  314. while (++row < maxRow) {
  315. line = session.getLine(row);
  316. if (/^\s*$/.test(line))
  317. continue;
  318. if (!this.usingRe.test(line))
  319. break;
  320. endRow = row;
  321. }
  322. if (endRow > startRow) {
  323. var endColumn = session.getLine(endRow).length;
  324. return new Range(startRow, startColumn, endRow, endColumn);
  325. }
  326. };
  327. this.getRegionBlock = function (session, line, row) {
  328. var startColumn = line.search(/\s*$/);
  329. var maxRow = session.getLength();
  330. var startRow = row;
  331. var re = /^\s*#(end)?region\b/;
  332. var depth = 1;
  333. while (++row < maxRow) {
  334. line = session.getLine(row);
  335. var m = re.exec(line);
  336. if (!m)
  337. continue;
  338. if (m[1])
  339. depth--;
  340. else
  341. depth++;
  342. if (!depth)
  343. break;
  344. }
  345. var endRow = row;
  346. if (endRow > startRow) {
  347. return new Range(startRow, startColumn, endRow, line.length);
  348. }
  349. };
  350. }).call(FoldMode.prototype);
  351. });
  352. ace.define("ace/mode/csharp",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/csharp_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/csharp"], function(require, exports, module){"use strict";
  353. var oop = require("../lib/oop");
  354. var TextMode = require("./text").Mode;
  355. var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
  356. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  357. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  358. var CStyleFoldMode = require("./folding/csharp").FoldMode;
  359. var Mode = function () {
  360. this.HighlightRules = CSharpHighlightRules;
  361. this.$outdent = new MatchingBraceOutdent();
  362. this.$behaviour = new CstyleBehaviour();
  363. this.foldingRules = new CStyleFoldMode();
  364. };
  365. oop.inherits(Mode, TextMode);
  366. (function () {
  367. this.lineCommentStart = "//";
  368. this.blockComment = { start: "/*", end: "*/" };
  369. this.getNextLineIndent = function (state, line, tab) {
  370. var indent = this.$getIndent(line);
  371. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  372. var tokens = tokenizedLine.tokens;
  373. if (tokens.length && tokens[tokens.length - 1].type == "comment") {
  374. return indent;
  375. }
  376. if (state == "start") {
  377. var match = line.match(/^.*[\{\(\[]\s*$/);
  378. if (match) {
  379. indent += tab;
  380. }
  381. }
  382. return indent;
  383. };
  384. this.checkOutdent = function (state, line, input) {
  385. return this.$outdent.checkOutdent(line, input);
  386. };
  387. this.autoOutdent = function (state, doc, row) {
  388. this.$outdent.autoOutdent(doc, row);
  389. };
  390. this.createWorker = function (session) {
  391. return null;
  392. };
  393. this.$id = "ace/mode/csharp";
  394. }).call(Mode.prototype);
  395. exports.Mode = Mode;
  396. }); (function() {
  397. ace.require(["ace/mode/csharp"], function(m) {
  398. if (typeof module == "object" && typeof exports == "object" && module) {
  399. module.exports = m;
  400. }
  401. });
  402. })();