mode-groovy-uncompressed.js 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  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. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  251. "u[0-9a-fA-F]{4}|" + // unicode
  252. "[0-2][0-7]{0,2}|" + // oct
  253. "3[0-6][0-7]?|" + // oct
  254. "37[0-7]?|" + // oct
  255. "[4-7][0-7]?|" + //oct
  256. ".)";
  257. // regexp must not have capturing parentheses. Use (?:) instead.
  258. // regexps are ordered -> the first match is used
  259. this.$rules = {
  260. "start" : [
  261. {
  262. token : "comment",
  263. regex : /\/\/.*$/
  264. },
  265. new DocCommentHighlightRules().getStartRule("doc-start"),
  266. {
  267. token : "comment", // multi line comment
  268. merge : true,
  269. regex : /\/\*/,
  270. next : "comment"
  271. }, {
  272. token : "string",
  273. regex : "'",
  274. next : "qstring"
  275. }, {
  276. token : "string",
  277. regex : '"',
  278. next : "qqstring"
  279. }, {
  280. token : "constant.numeric", // hex
  281. regex : /0[xX][0-9a-fA-F]+\b/
  282. }, {
  283. token : "constant.numeric", // float
  284. regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  285. }, { // match stuff like: Sound.prototype.play = function() { }
  286. token : [
  287. "storage.type",
  288. "punctuation.operator",
  289. "support.function",
  290. "punctuation.operator",
  291. "entity.name.function",
  292. "text",
  293. "keyword.operator",
  294. "text",
  295. "storage.type",
  296. "text",
  297. "paren.lparen",
  298. "variable.parameter",
  299. "paren.rparen"
  300. ],
  301. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  302. }, { // match stuff like: Sound.prototype.play = myfunc
  303. token : [
  304. "storage.type",
  305. "punctuation.operator",
  306. "support.function",
  307. "punctuation.operator",
  308. "entity.name.function",
  309. "text",
  310. "keyword.operator",
  311. "text"
  312. ],
  313. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
  314. }, { // match stuff like: Sound.play = function() { }
  315. token : [
  316. "storage.type",
  317. "punctuation.operator",
  318. "entity.name.function",
  319. "text",
  320. "keyword.operator",
  321. "text",
  322. "storage.type",
  323. "text",
  324. "paren.lparen",
  325. "variable.parameter",
  326. "paren.rparen"
  327. ],
  328. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  329. }, { // match stuff like: play = function() { }
  330. token : [
  331. "entity.name.function",
  332. "text",
  333. "keyword.operator",
  334. "text",
  335. "storage.type",
  336. "text",
  337. "paren.lparen",
  338. "variable.parameter",
  339. "paren.rparen"
  340. ],
  341. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  342. }, { // match regular function like: function myFunc(arg) { }
  343. token : [
  344. "storage.type",
  345. "text",
  346. "entity.name.function",
  347. "text",
  348. "paren.lparen",
  349. "variable.parameter",
  350. "paren.rparen"
  351. ],
  352. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
  353. }, { // match stuff like: foobar: function() { }
  354. token : [
  355. "entity.name.function",
  356. "text",
  357. "punctuation.operator",
  358. "text",
  359. "storage.type",
  360. "text",
  361. "paren.lparen",
  362. "variable.parameter",
  363. "paren.rparen"
  364. ],
  365. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  366. }, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
  367. token : [
  368. "text",
  369. "text",
  370. "storage.type",
  371. "text",
  372. "paren.lparen",
  373. "variable.parameter",
  374. "paren.rparen"
  375. ],
  376. regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
  377. }, {
  378. token : "constant.language.boolean",
  379. regex : /(?:true|false)\b/
  380. }, {
  381. token : "keyword",
  382. regex : "(?:" + kwBeforeRe + ")\\b",
  383. next : "regex_allowed"
  384. }, {
  385. token : ["punctuation.operator", "support.function"],
  386. regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
  387. }, {
  388. token : ["punctuation.operator", "support.function.dom"],
  389. regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
  390. }, {
  391. token : ["punctuation.operator", "support.constant"],
  392. regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
  393. }, {
  394. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  395. regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
  396. }, {
  397. token : function(value) {
  398. if (globals.hasOwnProperty(value))
  399. return "variable.language";
  400. else if (deprecated.hasOwnProperty(value))
  401. return "invalid.deprecated";
  402. else if (definitions.hasOwnProperty(value))
  403. return "storage.type";
  404. else if (keywords.hasOwnProperty(value))
  405. return "keyword";
  406. else if (buildinConstants.hasOwnProperty(value))
  407. return "constant.language";
  408. else if (futureReserved.hasOwnProperty(value))
  409. return "invalid.illegal";
  410. else if (value == "debugger")
  411. return "invalid.deprecated";
  412. else
  413. return "identifier";
  414. },
  415. regex : identifierRe
  416. }, {
  417. token : "keyword.operator",
  418. regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
  419. next : "regex_allowed"
  420. }, {
  421. token : "punctuation.operator",
  422. regex : /\?|\:|\,|\;|\./,
  423. next : "regex_allowed"
  424. }, {
  425. token : "paren.lparen",
  426. regex : /[\[({]/,
  427. next : "regex_allowed"
  428. }, {
  429. token : "paren.rparen",
  430. regex : /[\])}]/
  431. }, {
  432. token : "keyword.operator",
  433. regex : /\/=?/,
  434. next : "regex_allowed"
  435. }, {
  436. token: "comment",
  437. regex: /^#!.*$/
  438. }, {
  439. token : "text",
  440. regex : /\s+/
  441. }
  442. ],
  443. // regular expressions are only allowed after certain tokens. This
  444. // makes sure we don't mix up regexps with the divison operator
  445. "regex_allowed": [
  446. {
  447. token : "comment", // multi line comment
  448. merge : true,
  449. regex : "\\/\\*",
  450. next : "comment_regex_allowed"
  451. }, {
  452. token : "comment",
  453. regex : "\\/\\/.*$"
  454. }, {
  455. token: "string.regexp",
  456. regex: "\\/",
  457. next: "regex",
  458. merge: true
  459. }, {
  460. token : "text",
  461. regex : "\\s+"
  462. }, {
  463. // immediately return to the start mode without matching
  464. // anything
  465. token: "empty",
  466. regex: "",
  467. next: "start"
  468. }
  469. ],
  470. "regex": [
  471. {
  472. token: "regexp.keyword.operator",
  473. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
  474. next: "regex"
  475. }, {
  476. // flag
  477. token: "string.regexp",
  478. regex: "/\\w*",
  479. next: "start",
  480. merge: true
  481. }, {
  482. token: "string.regexp",
  483. regex: "[^\\\\/\\[]+",
  484. next: "regex",
  485. merge: true
  486. }, {
  487. token: "string.regexp.charachterclass",
  488. regex: "\\[",
  489. next: "regex_character_class",
  490. merge: true
  491. }, {
  492. token: "empty",
  493. regex: "",
  494. next: "start"
  495. }
  496. ],
  497. "regex_character_class": [
  498. {
  499. token: "regexp.keyword.operator",
  500. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
  501. next: "regex_character_class"
  502. }, {
  503. token: "string.regexp.charachterclass",
  504. regex: "]",
  505. next: "regex",
  506. merge: true
  507. }, {
  508. token: "string.regexp.charachterclass",
  509. regex: "[^\\\\\\]]+",
  510. next: "regex_character_class",
  511. merge: true
  512. }, {
  513. token: "empty",
  514. regex: "",
  515. next: "start"
  516. }
  517. ],
  518. "comment_regex_allowed" : [
  519. {
  520. token : "comment", // closing comment
  521. regex : ".*?\\*\\/",
  522. merge : true,
  523. next : "regex_allowed"
  524. }, {
  525. token : "comment", // comment spanning whole line
  526. merge : true,
  527. regex : ".+"
  528. }
  529. ],
  530. "comment" : [
  531. {
  532. token : "comment", // closing comment
  533. regex : ".*?\\*\\/",
  534. merge : true,
  535. next : "start"
  536. }, {
  537. token : "comment", // comment spanning whole line
  538. merge : true,
  539. regex : ".+"
  540. }
  541. ],
  542. "qqstring" : [
  543. {
  544. token : "constant.language.escape",
  545. regex : escapedRe
  546. }, {
  547. token : "string",
  548. regex : '[^"\\\\]+'
  549. }, {
  550. token : "string",
  551. regex : '"',
  552. next : "start"
  553. }
  554. ],
  555. "qstring" : [
  556. {
  557. token : "constant.language.escape",
  558. regex : escapedRe
  559. }, {
  560. token : "string",
  561. regex : "[^'\\\\]+"
  562. }, {
  563. token : "string",
  564. regex : "'",
  565. next : "start"
  566. }
  567. ]
  568. };
  569. this.embedRules(DocCommentHighlightRules, "doc-",
  570. [ new DocCommentHighlightRules().getEndRule("start") ]);
  571. };
  572. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  573. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  574. });
  575. /* ***** BEGIN LICENSE BLOCK *****
  576. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  577. *
  578. * The contents of this file are subject to the Mozilla Public License Version
  579. * 1.1 (the "License"); you may not use this file except in compliance with
  580. * the License. You may obtain a copy of the License at
  581. * http://www.mozilla.org/MPL/
  582. *
  583. * Software distributed under the License is distributed on an "AS IS" basis,
  584. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  585. * for the specific language governing rights and limitations under the
  586. * License.
  587. *
  588. * The Original Code is Ajax.org Code Editor (ACE).
  589. *
  590. * The Initial Developer of the Original Code is
  591. * Ajax.org B.V.
  592. * Portions created by the Initial Developer are Copyright (C) 2010
  593. * the Initial Developer. All Rights Reserved.
  594. *
  595. * Contributor(s):
  596. * Fabian Jakobs <fabian AT ajax DOT org>
  597. *
  598. * Alternatively, the contents of this file may be used under the terms of
  599. * either the GNU General Public License Version 2 or later (the "GPL"), or
  600. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  601. * in which case the provisions of the GPL or the LGPL are applicable instead
  602. * of those above. If you wish to allow use of your version of this file only
  603. * under the terms of either the GPL or the LGPL, and not to allow others to
  604. * use your version of this file under the terms of the MPL, indicate your
  605. * decision by deleting the provisions above and replace them with the notice
  606. * and other provisions required by the GPL or the LGPL. If you do not delete
  607. * the provisions above, a recipient may use your version of this file under
  608. * the terms of any one of the MPL, the GPL or the LGPL.
  609. *
  610. * ***** END LICENSE BLOCK ***** */
  611. define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  612. "use strict";
  613. var oop = require("../lib/oop");
  614. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  615. var DocCommentHighlightRules = function() {
  616. this.$rules = {
  617. "start" : [ {
  618. token : "comment.doc.tag",
  619. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  620. }, {
  621. token : "comment.doc",
  622. merge : true,
  623. regex : "\\s+"
  624. }, {
  625. token : "comment.doc",
  626. merge : true,
  627. regex : "TODO"
  628. }, {
  629. token : "comment.doc",
  630. merge : true,
  631. regex : "[^@\\*]+"
  632. }, {
  633. token : "comment.doc",
  634. merge : true,
  635. regex : "."
  636. }]
  637. };
  638. };
  639. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  640. (function() {
  641. this.getStartRule = function(start) {
  642. return {
  643. token : "comment.doc", // doc comment
  644. merge : true,
  645. regex : "\\/\\*(?=\\*)",
  646. next : start
  647. };
  648. };
  649. this.getEndRule = function (start) {
  650. return {
  651. token : "comment.doc", // closing comment
  652. merge : true,
  653. regex : "\\*\\/",
  654. next : start
  655. };
  656. };
  657. }).call(DocCommentHighlightRules.prototype);
  658. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  659. });
  660. /* ***** BEGIN LICENSE BLOCK *****
  661. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  662. *
  663. * The contents of this file are subject to the Mozilla Public License Version
  664. * 1.1 (the "License"); you may not use this file except in compliance with
  665. * the License. You may obtain a copy of the License at
  666. * http://www.mozilla.org/MPL/
  667. *
  668. * Software distributed under the License is distributed on an "AS IS" basis,
  669. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  670. * for the specific language governing rights and limitations under the
  671. * License.
  672. *
  673. * The Original Code is Ajax.org Code Editor (ACE).
  674. *
  675. * The Initial Developer of the Original Code is
  676. * Ajax.org B.V.
  677. * Portions created by the Initial Developer are Copyright (C) 2010
  678. * the Initial Developer. All Rights Reserved.
  679. *
  680. * Contributor(s):
  681. * Fabian Jakobs <fabian AT ajax DOT org>
  682. *
  683. * Alternatively, the contents of this file may be used under the terms of
  684. * either the GNU General Public License Version 2 or later (the "GPL"), or
  685. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  686. * in which case the provisions of the GPL or the LGPL are applicable instead
  687. * of those above. If you wish to allow use of your version of this file only
  688. * under the terms of either the GPL or the LGPL, and not to allow others to
  689. * use your version of this file under the terms of the MPL, indicate your
  690. * decision by deleting the provisions above and replace them with the notice
  691. * and other provisions required by the GPL or the LGPL. If you do not delete
  692. * the provisions above, a recipient may use your version of this file under
  693. * the terms of any one of the MPL, the GPL or the LGPL.
  694. *
  695. * ***** END LICENSE BLOCK ***** */
  696. define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  697. "use strict";
  698. var Range = require("../range").Range;
  699. var MatchingBraceOutdent = function() {};
  700. (function() {
  701. this.checkOutdent = function(line, input) {
  702. if (! /^\s+$/.test(line))
  703. return false;
  704. return /^\s*\}/.test(input);
  705. };
  706. this.autoOutdent = function(doc, row) {
  707. var line = doc.getLine(row);
  708. var match = line.match(/^(\s*\})/);
  709. if (!match) return 0;
  710. var column = match[1].length;
  711. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  712. if (!openBracePos || openBracePos.row == row) return 0;
  713. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  714. doc.replace(new Range(row, 0, row, column-1), indent);
  715. };
  716. this.$getIndent = function(line) {
  717. var match = line.match(/^(\s+)/);
  718. if (match) {
  719. return match[1];
  720. }
  721. return "";
  722. };
  723. }).call(MatchingBraceOutdent.prototype);
  724. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  725. });
  726. /* vim:ts=4:sts=4:sw=4:
  727. * ***** BEGIN LICENSE BLOCK *****
  728. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  729. *
  730. * The contents of this file are subject to the Mozilla Public License Version
  731. * 1.1 (the "License"); you may not use this file except in compliance with
  732. * the License. You may obtain a copy of the License at
  733. * http://www.mozilla.org/MPL/
  734. *
  735. * Software distributed under the License is distributed on an "AS IS" basis,
  736. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  737. * for the specific language governing rights and limitations under the
  738. * License.
  739. *
  740. * The Original Code is Ajax.org Code Editor (ACE).
  741. *
  742. * The Initial Developer of the Original Code is
  743. * Ajax.org B.V.
  744. * Portions created by the Initial Developer are Copyright (C) 2010
  745. * the Initial Developer. All Rights Reserved.
  746. *
  747. * Contributor(s):
  748. * Chris Spencer <chris.ag.spencer AT googlemail DOT com>
  749. *
  750. * Alternatively, the contents of this file may be used under the terms of
  751. * either the GNU General Public License Version 2 or later (the "GPL"), or
  752. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  753. * in which case the provisions of the GPL or the LGPL are applicable instead
  754. * of those above. If you wish to allow use of your version of this file only
  755. * under the terms of either the GPL or the LGPL, and not to allow others to
  756. * use your version of this file under the terms of the MPL, indicate your
  757. * decision by deleting the provisions above and replace them with the notice
  758. * and other provisions required by the GPL or the LGPL. If you do not delete
  759. * the provisions above, a recipient may use your version of this file under
  760. * the terms of any one of the MPL, the GPL or the LGPL.
  761. *
  762. * ***** END LICENSE BLOCK ***** */
  763. define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
  764. "use strict";
  765. var oop = require("../../lib/oop");
  766. var Behaviour = require('../behaviour').Behaviour;
  767. var CstyleBehaviour = function () {
  768. this.add("braces", "insertion", function (state, action, editor, session, text) {
  769. if (text == '{') {
  770. var selection = editor.getSelectionRange();
  771. var selected = session.doc.getTextRange(selection);
  772. if (selected !== "") {
  773. return {
  774. text: '{' + selected + '}',
  775. selection: false
  776. };
  777. } else {
  778. return {
  779. text: '{}',
  780. selection: [1, 1]
  781. };
  782. }
  783. } else if (text == '}') {
  784. var cursor = editor.getCursorPosition();
  785. var line = session.doc.getLine(cursor.row);
  786. var rightChar = line.substring(cursor.column, cursor.column + 1);
  787. if (rightChar == '}') {
  788. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  789. if (matching !== null) {
  790. return {
  791. text: '',
  792. selection: [1, 1]
  793. };
  794. }
  795. }
  796. } else if (text == "\n") {
  797. var cursor = editor.getCursorPosition();
  798. var line = session.doc.getLine(cursor.row);
  799. var rightChar = line.substring(cursor.column, cursor.column + 1);
  800. if (rightChar == '}') {
  801. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
  802. if (!openBracePos)
  803. return null;
  804. var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
  805. var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
  806. return {
  807. text: '\n' + indent + '\n' + next_indent,
  808. selection: [1, indent.length, 1, indent.length]
  809. };
  810. }
  811. }
  812. });
  813. this.add("braces", "deletion", function (state, action, editor, session, range) {
  814. var selected = session.doc.getTextRange(range);
  815. if (!range.isMultiLine() && selected == '{') {
  816. var line = session.doc.getLine(range.start.row);
  817. var rightChar = line.substring(range.end.column, range.end.column + 1);
  818. if (rightChar == '}') {
  819. range.end.column++;
  820. return range;
  821. }
  822. }
  823. });
  824. this.add("parens", "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. }
  853. });
  854. this.add("parens", "deletion", function (state, action, editor, session, range) {
  855. var selected = session.doc.getTextRange(range);
  856. if (!range.isMultiLine() && selected == '(') {
  857. var line = session.doc.getLine(range.start.row);
  858. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  859. if (rightChar == ')') {
  860. range.end.column++;
  861. return range;
  862. }
  863. }
  864. });
  865. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  866. if (text == '"' || text == "'") {
  867. var quote = text;
  868. var selection = editor.getSelectionRange();
  869. var selected = session.doc.getTextRange(selection);
  870. if (selected !== "") {
  871. return {
  872. text: quote + selected + quote,
  873. selection: false
  874. };
  875. } else {
  876. var cursor = editor.getCursorPosition();
  877. var line = session.doc.getLine(cursor.row);
  878. var leftChar = line.substring(cursor.column-1, cursor.column);
  879. // We're escaped.
  880. if (leftChar == '\\') {
  881. return null;
  882. }
  883. // Find what token we're inside.
  884. var tokens = session.getTokens(selection.start.row, selection.start.row)[0].tokens;
  885. var col = 0, token;
  886. var quotepos = -1; // Track whether we're inside an open quote.
  887. for (var x = 0; x < tokens.length; x++) {
  888. token = tokens[x];
  889. if (token.type == "string") {
  890. quotepos = -1;
  891. } else if (quotepos < 0) {
  892. quotepos = token.value.indexOf(quote);
  893. }
  894. if ((token.value.length + col) > selection.start.column) {
  895. break;
  896. }
  897. col += tokens[x].value.length;
  898. }
  899. // Try and be smart about when we auto insert.
  900. 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)))) {
  901. return {
  902. text: quote + quote,
  903. selection: [1,1]
  904. };
  905. } else if (token && token.type === "string") {
  906. // Ignore input and move right one if we're typing over the closing quote.
  907. var rightChar = line.substring(cursor.column, cursor.column + 1);
  908. if (rightChar == quote) {
  909. return {
  910. text: '',
  911. selection: [1, 1]
  912. };
  913. }
  914. }
  915. }
  916. }
  917. });
  918. this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
  919. var selected = session.doc.getTextRange(range);
  920. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  921. var line = session.doc.getLine(range.start.row);
  922. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  923. if (rightChar == '"') {
  924. range.end.column++;
  925. return range;
  926. }
  927. }
  928. });
  929. };
  930. oop.inherits(CstyleBehaviour, Behaviour);
  931. exports.CstyleBehaviour = CstyleBehaviour;
  932. });/* ***** BEGIN LICENSE BLOCK *****
  933. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  934. *
  935. * The contents of this file are subject to the Mozilla Public License Version
  936. * 1.1 (the "License"); you may not use this file except in compliance with
  937. * the License. You may obtain a copy of the License at
  938. * http://www.mozilla.org/MPL/
  939. *
  940. * Software distributed under the License is distributed on an "AS IS" basis,
  941. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  942. * for the specific language governing rights and limitations under the
  943. * License.
  944. *
  945. * The Original Code is Ajax.org Code Editor (ACE).
  946. *
  947. * The Initial Developer of the Original Code is
  948. * Ajax.org B.V.
  949. * Portions created by the Initial Developer are Copyright (C) 2010
  950. * the Initial Developer. All Rights Reserved.
  951. *
  952. * Contributor(s):
  953. * Fabian Jakobs <fabian AT ajax DOT org>
  954. *
  955. * Alternatively, the contents of this file may be used under the terms of
  956. * either the GNU General Public License Version 2 or later (the "GPL"), or
  957. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  958. * in which case the provisions of the GPL or the LGPL are applicable instead
  959. * of those above. If you wish to allow use of your version of this file only
  960. * under the terms of either the GPL or the LGPL, and not to allow others to
  961. * use your version of this file under the terms of the MPL, indicate your
  962. * decision by deleting the provisions above and replace them with the notice
  963. * and other provisions required by the GPL or the LGPL. If you do not delete
  964. * the provisions above, a recipient may use your version of this file under
  965. * the terms of any one of the MPL, the GPL or the LGPL.
  966. *
  967. * ***** END LICENSE BLOCK ***** */
  968. define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
  969. "use strict";
  970. var oop = require("../../lib/oop");
  971. var Range = require("../../range").Range;
  972. var BaseFoldMode = require("./fold_mode").FoldMode;
  973. var FoldMode = exports.FoldMode = function() {};
  974. oop.inherits(FoldMode, BaseFoldMode);
  975. (function() {
  976. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  977. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  978. this.getFoldWidgetRange = function(session, foldStyle, row) {
  979. var line = session.getLine(row);
  980. var match = line.match(this.foldingStartMarker);
  981. if (match) {
  982. var i = match.index;
  983. if (match[1])
  984. return this.openingBracketBlock(session, match[1], row, i);
  985. var range = session.getCommentFoldRange(row, i + match[0].length);
  986. range.end.column -= 2;
  987. return range;
  988. }
  989. if (foldStyle !== "markbeginend")
  990. return;
  991. var match = line.match(this.foldingStopMarker);
  992. if (match) {
  993. var i = match.index + match[0].length;
  994. if (match[2]) {
  995. var range = session.getCommentFoldRange(row, i);
  996. range.end.column -= 2;
  997. return range;
  998. }
  999. var end = {row: row, column: i};
  1000. var start = session.$findOpeningBracket(match[1], end);
  1001. if (!start)
  1002. return;
  1003. start.column++;
  1004. end.column--;
  1005. return Range.fromPoints(start, end);
  1006. }
  1007. };
  1008. }).call(FoldMode.prototype);
  1009. });/* ***** BEGIN LICENSE BLOCK *****
  1010. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  1011. *
  1012. * The contents of this file are subject to the Mozilla Public License Version
  1013. * 1.1 (the "License"); you may not use this file except in compliance with
  1014. * the License. You may obtain a copy of the License at
  1015. * http://www.mozilla.org/MPL/
  1016. *
  1017. * Software distributed under the License is distributed on an "AS IS" basis,
  1018. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  1019. * for the specific language governing rights and limitations under the
  1020. * License.
  1021. *
  1022. * The Original Code is Ajax.org Code Editor (ACE).
  1023. *
  1024. * The Initial Developer of the Original Code is
  1025. * Ajax.org B.V.
  1026. * Portions created by the Initial Developer are Copyright (C) 2010
  1027. * the Initial Developer. All Rights Reserved.
  1028. *
  1029. * Contributor(s):
  1030. * Fabian Jakobs <fabian AT ajax DOT org>
  1031. *
  1032. * Alternatively, the contents of this file may be used under the terms of
  1033. * either the GNU General Public License Version 2 or later (the "GPL"), or
  1034. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  1035. * in which case the provisions of the GPL or the LGPL are applicable instead
  1036. * of those above. If you wish to allow use of your version of this file only
  1037. * under the terms of either the GPL or the LGPL, and not to allow others to
  1038. * use your version of this file under the terms of the MPL, indicate your
  1039. * decision by deleting the provisions above and replace them with the notice
  1040. * and other provisions required by the GPL or the LGPL. If you do not delete
  1041. * the provisions above, a recipient may use your version of this file under
  1042. * the terms of any one of the MPL, the GPL or the LGPL.
  1043. *
  1044. * ***** END LICENSE BLOCK ***** */
  1045. define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  1046. "use strict";
  1047. var Range = require("../../range").Range;
  1048. var FoldMode = exports.FoldMode = function() {};
  1049. (function() {
  1050. this.foldingStartMarker = null;
  1051. this.foldingStopMarker = null;
  1052. // must return "" if there's no fold, to enable caching
  1053. this.getFoldWidget = function(session, foldStyle, row) {
  1054. var line = session.getLine(row);
  1055. if (this.foldingStartMarker.test(line))
  1056. return "start";
  1057. if (foldStyle == "markbeginend"
  1058. && this.foldingStopMarker
  1059. && this.foldingStopMarker.test(line))
  1060. return "end";
  1061. return "";
  1062. };
  1063. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1064. return null;
  1065. };
  1066. this.indentationBlock = function(session, row, column) {
  1067. var re = /^\s*/;
  1068. var startRow = row;
  1069. var endRow = row;
  1070. var line = session.getLine(row);
  1071. var startColumn = column || line.length;
  1072. var startLevel = line.match(re)[0].length;
  1073. var maxRow = session.getLength()
  1074. while (++row < maxRow) {
  1075. line = session.getLine(row);
  1076. var level = line.match(re)[0].length;
  1077. if (level == line.length)
  1078. continue;
  1079. if (level <= startLevel)
  1080. break;
  1081. endRow = row;
  1082. }
  1083. if (endRow > startRow) {
  1084. var endColumn = session.getLine(endRow).length;
  1085. return new Range(startRow, startColumn, endRow, endColumn);
  1086. }
  1087. };
  1088. this.openingBracketBlock = function(session, bracket, row, column) {
  1089. var start = {row: row, column: column + 1};
  1090. var end = session.$findClosingBracket(bracket, start);
  1091. if (!end)
  1092. return;
  1093. var fw = session.foldWidgets[end.row];
  1094. if (fw == null)
  1095. fw = this.getFoldWidget(session, end.row);
  1096. if (fw == "start") {
  1097. end.row --;
  1098. end.column = session.getLine(end.row).length;
  1099. }
  1100. return Range.fromPoints(start, end);
  1101. };
  1102. }).call(FoldMode.prototype);
  1103. });
  1104. 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) {
  1105. "use strict";
  1106. var oop = require("../lib/oop");
  1107. var lang = require("../lib/lang");
  1108. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  1109. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1110. var GroovyHighlightRules = function() {
  1111. var keywords = lang.arrayToMap(
  1112. ("assert|with|abstract|continue|for|new|switch|" +
  1113. "assert|default|goto|package|synchronized|" +
  1114. "boolean|do|if|private|this|" +
  1115. "break|double|implements|protected|throw|" +
  1116. "byte|else|import|public|throws|" +
  1117. "case|enum|instanceof|return|transient|" +
  1118. "catch|extends|int|short|try|" +
  1119. "char|final|interface|static|void|" +
  1120. "class|finally|long|strictfp|volatile|" +
  1121. "def|float|native|super|while").split("|")
  1122. );
  1123. var buildinConstants = lang.arrayToMap(
  1124. ("null|Infinity|NaN|undefined").split("|")
  1125. );
  1126. var langClasses = lang.arrayToMap(
  1127. ("AbstractMethodError|AssertionError|ClassCircularityError|"+
  1128. "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
  1129. "ExceptionInInitializerError|IllegalAccessError|"+
  1130. "IllegalThreadStateException|InstantiationError|InternalError|"+
  1131. "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+
  1132. "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+
  1133. "SuppressWarnings|TypeNotPresentException|UnknownError|"+
  1134. "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+
  1135. "InstantiationException|IndexOutOfBoundsException|"+
  1136. "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+
  1137. "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+
  1138. "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+
  1139. "InterruptedException|NoSuchMethodException|IllegalAccessException|"+
  1140. "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+
  1141. "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+
  1142. "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+
  1143. "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+
  1144. "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+
  1145. "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+
  1146. "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+
  1147. "ArrayStoreException|ClassCastException|LinkageError|"+
  1148. "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
  1149. "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
  1150. "Cloneable|Class|CharSequence|Comparable|String|Object").split("|")
  1151. );
  1152. var importClasses = lang.arrayToMap(
  1153. ("").split("|")
  1154. );
  1155. // regexp must not have capturing parentheses. Use (?:) instead.
  1156. // regexps are ordered -> the first match is used
  1157. this.$rules = {
  1158. "start" : [
  1159. {
  1160. token : "comment",
  1161. regex : "\\/\\/.*$"
  1162. },
  1163. new DocCommentHighlightRules().getStartRule("doc-start"),
  1164. {
  1165. token : "comment", // multi line comment
  1166. merge : true,
  1167. regex : "\\/\\*",
  1168. next : "comment"
  1169. }, {
  1170. token : "string.regexp",
  1171. regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  1172. }, {
  1173. token : "string", // single line
  1174. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  1175. }, {
  1176. token : "string", // single line
  1177. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  1178. }, {
  1179. token : "constant.numeric", // hex
  1180. regex : "0[xX][0-9a-fA-F]+\\b"
  1181. }, {
  1182. token : "constant.numeric", // float
  1183. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  1184. }, {
  1185. token : "constant.language.boolean",
  1186. regex : "(?:true|false)\\b"
  1187. }, {
  1188. token : function(value) {
  1189. if (value == "this")
  1190. return "variable.language";
  1191. else if (keywords.hasOwnProperty(value))
  1192. return "keyword";
  1193. else if (langClasses.hasOwnProperty(value))
  1194. return "support.function";
  1195. else if (importClasses.hasOwnProperty(value))
  1196. return "support.function";
  1197. else if (buildinConstants.hasOwnProperty(value))
  1198. return "constant.language";
  1199. else
  1200. return "identifier";
  1201. },
  1202. // TODO: Unicode escape sequences
  1203. // TODO: Unicode identifiers
  1204. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  1205. }, {
  1206. token : "keyword.operator",
  1207. regex : "\\?:|\\?\\.|\\*\\.|<=>|=~|==~|\\.@|\\*\\.@|\\.&|as|in|is|!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
  1208. }, {
  1209. token : "lparen",
  1210. regex : "[[({]"
  1211. }, {
  1212. token : "rparen",
  1213. regex : "[\\])}]"
  1214. }, {
  1215. token : "text",
  1216. regex : "\\s+"
  1217. }
  1218. ],
  1219. "comment" : [
  1220. {
  1221. token : "comment", // closing comment
  1222. regex : ".*?\\*\\/",
  1223. next : "start"
  1224. }, {
  1225. token : "comment", // comment spanning whole line
  1226. merge : true,
  1227. regex : ".+"
  1228. }
  1229. ]
  1230. };
  1231. this.embedRules(DocCommentHighlightRules, "doc-",
  1232. [ new DocCommentHighlightRules().getEndRule("start") ]);
  1233. };
  1234. oop.inherits(GroovyHighlightRules, TextHighlightRules);
  1235. exports.GroovyHighlightRules = GroovyHighlightRules;
  1236. });