mode-haxe.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. }, {
  11. token : "comment.doc.tag",
  12. regex : "\\bTODO\\b"
  13. }, {
  14. defaultToken : "comment.doc"
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getStartRule = function(start) {
  20. return {
  21. token : "comment.doc", // doc comment
  22. regex : "\\/\\*(?=\\*)",
  23. next : start
  24. };
  25. };
  26. DocCommentHighlightRules.getEndRule = function (start) {
  27. return {
  28. token : "comment.doc", // closing comment
  29. regex : "\\*\\/",
  30. next : start
  31. };
  32. };
  33. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  34. });
  35. 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) {
  36. "use strict";
  37. var oop = require("../lib/oop");
  38. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  39. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  40. var HaxeHighlightRules = function() {
  41. var keywords = (
  42. "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"
  43. );
  44. var buildinConstants = (
  45. "null|true|false"
  46. );
  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", // multi line comment
  61. regex : "\\/\\*",
  62. next : "comment"
  63. }, {
  64. token : "string.regexp",
  65. regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  66. }, {
  67. token : "string", // single line
  68. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  69. }, {
  70. token : "string", // single line
  71. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  72. }, {
  73. token : "constant.numeric", // hex
  74. regex : "0[xX][0-9a-fA-F]+\\b"
  75. }, {
  76. token : "constant.numeric", // float
  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", // closing comment
  104. regex : ".*?\\*\\/",
  105. next : "start"
  106. }, {
  107. token : "comment", // comment spanning whole line
  108. regex : ".+"
  109. }
  110. ]
  111. };
  112. this.embedRules(DocCommentHighlightRules, "doc-",
  113. [ DocCommentHighlightRules.getEndRule("start") ]);
  114. };
  115. oop.inherits(HaxeHighlightRules, TextHighlightRules);
  116. exports.HaxeHighlightRules = HaxeHighlightRules;
  117. });
  118. ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  119. "use strict";
  120. var Range = require("../range").Range;
  121. var MatchingBraceOutdent = function() {};
  122. (function() {
  123. this.checkOutdent = function(line, input) {
  124. if (! /^\s+$/.test(line))
  125. return false;
  126. return /^\s*\}/.test(input);
  127. };
  128. this.autoOutdent = function(doc, row) {
  129. var line = doc.getLine(row);
  130. var match = line.match(/^(\s*\})/);
  131. if (!match) return 0;
  132. var column = match[1].length;
  133. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  134. if (!openBracePos || openBracePos.row == row) return 0;
  135. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  136. doc.replace(new Range(row, 0, row, column-1), indent);
  137. };
  138. this.$getIndent = function(line) {
  139. return line.match(/^\s*/)[0];
  140. };
  141. }).call(MatchingBraceOutdent.prototype);
  142. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  143. });
  144. ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
  145. "use strict";
  146. var oop = require("../../lib/oop");
  147. var Behaviour = require("../behaviour").Behaviour;
  148. var TokenIterator = require("../../token_iterator").TokenIterator;
  149. var lang = require("../../lib/lang");
  150. var SAFE_INSERT_IN_TOKENS =
  151. ["text", "paren.rparen", "punctuation.operator"];
  152. var SAFE_INSERT_BEFORE_TOKENS =
  153. ["text", "paren.rparen", "punctuation.operator", "comment"];
  154. var context;
  155. var contextCache = {}
  156. var initContext = function(editor) {
  157. var id = -1;
  158. if (editor.multiSelect) {
  159. id = editor.selection.id;
  160. if (contextCache.rangeCount != editor.multiSelect.rangeCount)
  161. contextCache = {rangeCount: editor.multiSelect.rangeCount};
  162. }
  163. if (contextCache[id])
  164. return context = contextCache[id];
  165. context = contextCache[id] = {
  166. autoInsertedBrackets: 0,
  167. autoInsertedRow: -1,
  168. autoInsertedLineEnd: "",
  169. maybeInsertedBrackets: 0,
  170. maybeInsertedRow: -1,
  171. maybeInsertedLineStart: "",
  172. maybeInsertedLineEnd: ""
  173. };
  174. };
  175. var CstyleBehaviour = function() {
  176. this.add("braces", "insertion", function(state, action, editor, session, text) {
  177. var cursor = editor.getCursorPosition();
  178. var line = session.doc.getLine(cursor.row);
  179. if (text == '{') {
  180. initContext(editor);
  181. var selection = editor.getSelectionRange();
  182. var selected = session.doc.getTextRange(selection);
  183. if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
  184. return {
  185. text: '{' + selected + '}',
  186. selection: false
  187. };
  188. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  189. if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
  190. CstyleBehaviour.recordAutoInsert(editor, session, "}");
  191. return {
  192. text: '{}',
  193. selection: [1, 1]
  194. };
  195. } else {
  196. CstyleBehaviour.recordMaybeInsert(editor, session, "{");
  197. return {
  198. text: '{',
  199. selection: [1, 1]
  200. };
  201. }
  202. }
  203. } else if (text == '}') {
  204. initContext(editor);
  205. var rightChar = line.substring(cursor.column, cursor.column + 1);
  206. if (rightChar == '}') {
  207. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  208. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  209. CstyleBehaviour.popAutoInsertedClosing();
  210. return {
  211. text: '',
  212. selection: [1, 1]
  213. };
  214. }
  215. }
  216. } else if (text == "\n" || text == "\r\n") {
  217. initContext(editor);
  218. var closing = "";
  219. if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
  220. closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
  221. CstyleBehaviour.clearMaybeInsertedClosing();
  222. }
  223. var rightChar = line.substring(cursor.column, cursor.column + 1);
  224. if (rightChar === '}') {
  225. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
  226. if (!openBracePos)
  227. return null;
  228. var next_indent = this.$getIndent(session.getLine(openBracePos.row));
  229. } else if (closing) {
  230. var next_indent = this.$getIndent(line);
  231. } else {
  232. CstyleBehaviour.clearMaybeInsertedClosing();
  233. return;
  234. }
  235. var indent = next_indent + session.getTabString();
  236. return {
  237. text: '\n' + indent + '\n' + next_indent + closing,
  238. selection: [1, indent.length, 1, indent.length]
  239. };
  240. } else {
  241. CstyleBehaviour.clearMaybeInsertedClosing();
  242. }
  243. });
  244. this.add("braces", "deletion", function(state, action, editor, session, range) {
  245. var selected = session.doc.getTextRange(range);
  246. if (!range.isMultiLine() && selected == '{') {
  247. initContext(editor);
  248. var line = session.doc.getLine(range.start.row);
  249. var rightChar = line.substring(range.end.column, range.end.column + 1);
  250. if (rightChar == '}') {
  251. range.end.column++;
  252. return range;
  253. } else {
  254. context.maybeInsertedBrackets--;
  255. }
  256. }
  257. });
  258. this.add("parens", "insertion", function(state, action, editor, session, text) {
  259. if (text == '(') {
  260. initContext(editor);
  261. var selection = editor.getSelectionRange();
  262. var selected = session.doc.getTextRange(selection);
  263. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  264. return {
  265. text: '(' + selected + ')',
  266. selection: false
  267. };
  268. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  269. CstyleBehaviour.recordAutoInsert(editor, session, ")");
  270. return {
  271. text: '()',
  272. selection: [1, 1]
  273. };
  274. }
  275. } else if (text == ')') {
  276. initContext(editor);
  277. var cursor = editor.getCursorPosition();
  278. var line = session.doc.getLine(cursor.row);
  279. var rightChar = line.substring(cursor.column, cursor.column + 1);
  280. if (rightChar == ')') {
  281. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  282. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  283. CstyleBehaviour.popAutoInsertedClosing();
  284. return {
  285. text: '',
  286. selection: [1, 1]
  287. };
  288. }
  289. }
  290. }
  291. });
  292. this.add("parens", "deletion", function(state, action, editor, session, range) {
  293. var selected = session.doc.getTextRange(range);
  294. if (!range.isMultiLine() && selected == '(') {
  295. initContext(editor);
  296. var line = session.doc.getLine(range.start.row);
  297. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  298. if (rightChar == ')') {
  299. range.end.column++;
  300. return range;
  301. }
  302. }
  303. });
  304. this.add("brackets", "insertion", function(state, action, editor, session, text) {
  305. if (text == '[') {
  306. initContext(editor);
  307. var selection = editor.getSelectionRange();
  308. var selected = session.doc.getTextRange(selection);
  309. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  310. return {
  311. text: '[' + selected + ']',
  312. selection: false
  313. };
  314. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  315. CstyleBehaviour.recordAutoInsert(editor, session, "]");
  316. return {
  317. text: '[]',
  318. selection: [1, 1]
  319. };
  320. }
  321. } else if (text == ']') {
  322. initContext(editor);
  323. var cursor = editor.getCursorPosition();
  324. var line = session.doc.getLine(cursor.row);
  325. var rightChar = line.substring(cursor.column, cursor.column + 1);
  326. if (rightChar == ']') {
  327. var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
  328. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  329. CstyleBehaviour.popAutoInsertedClosing();
  330. return {
  331. text: '',
  332. selection: [1, 1]
  333. };
  334. }
  335. }
  336. }
  337. });
  338. this.add("brackets", "deletion", function(state, action, editor, session, range) {
  339. var selected = session.doc.getTextRange(range);
  340. if (!range.isMultiLine() && selected == '[') {
  341. initContext(editor);
  342. var line = session.doc.getLine(range.start.row);
  343. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  344. if (rightChar == ']') {
  345. range.end.column++;
  346. return range;
  347. }
  348. }
  349. });
  350. this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
  351. if (text == '"' || text == "'") {
  352. initContext(editor);
  353. var quote = text;
  354. var selection = editor.getSelectionRange();
  355. var selected = session.doc.getTextRange(selection);
  356. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  357. return {
  358. text: quote + selected + quote,
  359. selection: false
  360. };
  361. } else {
  362. var cursor = editor.getCursorPosition();
  363. var line = session.doc.getLine(cursor.row);
  364. var leftChar = line.substring(cursor.column-1, cursor.column);
  365. if (leftChar == '\\') {
  366. return null;
  367. }
  368. var tokens = session.getTokens(selection.start.row);
  369. var col = 0, token;
  370. var quotepos = -1; // Track whether we're inside an open quote.
  371. for (var x = 0; x < tokens.length; x++) {
  372. token = tokens[x];
  373. if (token.type == "string") {
  374. quotepos = -1;
  375. } else if (quotepos < 0) {
  376. quotepos = token.value.indexOf(quote);
  377. }
  378. if ((token.value.length + col) > selection.start.column) {
  379. break;
  380. }
  381. col += tokens[x].value.length;
  382. }
  383. if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
  384. if (!CstyleBehaviour.isSaneInsertion(editor, session))
  385. return;
  386. return {
  387. text: quote + quote,
  388. selection: [1,1]
  389. };
  390. } else if (token && token.type === "string") {
  391. var rightChar = line.substring(cursor.column, cursor.column + 1);
  392. if (rightChar == quote) {
  393. return {
  394. text: '',
  395. selection: [1, 1]
  396. };
  397. }
  398. }
  399. }
  400. }
  401. });
  402. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  403. var selected = session.doc.getTextRange(range);
  404. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  405. initContext(editor);
  406. var line = session.doc.getLine(range.start.row);
  407. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  408. if (rightChar == selected) {
  409. range.end.column++;
  410. return range;
  411. }
  412. }
  413. });
  414. };
  415. CstyleBehaviour.isSaneInsertion = function(editor, session) {
  416. var cursor = editor.getCursorPosition();
  417. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  418. if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
  419. var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
  420. if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
  421. return false;
  422. }
  423. iterator.stepForward();
  424. return iterator.getCurrentTokenRow() !== cursor.row ||
  425. this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
  426. };
  427. CstyleBehaviour.$matchTokenType = function(token, types) {
  428. return types.indexOf(token.type || token) > -1;
  429. };
  430. CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
  431. var cursor = editor.getCursorPosition();
  432. var line = session.doc.getLine(cursor.row);
  433. if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
  434. context.autoInsertedBrackets = 0;
  435. context.autoInsertedRow = cursor.row;
  436. context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
  437. context.autoInsertedBrackets++;
  438. };
  439. CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
  440. var cursor = editor.getCursorPosition();
  441. var line = session.doc.getLine(cursor.row);
  442. if (!this.isMaybeInsertedClosing(cursor, line))
  443. context.maybeInsertedBrackets = 0;
  444. context.maybeInsertedRow = cursor.row;
  445. context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
  446. context.maybeInsertedLineEnd = line.substr(cursor.column);
  447. context.maybeInsertedBrackets++;
  448. };
  449. CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
  450. return context.autoInsertedBrackets > 0 &&
  451. cursor.row === context.autoInsertedRow &&
  452. bracket === context.autoInsertedLineEnd[0] &&
  453. line.substr(cursor.column) === context.autoInsertedLineEnd;
  454. };
  455. CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
  456. return context.maybeInsertedBrackets > 0 &&
  457. cursor.row === context.maybeInsertedRow &&
  458. line.substr(cursor.column) === context.maybeInsertedLineEnd &&
  459. line.substr(0, cursor.column) == context.maybeInsertedLineStart;
  460. };
  461. CstyleBehaviour.popAutoInsertedClosing = function() {
  462. context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
  463. context.autoInsertedBrackets--;
  464. };
  465. CstyleBehaviour.clearMaybeInsertedClosing = function() {
  466. if (context) {
  467. context.maybeInsertedBrackets = 0;
  468. context.maybeInsertedRow = -1;
  469. }
  470. };
  471. oop.inherits(CstyleBehaviour, Behaviour);
  472. exports.CstyleBehaviour = CstyleBehaviour;
  473. });
  474. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  475. "use strict";
  476. var oop = require("../../lib/oop");
  477. var Range = require("../../range").Range;
  478. var BaseFoldMode = require("./fold_mode").FoldMode;
  479. var FoldMode = exports.FoldMode = function(commentRegex) {
  480. if (commentRegex) {
  481. this.foldingStartMarker = new RegExp(
  482. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  483. );
  484. this.foldingStopMarker = new RegExp(
  485. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  486. );
  487. }
  488. };
  489. oop.inherits(FoldMode, BaseFoldMode);
  490. (function() {
  491. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  492. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  493. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  494. var line = session.getLine(row);
  495. var match = line.match(this.foldingStartMarker);
  496. if (match) {
  497. var i = match.index;
  498. if (match[1])
  499. return this.openingBracketBlock(session, match[1], row, i);
  500. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  501. if (range && !range.isMultiLine()) {
  502. if (forceMultiline) {
  503. range = this.getSectionRange(session, row);
  504. } else if (foldStyle != "all")
  505. range = null;
  506. }
  507. return range;
  508. }
  509. if (foldStyle === "markbegin")
  510. return;
  511. var match = line.match(this.foldingStopMarker);
  512. if (match) {
  513. var i = match.index + match[0].length;
  514. if (match[1])
  515. return this.closingBracketBlock(session, match[1], row, i);
  516. return session.getCommentFoldRange(row, i, -1);
  517. }
  518. };
  519. this.getSectionRange = function(session, row) {
  520. var line = session.getLine(row);
  521. var startIndent = line.search(/\S/);
  522. var startRow = row;
  523. var startColumn = line.length;
  524. row = row + 1;
  525. var endRow = row;
  526. var maxRow = session.getLength();
  527. while (++row < maxRow) {
  528. line = session.getLine(row);
  529. var indent = line.search(/\S/);
  530. if (indent === -1)
  531. continue;
  532. if (startIndent > indent)
  533. break;
  534. var subRange = this.getFoldWidgetRange(session, "all", row);
  535. if (subRange) {
  536. if (subRange.start.row <= startRow) {
  537. break;
  538. } else if (subRange.isMultiLine()) {
  539. row = subRange.end.row;
  540. } else if (startIndent == indent) {
  541. break;
  542. }
  543. }
  544. endRow = row;
  545. }
  546. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  547. };
  548. }).call(FoldMode.prototype);
  549. });
  550. 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) {
  551. "use strict";
  552. var oop = require("../lib/oop");
  553. var TextMode = require("./text").Mode;
  554. var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules;
  555. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  556. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  557. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  558. var Mode = function() {
  559. this.HighlightRules = HaxeHighlightRules;
  560. this.$outdent = new MatchingBraceOutdent();
  561. this.$behaviour = new CstyleBehaviour();
  562. this.foldingRules = new CStyleFoldMode();
  563. };
  564. oop.inherits(Mode, TextMode);
  565. (function() {
  566. this.lineCommentStart = "//";
  567. this.blockComment = {start: "/*", end: "*/"};
  568. this.getNextLineIndent = function(state, line, tab) {
  569. var indent = this.$getIndent(line);
  570. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  571. var tokens = tokenizedLine.tokens;
  572. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  573. return indent;
  574. }
  575. if (state == "start") {
  576. var match = line.match(/^.*[\{\(\[]\s*$/);
  577. if (match) {
  578. indent += tab;
  579. }
  580. }
  581. return indent;
  582. };
  583. this.checkOutdent = function(state, line, input) {
  584. return this.$outdent.checkOutdent(line, input);
  585. };
  586. this.autoOutdent = function(state, doc, row) {
  587. this.$outdent.autoOutdent(doc, row);
  588. };
  589. this.$id = "ace/mode/haxe";
  590. }).call(Mode.prototype);
  591. exports.Mode = Mode;
  592. });