mode-groovy-uncompressed.js 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462
  1. define('ace/mode/groovy', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/groovy_highlight_rules'], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var JavaScriptMode = require("./javascript").Mode;
  5. var Tokenizer = require("../tokenizer").Tokenizer;
  6. var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRules;
  7. var Mode = function() {
  8. JavaScriptMode.call(this);
  9. this.$tokenizer = new Tokenizer(new GroovyHighlightRules().getRules());
  10. };
  11. oop.inherits(Mode, JavaScriptMode);
  12. (function() {
  13. this.createWorker = function(session) {
  14. return null;
  15. };
  16. }).call(Mode.prototype);
  17. exports.Mode = Mode;
  18. });
  19. /* ***** BEGIN LICENSE BLOCK *****
  20. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  21. *
  22. * The contents of this file are subject to the Mozilla Public License Version
  23. * 1.1 (the "License"); you may not use this file except in compliance with
  24. * the License. You may obtain a copy of the License at
  25. * http://www.mozilla.org/MPL/
  26. *
  27. * Software distributed under the License is distributed on an "AS IS" basis,
  28. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  29. * for the specific language governing rights and limitations under the
  30. * License.
  31. *
  32. * The Original Code is Ajax.org Code Editor (ACE).
  33. *
  34. * The Initial Developer of the Original Code is
  35. * Ajax.org B.V.
  36. * Portions created by the Initial Developer are Copyright (C) 2010
  37. * the Initial Developer. All Rights Reserved.
  38. *
  39. * Contributor(s):
  40. * Fabian Jakobs <fabian AT ajax DOT org>
  41. *
  42. * Alternatively, the contents of this file may be used under the terms of
  43. * either the GNU General Public License Version 2 or later (the "GPL"), or
  44. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  45. * in which case the provisions of the GPL or the LGPL are applicable instead
  46. * of those above. If you wish to allow use of your version of this file only
  47. * under the terms of either the GPL or the LGPL, and not to allow others to
  48. * use your version of this file under the terms of the MPL, indicate your
  49. * decision by deleting the provisions above and replace them with the notice
  50. * and other provisions required by the GPL or the LGPL. If you do not delete
  51. * the provisions above, a recipient may use your version of this file under
  52. * the terms of any one of the MPL, the GPL or the LGPL.
  53. *
  54. * ***** END LICENSE BLOCK ***** */
  55. define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
  56. "use strict";
  57. var oop = require("../lib/oop");
  58. var TextMode = require("./text").Mode;
  59. var Tokenizer = require("../tokenizer").Tokenizer;
  60. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  61. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  62. var Range = require("../range").Range;
  63. var WorkerClient = require("../worker/worker_client").WorkerClient;
  64. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  65. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  66. var Mode = function() {
  67. this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
  68. this.$outdent = new MatchingBraceOutdent();
  69. this.$behaviour = new CstyleBehaviour();
  70. this.foldingRules = new CStyleFoldMode();
  71. };
  72. oop.inherits(Mode, TextMode);
  73. (function() {
  74. this.toggleCommentLines = function(state, doc, startRow, endRow) {
  75. var outdent = true;
  76. var re = /^(\s*)\/\//;
  77. for (var i=startRow; i<= endRow; i++) {
  78. if (!re.test(doc.getLine(i))) {
  79. outdent = false;
  80. break;
  81. }
  82. }
  83. if (outdent) {
  84. var deleteRange = new Range(0, 0, 0, 0);
  85. for (var i=startRow; i<= endRow; i++)
  86. {
  87. var line = doc.getLine(i);
  88. var m = line.match(re);
  89. deleteRange.start.row = i;
  90. deleteRange.end.row = i;
  91. deleteRange.end.column = m[0].length;
  92. doc.replace(deleteRange, m[1]);
  93. }
  94. }
  95. else {
  96. doc.indentRows(startRow, endRow, "//");
  97. }
  98. };
  99. this.getNextLineIndent = function(state, line, tab) {
  100. var indent = this.$getIndent(line);
  101. var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
  102. var tokens = tokenizedLine.tokens;
  103. var endState = tokenizedLine.state;
  104. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  105. return indent;
  106. }
  107. if (state == "start" || state == "regex_allowed") {
  108. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  109. if (match) {
  110. indent += tab;
  111. }
  112. } else if (state == "doc-start") {
  113. if (endState == "start" || state == "regex_allowed") {
  114. return "";
  115. }
  116. var match = line.match(/^\s*(\/?)\*/);
  117. if (match) {
  118. if (match[1]) {
  119. indent += " ";
  120. }
  121. indent += "* ";
  122. }
  123. }
  124. return indent;
  125. };
  126. this.checkOutdent = function(state, line, input) {
  127. return this.$outdent.checkOutdent(line, input);
  128. };
  129. this.autoOutdent = function(state, doc, row) {
  130. this.$outdent.autoOutdent(doc, row);
  131. };
  132. this.createWorker = function(session) {
  133. var worker = new WorkerClient(["ace"], "worker-javascript.js", "ace/mode/javascript_worker", "JavaScriptWorker");
  134. worker.attachToDocument(session.getDocument());
  135. worker.on("jslint", function(results) {
  136. var errors = [];
  137. for (var i=0; i<results.data.length; i++) {
  138. var error = results.data[i];
  139. if (error)
  140. errors.push({
  141. row: error.line-1,
  142. column: error.character-1,
  143. text: error.reason,
  144. type: "warning",
  145. lint: error
  146. });
  147. }
  148. session.setAnnotations(errors);
  149. });
  150. worker.on("narcissus", function(e) {
  151. session.setAnnotations([e.data]);
  152. });
  153. worker.on("terminate", function() {
  154. session.clearAnnotations();
  155. });
  156. return worker;
  157. };
  158. }).call(Mode.prototype);
  159. exports.Mode = Mode;
  160. });
  161. /* ***** BEGIN LICENSE BLOCK *****
  162. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  163. *
  164. * The contents of this file are subject to the Mozilla Public License Version
  165. * 1.1 (the "License"); you may not use this file except in compliance with
  166. * the License. You may obtain a copy of the License at
  167. * http://www.mozilla.org/MPL/
  168. *
  169. * Software distributed under the License is distributed on an "AS IS" basis,
  170. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  171. * for the specific language governing rights and limitations under the
  172. * License.
  173. *
  174. * The Original Code is Ajax.org Code Editor (ACE).
  175. *
  176. * The Initial Developer of the Original Code is
  177. * Ajax.org B.V.
  178. * Portions created by the Initial Developer are Copyright (C) 2010
  179. * the Initial Developer. All Rights Reserved.
  180. *
  181. * Contributor(s):
  182. * Fabian Jakobs <fabian AT ajax DOT org>
  183. * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
  184. *
  185. * Alternatively, the contents of this file may be used under the terms of
  186. * either the GNU General Public License Version 2 or later (the "GPL"), or
  187. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  188. * in which case the provisions of the GPL or the LGPL are applicable instead
  189. * of those above. If you wish to allow use of your version of this file only
  190. * under the terms of either the GPL or the LGPL, and not to allow others to
  191. * use your version of this file under the terms of the MPL, indicate your
  192. * decision by deleting the provisions above and replace them with the notice
  193. * and other provisions required by the GPL or the LGPL. If you do not delete
  194. * the provisions above, a recipient may use your version of this file under
  195. * the terms of any one of the MPL, the GPL or the LGPL.
  196. *
  197. * ***** END LICENSE BLOCK ***** */
  198. define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  199. "use strict";
  200. var oop = require("../lib/oop");
  201. var lang = require("../lib/lang");
  202. var unicode = require("../unicode");
  203. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  204. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  205. var JavaScriptHighlightRules = function() {
  206. // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
  207. var globals = lang.arrayToMap(
  208. // Constructors
  209. ("Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" +
  210. // E4X
  211. "Namespace|QName|XML|XMLList|" +
  212. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  213. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  214. // Errors
  215. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
  216. "SyntaxError|TypeError|URIError|" +
  217. // Non-constructor functions
  218. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" +
  219. "isNaN|parseFloat|parseInt|" +
  220. // Other
  221. "JSON|Math|" +
  222. // Pseudo
  223. "this|arguments|prototype|window|document"
  224. ).split("|")
  225. );
  226. var keywords = lang.arrayToMap(
  227. ("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  228. "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
  229. "const|yield|import|get|set").split("|")
  230. );
  231. // keywords which can be followed by regular expressions
  232. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
  233. var deprecated = lang.arrayToMap(
  234. ("__parent__|__count__|escape|unescape|with|__proto__").split("|")
  235. );
  236. var definitions = lang.arrayToMap(("const|let|var|function").split("|"));
  237. var buildinConstants = lang.arrayToMap(
  238. ("null|Infinity|NaN|undefined").split("|")
  239. );
  240. var futureReserved = lang.arrayToMap(
  241. ("class|enum|extends|super|export|implements|private|" +
  242. "public|interface|package|protected|static").split("|")
  243. );
  244. // TODO: Unicode escape sequences
  245. var identifierRe = "[" + unicode.packages.L + "\\$_]["
  246. + unicode.packages.L
  247. + unicode.packages.Mn + unicode.packages.Mc
  248. + unicode.packages.Nd
  249. + unicode.packages.Pc + "\\$_]*\\b";
  250. // regexp must not have capturing parentheses. Use (?:) instead.
  251. // regexps are ordered -> the first match is used
  252. this.$rules = {
  253. "start" : [
  254. {
  255. token : "comment",
  256. regex : "\\/\\/.*$"
  257. },
  258. new DocCommentHighlightRules().getStartRule("doc-start"),
  259. {
  260. token : "comment", // multi line comment
  261. merge : true,
  262. regex : "\\/\\*",
  263. next : "comment"
  264. }, {
  265. token : "string", // single line
  266. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  267. }, {
  268. token : "string", // multi line string start
  269. merge : true,
  270. regex : '["].*\\\\$',
  271. next : "qqstring"
  272. }, {
  273. token : "string", // single line
  274. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  275. }, {
  276. token : "string", // multi line string start
  277. merge : true,
  278. regex : "['].*\\\\$",
  279. next : "qstring"
  280. }, {
  281. token : "constant.numeric", // hex
  282. regex : "0[xX][0-9a-fA-F]+\\b"
  283. }, {
  284. token : "constant.numeric", // float
  285. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  286. }, {
  287. token : ["keyword.definition", "text", "entity.name.function"],
  288. regex : "(function)(\\s+)(" + identifierRe + ")"
  289. }, {
  290. token : "constant.language.boolean",
  291. regex : "(?:true|false)\\b"
  292. }, {
  293. token : "keyword",
  294. regex : "(?:" + kwBeforeRe + ")\\b",
  295. next : "regex_allowed"
  296. }, {
  297. token : function(value) {
  298. if (globals.hasOwnProperty(value))
  299. return "variable.language";
  300. else if (deprecated.hasOwnProperty(value))
  301. return "invalid.deprecated";
  302. else if (definitions.hasOwnProperty(value))
  303. return "keyword.definition";
  304. else if (keywords.hasOwnProperty(value))
  305. return "keyword";
  306. else if (buildinConstants.hasOwnProperty(value))
  307. return "constant.language";
  308. else if (futureReserved.hasOwnProperty(value))
  309. return "invalid.illegal";
  310. else if (value == "debugger")
  311. return "invalid.deprecated";
  312. else
  313. return "identifier";
  314. },
  315. regex : identifierRe
  316. }, {
  317. token : "keyword.operator",
  318. regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)",
  319. next : "regex_allowed"
  320. }, {
  321. token : "punctuation.operator",
  322. regex : "\\?|\\:|\\,|\\;|\\.",
  323. next : "regex_allowed"
  324. }, {
  325. token : "paren.lparen",
  326. regex : "[[({]",
  327. next : "regex_allowed"
  328. }, {
  329. token : "paren.rparen",
  330. regex : "[\\])}]"
  331. }, {
  332. token : "keyword.operator",
  333. regex : "\\/=?",
  334. next : "regex_allowed"
  335. }, {
  336. token: "comment",
  337. regex: "^#!.*$"
  338. }, {
  339. token : "text",
  340. regex : "\\s+"
  341. }
  342. ],
  343. // regular expressions are only allowed after certain tokens. This
  344. // makes sure we don't mix up regexps with the divison operator
  345. "regex_allowed": [
  346. {
  347. token : "comment", // multi line comment
  348. merge : true,
  349. regex : "\\/\\*",
  350. next : "comment_regex_allowed"
  351. }, {
  352. token : "comment",
  353. regex : "\\/\\/.*$"
  354. }, {
  355. token: "string.regexp",
  356. regex: "\\/",
  357. next: "regex",
  358. merge: true
  359. }, {
  360. token : "text",
  361. regex : "\\s+"
  362. }, {
  363. // immediately return to the start mode without matching
  364. // anything
  365. token: "empty",
  366. regex: "",
  367. next: "start"
  368. }
  369. ],
  370. "regex": [
  371. {
  372. token: "regexp.keyword.operator",
  373. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
  374. next: "regex"
  375. }, {
  376. // flag
  377. token: "string.regexp",
  378. regex: "/\\w*",
  379. next: "start",
  380. merge: true
  381. }, {
  382. token: "string.regexp",
  383. regex: "[^\\\\/\\[]+",
  384. next: "regex",
  385. merge: true
  386. }, {
  387. token: "string.regexp.charachterclass",
  388. regex: "\\[",
  389. next: "regex_character_class",
  390. merge: true
  391. }, {
  392. token: "empty",
  393. regex: "",
  394. next: "start"
  395. }
  396. ],
  397. "regex_character_class": [
  398. {
  399. token: "regexp.keyword.operator",
  400. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
  401. next: "regex_character_class"
  402. }, {
  403. token: "string.regexp.charachterclass",
  404. regex: "]",
  405. next: "regex",
  406. merge: true
  407. }, {
  408. token: "string.regexp.charachterclass",
  409. regex: "[^\\\\\\]]+",
  410. next: "regex_character_class",
  411. merge: true
  412. }, {
  413. token: "empty",
  414. regex: "",
  415. next: "start"
  416. }
  417. ],
  418. "comment_regex_allowed" : [
  419. {
  420. token : "comment", // closing comment
  421. regex : ".*?\\*\\/",
  422. merge : true,
  423. next : "regex_allowed"
  424. }, {
  425. token : "comment", // comment spanning whole line
  426. merge : true,
  427. regex : ".+"
  428. }
  429. ],
  430. "comment" : [
  431. {
  432. token : "comment", // closing comment
  433. regex : ".*?\\*\\/",
  434. merge : true,
  435. next : "start"
  436. }, {
  437. token : "comment", // comment spanning whole line
  438. merge : true,
  439. regex : ".+"
  440. }
  441. ],
  442. "qqstring" : [
  443. {
  444. token : "string",
  445. regex : '(?:(?:\\\\.)|(?:[^"\\\\]))*?"',
  446. next : "start"
  447. }, {
  448. token : "string",
  449. merge : true,
  450. regex : '.+'
  451. }
  452. ],
  453. "qstring" : [
  454. {
  455. token : "string",
  456. regex : "(?:(?:\\\\.)|(?:[^'\\\\]))*?'",
  457. next : "start"
  458. }, {
  459. token : "string",
  460. merge : true,
  461. regex : '.+'
  462. }
  463. ]
  464. };
  465. this.embedRules(DocCommentHighlightRules, "doc-",
  466. [ new DocCommentHighlightRules().getEndRule("start") ]);
  467. };
  468. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  469. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  470. });
  471. /* ***** BEGIN LICENSE BLOCK *****
  472. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  473. *
  474. * The contents of this file are subject to the Mozilla Public License Version
  475. * 1.1 (the "License"); you may not use this file except in compliance with
  476. * the License. You may obtain a copy of the License at
  477. * http://www.mozilla.org/MPL/
  478. *
  479. * Software distributed under the License is distributed on an "AS IS" basis,
  480. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  481. * for the specific language governing rights and limitations under the
  482. * License.
  483. *
  484. * The Original Code is Ajax.org Code Editor (ACE).
  485. *
  486. * The Initial Developer of the Original Code is
  487. * Ajax.org B.V.
  488. * Portions created by the Initial Developer are Copyright (C) 2010
  489. * the Initial Developer. All Rights Reserved.
  490. *
  491. * Contributor(s):
  492. * Fabian Jakobs <fabian AT ajax DOT org>
  493. *
  494. * Alternatively, the contents of this file may be used under the terms of
  495. * either the GNU General Public License Version 2 or later (the "GPL"), or
  496. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  497. * in which case the provisions of the GPL or the LGPL are applicable instead
  498. * of those above. If you wish to allow use of your version of this file only
  499. * under the terms of either the GPL or the LGPL, and not to allow others to
  500. * use your version of this file under the terms of the MPL, indicate your
  501. * decision by deleting the provisions above and replace them with the notice
  502. * and other provisions required by the GPL or the LGPL. If you do not delete
  503. * the provisions above, a recipient may use your version of this file under
  504. * the terms of any one of the MPL, the GPL or the LGPL.
  505. *
  506. * ***** END LICENSE BLOCK ***** */
  507. define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  508. "use strict";
  509. var oop = require("../lib/oop");
  510. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  511. var DocCommentHighlightRules = function() {
  512. this.$rules = {
  513. "start" : [ {
  514. token : "comment.doc.tag",
  515. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  516. }, {
  517. token : "comment.doc",
  518. merge : true,
  519. regex : "\\s+"
  520. }, {
  521. token : "comment.doc",
  522. merge : true,
  523. regex : "TODO"
  524. }, {
  525. token : "comment.doc",
  526. merge : true,
  527. regex : "[^@\\*]+"
  528. }, {
  529. token : "comment.doc",
  530. merge : true,
  531. regex : "."
  532. }]
  533. };
  534. };
  535. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  536. (function() {
  537. this.getStartRule = function(start) {
  538. return {
  539. token : "comment.doc", // doc comment
  540. merge : true,
  541. regex : "\\/\\*(?=\\*)",
  542. next : start
  543. };
  544. };
  545. this.getEndRule = function (start) {
  546. return {
  547. token : "comment.doc", // closing comment
  548. merge : true,
  549. regex : "\\*\\/",
  550. next : start
  551. };
  552. };
  553. }).call(DocCommentHighlightRules.prototype);
  554. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  555. });
  556. /* ***** BEGIN LICENSE BLOCK *****
  557. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  558. *
  559. * The contents of this file are subject to the Mozilla Public License Version
  560. * 1.1 (the "License"); you may not use this file except in compliance with
  561. * the License. You may obtain a copy of the License at
  562. * http://www.mozilla.org/MPL/
  563. *
  564. * Software distributed under the License is distributed on an "AS IS" basis,
  565. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  566. * for the specific language governing rights and limitations under the
  567. * License.
  568. *
  569. * The Original Code is Ajax.org Code Editor (ACE).
  570. *
  571. * The Initial Developer of the Original Code is
  572. * Ajax.org B.V.
  573. * Portions created by the Initial Developer are Copyright (C) 2010
  574. * the Initial Developer. All Rights Reserved.
  575. *
  576. * Contributor(s):
  577. * Fabian Jakobs <fabian AT ajax DOT org>
  578. *
  579. * Alternatively, the contents of this file may be used under the terms of
  580. * either the GNU General Public License Version 2 or later (the "GPL"), or
  581. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  582. * in which case the provisions of the GPL or the LGPL are applicable instead
  583. * of those above. If you wish to allow use of your version of this file only
  584. * under the terms of either the GPL or the LGPL, and not to allow others to
  585. * use your version of this file under the terms of the MPL, indicate your
  586. * decision by deleting the provisions above and replace them with the notice
  587. * and other provisions required by the GPL or the LGPL. If you do not delete
  588. * the provisions above, a recipient may use your version of this file under
  589. * the terms of any one of the MPL, the GPL or the LGPL.
  590. *
  591. * ***** END LICENSE BLOCK ***** */
  592. define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  593. "use strict";
  594. var Range = require("../range").Range;
  595. var MatchingBraceOutdent = function() {};
  596. (function() {
  597. this.checkOutdent = function(line, input) {
  598. if (! /^\s+$/.test(line))
  599. return false;
  600. return /^\s*\}/.test(input);
  601. };
  602. this.autoOutdent = function(doc, row) {
  603. var line = doc.getLine(row);
  604. var match = line.match(/^(\s*\})/);
  605. if (!match) return 0;
  606. var column = match[1].length;
  607. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  608. if (!openBracePos || openBracePos.row == row) return 0;
  609. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  610. doc.replace(new Range(row, 0, row, column-1), indent);
  611. };
  612. this.$getIndent = function(line) {
  613. var match = line.match(/^(\s+)/);
  614. if (match) {
  615. return match[1];
  616. }
  617. return "";
  618. };
  619. }).call(MatchingBraceOutdent.prototype);
  620. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  621. });
  622. /* ***** BEGIN LICENSE BLOCK *****
  623. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  624. *
  625. * The contents of this file are subject to the Mozilla Public License Version
  626. * 1.1 (the "License"); you may not use this file except in compliance with
  627. * the License. You may obtain a copy of the License at
  628. * http://www.mozilla.org/MPL/
  629. *
  630. * Software distributed under the License is distributed on an "AS IS" basis,
  631. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  632. * for the specific language governing rights and limitations under the
  633. * License.
  634. *
  635. * The Original Code is Ajax.org Code Editor (ACE).
  636. *
  637. * The Initial Developer of the Original Code is
  638. * Ajax.org B.V.
  639. * Portions created by the Initial Developer are Copyright (C) 2010
  640. * the Initial Developer. All Rights Reserved.
  641. *
  642. * Contributor(s):
  643. * Fabian Jakobs <fabian AT ajax DOT org>
  644. *
  645. * Alternatively, the contents of this file may be used under the terms of
  646. * either the GNU General Public License Version 2 or later (the "GPL"), or
  647. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  648. * in which case the provisions of the GPL or the LGPL are applicable instead
  649. * of those above. If you wish to allow use of your version of this file only
  650. * under the terms of either the GPL or the LGPL, and not to allow others to
  651. * use your version of this file under the terms of the MPL, indicate your
  652. * decision by deleting the provisions above and replace them with the notice
  653. * and other provisions required by the GPL or the LGPL. If you do not delete
  654. * the provisions above, a recipient may use your version of this file under
  655. * the terms of any one of the MPL, the GPL or the LGPL.
  656. *
  657. * ***** END LICENSE BLOCK ***** */
  658. define('ace/worker/worker_client', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
  659. "use strict";
  660. var oop = require("../lib/oop");
  661. var EventEmitter = require("../lib/event_emitter").EventEmitter;
  662. var WorkerClient = function(topLevelNamespaces, packagedJs, mod, classname) {
  663. this.changeListener = this.changeListener.bind(this);
  664. if (module.packaged) {
  665. var base = this.$guessBasePath();
  666. this.$worker = new Worker(base + packagedJs);
  667. }
  668. else {
  669. var workerUrl = this.$normalizePath(require.nameToUrl("ace/worker/worker", null, "_"));
  670. this.$worker = new Worker(workerUrl);
  671. var tlns = {};
  672. for (var i=0; i<topLevelNamespaces.length; i++) {
  673. var ns = topLevelNamespaces[i];
  674. var path = this.$normalizePath(require.nameToUrl(ns, null, "_").replace(/.js$/, ""));
  675. tlns[ns] = path;
  676. }
  677. }
  678. this.$worker.postMessage({
  679. init : true,
  680. tlns: tlns,
  681. module: mod,
  682. classname: classname
  683. });
  684. this.callbackId = 1;
  685. this.callbacks = {};
  686. var _self = this;
  687. this.$worker.onerror = function(e) {
  688. window.console && console.log && console.log(e);
  689. throw e;
  690. };
  691. this.$worker.onmessage = function(e) {
  692. var msg = e.data;
  693. switch(msg.type) {
  694. case "log":
  695. window.console && console.log && console.log(msg.data);
  696. break;
  697. case "event":
  698. _self._emit(msg.name, {data: msg.data});
  699. break;
  700. case "call":
  701. var callback = _self.callbacks[msg.id];
  702. if (callback) {
  703. callback(msg.data);
  704. delete _self.callbacks[msg.id];
  705. }
  706. break;
  707. }
  708. };
  709. };
  710. (function(){
  711. oop.implement(this, EventEmitter);
  712. this.$normalizePath = function(path) {
  713. path = path.replace(/^[a-z]+:\/\/[^\/]+\//, ""); // Remove domain name and rebuild it
  714. path = location.protocol + "//" + location.host
  715. // paths starting with a slash are relative to the root (host)
  716. + (path.charAt(0) == "/" ? "" : location.pathname.replace(/\/[^\/]*$/, ""))
  717. + "/" + path.replace(/^[\/]+/, "");
  718. return path;
  719. };
  720. this.$guessBasePath = function() {
  721. if (require.aceBaseUrl)
  722. return require.aceBaseUrl;
  723. var scripts = document.getElementsByTagName("script");
  724. for (var i=0; i<scripts.length; i++) {
  725. var script = scripts[i];
  726. var base = script.getAttribute("data-ace-base");
  727. if (base)
  728. return base.replace(/\/*$/, "/");
  729. var src = script.src || script.getAttribute("src");
  730. if (!src) {
  731. continue;
  732. }
  733. var m = src.match(/^(?:(.*\/)ace\.js|(.*\/)ace(-uncompressed)?(-noconflict)?\.js)(?:\?|$)/);
  734. if (m)
  735. return m[1] || m[2];
  736. }
  737. return "";
  738. };
  739. this.terminate = function() {
  740. this._emit("terminate", {});
  741. this.$worker.terminate();
  742. this.$worker = null;
  743. this.$doc.removeEventListener("change", this.changeListener);
  744. this.$doc = null;
  745. };
  746. this.send = function(cmd, args) {
  747. this.$worker.postMessage({command: cmd, args: args});
  748. };
  749. this.call = function(cmd, args, callback) {
  750. if (callback) {
  751. var id = this.callbackId++;
  752. this.callbacks[id] = callback;
  753. args.push(id);
  754. }
  755. this.send(cmd, args);
  756. };
  757. this.emit = function(event, data) {
  758. try {
  759. // firefox refuses to clone objects which have function properties
  760. // TODO: cleanup event
  761. this.$worker.postMessage({event: event, data: {data: data.data}});
  762. }
  763. catch(ex) {}
  764. };
  765. this.attachToDocument = function(doc) {
  766. if(this.$doc)
  767. this.terminate();
  768. this.$doc = doc;
  769. this.call("setValue", [doc.getValue()]);
  770. doc.on("change", this.changeListener);
  771. };
  772. this.changeListener = function(e) {
  773. e.range = {
  774. start: e.data.range.start,
  775. end: e.data.range.end
  776. };
  777. this.emit("change", e);
  778. };
  779. }).call(WorkerClient.prototype);
  780. exports.WorkerClient = WorkerClient;
  781. });
  782. /* vim:ts=4:sts=4:sw=4:
  783. * ***** BEGIN LICENSE BLOCK *****
  784. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  785. *
  786. * The contents of this file are subject to the Mozilla Public License Version
  787. * 1.1 (the "License"); you may not use this file except in compliance with
  788. * the License. You may obtain a copy of the License at
  789. * http://www.mozilla.org/MPL/
  790. *
  791. * Software distributed under the License is distributed on an "AS IS" basis,
  792. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  793. * for the specific language governing rights and limitations under the
  794. * License.
  795. *
  796. * The Original Code is Ajax.org Code Editor (ACE).
  797. *
  798. * The Initial Developer of the Original Code is
  799. * Ajax.org B.V.
  800. * Portions created by the Initial Developer are Copyright (C) 2010
  801. * the Initial Developer. All Rights Reserved.
  802. *
  803. * Contributor(s):
  804. * Chris Spencer <chris.ag.spencer AT googlemail DOT com>
  805. *
  806. * Alternatively, the contents of this file may be used under the terms of
  807. * either the GNU General Public License Version 2 or later (the "GPL"), or
  808. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  809. * in which case the provisions of the GPL or the LGPL are applicable instead
  810. * of those above. If you wish to allow use of your version of this file only
  811. * under the terms of either the GPL or the LGPL, and not to allow others to
  812. * use your version of this file under the terms of the MPL, indicate your
  813. * decision by deleting the provisions above and replace them with the notice
  814. * and other provisions required by the GPL or the LGPL. If you do not delete
  815. * the provisions above, a recipient may use your version of this file under
  816. * the terms of any one of the MPL, the GPL or the LGPL.
  817. *
  818. * ***** END LICENSE BLOCK ***** */
  819. define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
  820. "use strict";
  821. var oop = require("../../lib/oop");
  822. var Behaviour = require('../behaviour').Behaviour;
  823. var CstyleBehaviour = function () {
  824. this.add("braces", "insertion", function (state, action, editor, session, text) {
  825. if (text == '{') {
  826. var selection = editor.getSelectionRange();
  827. var selected = session.doc.getTextRange(selection);
  828. if (selected !== "") {
  829. return {
  830. text: '{' + selected + '}',
  831. selection: false
  832. }
  833. } else {
  834. return {
  835. text: '{}',
  836. selection: [1, 1]
  837. }
  838. }
  839. } else if (text == '}') {
  840. var cursor = editor.getCursorPosition();
  841. var line = session.doc.getLine(cursor.row);
  842. var rightChar = line.substring(cursor.column, cursor.column + 1);
  843. if (rightChar == '}') {
  844. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  845. if (matching !== null) {
  846. return {
  847. text: '',
  848. selection: [1, 1]
  849. }
  850. }
  851. }
  852. } else if (text == "\n") {
  853. var cursor = editor.getCursorPosition();
  854. var line = session.doc.getLine(cursor.row);
  855. var rightChar = line.substring(cursor.column, cursor.column + 1);
  856. if (rightChar == '}') {
  857. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
  858. if (!openBracePos)
  859. return null;
  860. var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
  861. var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
  862. return {
  863. text: '\n' + indent + '\n' + next_indent,
  864. selection: [1, indent.length, 1, indent.length]
  865. }
  866. }
  867. }
  868. });
  869. this.add("braces", "deletion", function (state, action, editor, session, range) {
  870. var selected = session.doc.getTextRange(range);
  871. if (!range.isMultiLine() && selected == '{') {
  872. var line = session.doc.getLine(range.start.row);
  873. var rightChar = line.substring(range.end.column, range.end.column + 1);
  874. if (rightChar == '}') {
  875. range.end.column++;
  876. return range;
  877. }
  878. }
  879. });
  880. this.add("parens", "insertion", function (state, action, editor, session, text) {
  881. if (text == '(') {
  882. var selection = editor.getSelectionRange();
  883. var selected = session.doc.getTextRange(selection);
  884. if (selected !== "") {
  885. return {
  886. text: '(' + selected + ')',
  887. selection: false
  888. }
  889. } else {
  890. return {
  891. text: '()',
  892. selection: [1, 1]
  893. }
  894. }
  895. } else if (text == ')') {
  896. var cursor = editor.getCursorPosition();
  897. var line = session.doc.getLine(cursor.row);
  898. var rightChar = line.substring(cursor.column, cursor.column + 1);
  899. if (rightChar == ')') {
  900. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  901. if (matching !== null) {
  902. return {
  903. text: '',
  904. selection: [1, 1]
  905. }
  906. }
  907. }
  908. }
  909. });
  910. this.add("parens", "deletion", function (state, action, editor, session, range) {
  911. var selected = session.doc.getTextRange(range);
  912. if (!range.isMultiLine() && selected == '(') {
  913. var line = session.doc.getLine(range.start.row);
  914. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  915. if (rightChar == ')') {
  916. range.end.column++;
  917. return range;
  918. }
  919. }
  920. });
  921. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  922. if (text == '"') {
  923. var selection = editor.getSelectionRange();
  924. var selected = session.doc.getTextRange(selection);
  925. if (selected !== "") {
  926. return {
  927. text: '"' + selected + '"',
  928. selection: false
  929. }
  930. } else {
  931. var cursor = editor.getCursorPosition();
  932. var line = session.doc.getLine(cursor.row);
  933. var leftChar = line.substring(cursor.column-1, cursor.column);
  934. // We're escaped.
  935. if (leftChar == '\\') {
  936. return null;
  937. }
  938. // Find what token we're inside.
  939. var tokens = session.getTokens(selection.start.row, selection.start.row)[0].tokens;
  940. var col = 0, token;
  941. var quotepos = -1; // Track whether we're inside an open quote.
  942. for (var x = 0; x < tokens.length; x++) {
  943. token = tokens[x];
  944. if (token.type == "string") {
  945. quotepos = -1;
  946. } else if (quotepos < 0) {
  947. quotepos = token.value.indexOf('"');
  948. }
  949. if ((token.value.length + col) > selection.start.column) {
  950. break;
  951. }
  952. col += tokens[x].value.length;
  953. }
  954. // Try and be smart about when we auto insert.
  955. if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) {
  956. return {
  957. text: '""',
  958. selection: [1,1]
  959. }
  960. } else if (token && token.type === "string") {
  961. // Ignore input and move right one if we're typing over the closing quote.
  962. var rightChar = line.substring(cursor.column, cursor.column + 1);
  963. if (rightChar == '"') {
  964. return {
  965. text: '',
  966. selection: [1, 1]
  967. }
  968. }
  969. }
  970. }
  971. }
  972. });
  973. this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
  974. var selected = session.doc.getTextRange(range);
  975. if (!range.isMultiLine() && selected == '"') {
  976. var line = session.doc.getLine(range.start.row);
  977. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  978. if (rightChar == '"') {
  979. range.end.column++;
  980. return range;
  981. }
  982. }
  983. });
  984. }
  985. oop.inherits(CstyleBehaviour, Behaviour);
  986. exports.CstyleBehaviour = CstyleBehaviour;
  987. });/* ***** BEGIN LICENSE BLOCK *****
  988. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  989. *
  990. * The contents of this file are subject to the Mozilla Public License Version
  991. * 1.1 (the "License"); you may not use this file except in compliance with
  992. * the License. You may obtain a copy of the License at
  993. * http://www.mozilla.org/MPL/
  994. *
  995. * Software distributed under the License is distributed on an "AS IS" basis,
  996. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  997. * for the specific language governing rights and limitations under the
  998. * License.
  999. *
  1000. * The Original Code is Ajax.org Code Editor (ACE).
  1001. *
  1002. * The Initial Developer of the Original Code is
  1003. * Ajax.org B.V.
  1004. * Portions created by the Initial Developer are Copyright (C) 2010
  1005. * the Initial Developer. All Rights Reserved.
  1006. *
  1007. * Contributor(s):
  1008. * Fabian Jakobs <fabian AT ajax DOT org>
  1009. *
  1010. * Alternatively, the contents of this file may be used under the terms of
  1011. * either the GNU General Public License Version 2 or later (the "GPL"), or
  1012. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  1013. * in which case the provisions of the GPL or the LGPL are applicable instead
  1014. * of those above. If you wish to allow use of your version of this file only
  1015. * under the terms of either the GPL or the LGPL, and not to allow others to
  1016. * use your version of this file under the terms of the MPL, indicate your
  1017. * decision by deleting the provisions above and replace them with the notice
  1018. * and other provisions required by the GPL or the LGPL. If you do not delete
  1019. * the provisions above, a recipient may use your version of this file under
  1020. * the terms of any one of the MPL, the GPL or the LGPL.
  1021. *
  1022. * ***** END LICENSE BLOCK ***** */
  1023. define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
  1024. "use strict";
  1025. var oop = require("../../lib/oop");
  1026. var Range = require("../../range").Range;
  1027. var BaseFoldMode = require("./fold_mode").FoldMode;
  1028. var FoldMode = exports.FoldMode = function() {};
  1029. oop.inherits(FoldMode, BaseFoldMode);
  1030. (function() {
  1031. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  1032. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  1033. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1034. var line = session.getLine(row);
  1035. var match = line.match(this.foldingStartMarker);
  1036. if (match) {
  1037. var i = match.index;
  1038. if (match[1])
  1039. return this.openingBracketBlock(session, match[1], row, i);
  1040. var range = session.getCommentFoldRange(row, i + match[0].length);
  1041. range.end.column -= 2;
  1042. return range;
  1043. }
  1044. if (foldStyle !== "markbeginend")
  1045. return;
  1046. var match = line.match(this.foldingStopMarker);
  1047. if (match) {
  1048. var i = match.index + match[0].length;
  1049. if (match[2]) {
  1050. var range = session.getCommentFoldRange(row, i);
  1051. range.end.column -= 2;
  1052. return range;
  1053. }
  1054. var end = {row: row, column: i};
  1055. var start = session.$findOpeningBracket(match[1], end);
  1056. if (!start)
  1057. return;
  1058. start.column++;
  1059. end.column--;
  1060. return Range.fromPoints(start, end);
  1061. }
  1062. };
  1063. }).call(FoldMode.prototype);
  1064. });/* ***** BEGIN LICENSE BLOCK *****
  1065. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  1066. *
  1067. * The contents of this file are subject to the Mozilla Public License Version
  1068. * 1.1 (the "License"); you may not use this file except in compliance with
  1069. * the License. You may obtain a copy of the License at
  1070. * http://www.mozilla.org/MPL/
  1071. *
  1072. * Software distributed under the License is distributed on an "AS IS" basis,
  1073. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  1074. * for the specific language governing rights and limitations under the
  1075. * License.
  1076. *
  1077. * The Original Code is Ajax.org Code Editor (ACE).
  1078. *
  1079. * The Initial Developer of the Original Code is
  1080. * Ajax.org B.V.
  1081. * Portions created by the Initial Developer are Copyright (C) 2010
  1082. * the Initial Developer. All Rights Reserved.
  1083. *
  1084. * Contributor(s):
  1085. * Fabian Jakobs <fabian AT ajax DOT org>
  1086. *
  1087. * Alternatively, the contents of this file may be used under the terms of
  1088. * either the GNU General Public License Version 2 or later (the "GPL"), or
  1089. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  1090. * in which case the provisions of the GPL or the LGPL are applicable instead
  1091. * of those above. If you wish to allow use of your version of this file only
  1092. * under the terms of either the GPL or the LGPL, and not to allow others to
  1093. * use your version of this file under the terms of the MPL, indicate your
  1094. * decision by deleting the provisions above and replace them with the notice
  1095. * and other provisions required by the GPL or the LGPL. If you do not delete
  1096. * the provisions above, a recipient may use your version of this file under
  1097. * the terms of any one of the MPL, the GPL or the LGPL.
  1098. *
  1099. * ***** END LICENSE BLOCK ***** */
  1100. define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  1101. "use strict";
  1102. var Range = require("../../range").Range;
  1103. var FoldMode = exports.FoldMode = function() {};
  1104. (function() {
  1105. this.foldingStartMarker = null;
  1106. this.foldingStopMarker = null;
  1107. // must return "" if there's no fold, to enable caching
  1108. this.getFoldWidget = function(session, foldStyle, row) {
  1109. var line = session.getLine(row);
  1110. if (this.foldingStartMarker.test(line))
  1111. return "start";
  1112. if (foldStyle == "markbeginend"
  1113. && this.foldingStopMarker
  1114. && this.foldingStopMarker.test(line))
  1115. return "end";
  1116. return "";
  1117. };
  1118. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1119. return null;
  1120. };
  1121. this.indentationBlock = function(session, row, column) {
  1122. var re = /^\s*/;
  1123. var startRow = row;
  1124. var endRow = row;
  1125. var line = session.getLine(row);
  1126. var startColumn = column || line.length;
  1127. var startLevel = line.match(re)[0].length;
  1128. var maxRow = session.getLength()
  1129. while (++row < maxRow) {
  1130. line = session.getLine(row);
  1131. var level = line.match(re)[0].length;
  1132. if (level == line.length)
  1133. continue;
  1134. if (level <= startLevel)
  1135. break;
  1136. endRow = row;
  1137. }
  1138. if (endRow > startRow) {
  1139. var endColumn = session.getLine(endRow).length;
  1140. return new Range(startRow, startColumn, endRow, endColumn);
  1141. }
  1142. };
  1143. this.openingBracketBlock = function(session, bracket, row, column) {
  1144. var start = {row: row, column: column + 1};
  1145. var end = session.$findClosingBracket(bracket, start);
  1146. if (!end)
  1147. return;
  1148. var fw = session.foldWidgets[end.row];
  1149. if (fw == null)
  1150. fw = this.getFoldWidget(session, end.row);
  1151. if (fw == "start") {
  1152. end.row --;
  1153. end.column = session.getLine(end.row).length;
  1154. }
  1155. return Range.fromPoints(start, end);
  1156. };
  1157. }).call(FoldMode.prototype);
  1158. });
  1159. define('ace/mode/groovy_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) {
  1160. "use strict";
  1161. var oop = require("../lib/oop");
  1162. var lang = require("../lib/lang");
  1163. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  1164. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1165. var GroovyHighlightRules = function() {
  1166. var keywords = lang.arrayToMap(
  1167. ("assert|with|abstract|continue|for|new|switch|" +
  1168. "assert|default|goto|package|synchronized|" +
  1169. "boolean|do|if|private|this|" +
  1170. "break|double|implements|protected|throw|" +
  1171. "byte|else|import|public|throws|" +
  1172. "case|enum|instanceof|return|transient|" +
  1173. "catch|extends|int|short|try|" +
  1174. "char|final|interface|static|void|" +
  1175. "class|finally|long|strictfp|volatile|" +
  1176. "def|float|native|super|while").split("|")
  1177. );
  1178. var buildinConstants = lang.arrayToMap(
  1179. ("null|Infinity|NaN|undefined").split("|")
  1180. );
  1181. var langClasses = lang.arrayToMap(
  1182. ("AbstractMethodError|AssertionError|ClassCircularityError|"+
  1183. "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
  1184. "ExceptionInInitializerError|IllegalAccessError|"+
  1185. "IllegalThreadStateException|InstantiationError|InternalError|"+
  1186. "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+
  1187. "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+
  1188. "SuppressWarnings|TypeNotPresentException|UnknownError|"+
  1189. "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+
  1190. "InstantiationException|IndexOutOfBoundsException|"+
  1191. "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+
  1192. "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+
  1193. "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+
  1194. "InterruptedException|NoSuchMethodException|IllegalAccessException|"+
  1195. "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+
  1196. "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+
  1197. "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+
  1198. "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+
  1199. "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+
  1200. "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+
  1201. "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+
  1202. "ArrayStoreException|ClassCastException|LinkageError|"+
  1203. "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
  1204. "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
  1205. "Cloneable|Class|CharSequence|Comparable|String|Object").split("|")
  1206. );
  1207. var importClasses = lang.arrayToMap(
  1208. ("").split("|")
  1209. );
  1210. // regexp must not have capturing parentheses. Use (?:) instead.
  1211. // regexps are ordered -> the first match is used
  1212. this.$rules = {
  1213. "start" : [
  1214. {
  1215. token : "comment",
  1216. regex : "\\/\\/.*$"
  1217. },
  1218. new DocCommentHighlightRules().getStartRule("doc-start"),
  1219. {
  1220. token : "comment", // multi line comment
  1221. merge : true,
  1222. regex : "\\/\\*",
  1223. next : "comment"
  1224. }, {
  1225. token : "string.regexp",
  1226. regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  1227. }, {
  1228. token : "string", // single line
  1229. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  1230. }, {
  1231. token : "string", // single line
  1232. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  1233. }, {
  1234. token : "constant.numeric", // hex
  1235. regex : "0[xX][0-9a-fA-F]+\\b"
  1236. }, {
  1237. token : "constant.numeric", // float
  1238. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  1239. }, {
  1240. token : "constant.language.boolean",
  1241. regex : "(?:true|false)\\b"
  1242. }, {
  1243. token : function(value) {
  1244. if (value == "this")
  1245. return "variable.language";
  1246. else if (keywords.hasOwnProperty(value))
  1247. return "keyword";
  1248. else if (langClasses.hasOwnProperty(value))
  1249. return "support.function";
  1250. else if (importClasses.hasOwnProperty(value))
  1251. return "support.function";
  1252. else if (buildinConstants.hasOwnProperty(value))
  1253. return "constant.language";
  1254. else
  1255. return "identifier";
  1256. },
  1257. // TODO: Unicode escape sequences
  1258. // TODO: Unicode identifiers
  1259. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  1260. }, {
  1261. token : "keyword.operator",
  1262. regex : "\\?:|\\?\\.|\\*\\.|<=>|=~|==~|\\.@|\\*\\.@|\\.&|as|in|is|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
  1263. }, {
  1264. token : "lparen",
  1265. regex : "[[({]"
  1266. }, {
  1267. token : "rparen",
  1268. regex : "[\\])}]"
  1269. }, {
  1270. token : "text",
  1271. regex : "\\s+"
  1272. }
  1273. ],
  1274. "comment" : [
  1275. {
  1276. token : "comment", // closing comment
  1277. regex : ".*?\\*\\/",
  1278. next : "start"
  1279. }, {
  1280. token : "comment", // comment spanning whole line
  1281. merge : true,
  1282. regex : ".+"
  1283. }
  1284. ]
  1285. };
  1286. this.embedRules(DocCommentHighlightRules, "doc-",
  1287. [ new DocCommentHighlightRules().getEndRule("start") ]);
  1288. };
  1289. oop.inherits(GroovyHighlightRules, TextHighlightRules);
  1290. exports.GroovyHighlightRules = GroovyHighlightRules;
  1291. });
  1292. ;
  1293. (function() {
  1294. window.require(["ace/ace"], function(a) {
  1295. if (!window.ace)
  1296. window.ace = {};
  1297. for (var key in a) if (a.hasOwnProperty(key))
  1298. ace[key] = a[key];
  1299. });
  1300. })();