mode-javascript-uncompressed.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is Ajax.org Code Editor (ACE).
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Ajax.org B.V.
  18. * Portions created by the Initial Developer are Copyright (C) 2010
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * Fabian Jakobs <fabian AT ajax DOT org>
  23. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. 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) {
  38. "use strict";
  39. var oop = require("../lib/oop");
  40. var TextMode = require("./text").Mode;
  41. var Tokenizer = require("../tokenizer").Tokenizer;
  42. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  43. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  44. var Range = require("../range").Range;
  45. var WorkerClient = require("../worker/worker_client").WorkerClient;
  46. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  47. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  48. var Mode = function() {
  49. this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
  50. this.$outdent = new MatchingBraceOutdent();
  51. this.$behaviour = new CstyleBehaviour();
  52. this.foldingRules = new CStyleFoldMode();
  53. };
  54. oop.inherits(Mode, TextMode);
  55. (function() {
  56. this.toggleCommentLines = function(state, doc, startRow, endRow) {
  57. var outdent = true;
  58. var re = /^(\s*)\/\//;
  59. for (var i=startRow; i<= endRow; i++) {
  60. if (!re.test(doc.getLine(i))) {
  61. outdent = false;
  62. break;
  63. }
  64. }
  65. if (outdent) {
  66. var deleteRange = new Range(0, 0, 0, 0);
  67. for (var i=startRow; i<= endRow; i++)
  68. {
  69. var line = doc.getLine(i);
  70. var m = line.match(re);
  71. deleteRange.start.row = i;
  72. deleteRange.end.row = i;
  73. deleteRange.end.column = m[0].length;
  74. doc.replace(deleteRange, m[1]);
  75. }
  76. }
  77. else {
  78. doc.indentRows(startRow, endRow, "//");
  79. }
  80. };
  81. this.getNextLineIndent = function(state, line, tab) {
  82. var indent = this.$getIndent(line);
  83. var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
  84. var tokens = tokenizedLine.tokens;
  85. var endState = tokenizedLine.state;
  86. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  87. return indent;
  88. }
  89. if (state == "start" || state == "regex_allowed") {
  90. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  91. if (match) {
  92. indent += tab;
  93. }
  94. } else if (state == "doc-start") {
  95. if (endState == "start" || state == "regex_allowed") {
  96. return "";
  97. }
  98. var match = line.match(/^\s*(\/?)\*/);
  99. if (match) {
  100. if (match[1]) {
  101. indent += " ";
  102. }
  103. indent += "* ";
  104. }
  105. }
  106. return indent;
  107. };
  108. this.checkOutdent = function(state, line, input) {
  109. return this.$outdent.checkOutdent(line, input);
  110. };
  111. this.autoOutdent = function(state, doc, row) {
  112. this.$outdent.autoOutdent(doc, row);
  113. };
  114. this.createWorker = function(session) {
  115. var worker = new WorkerClient(["ace"], "worker-javascript.js", "ace/mode/javascript_worker", "JavaScriptWorker");
  116. worker.attachToDocument(session.getDocument());
  117. worker.on("jslint", function(results) {
  118. var errors = [];
  119. for (var i=0; i<results.data.length; i++) {
  120. var error = results.data[i];
  121. if (error)
  122. errors.push({
  123. row: error.line-1,
  124. column: error.character-1,
  125. text: error.reason,
  126. type: "warning",
  127. lint: error
  128. });
  129. }
  130. session.setAnnotations(errors);
  131. });
  132. worker.on("narcissus", function(e) {
  133. session.setAnnotations([e.data]);
  134. });
  135. worker.on("terminate", function() {
  136. session.clearAnnotations();
  137. });
  138. return worker;
  139. };
  140. }).call(Mode.prototype);
  141. exports.Mode = Mode;
  142. });
  143. /* ***** BEGIN LICENSE BLOCK *****
  144. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  145. *
  146. * The contents of this file are subject to the Mozilla Public License Version
  147. * 1.1 (the "License"); you may not use this file except in compliance with
  148. * the License. You may obtain a copy of the License at
  149. * http://www.mozilla.org/MPL/
  150. *
  151. * Software distributed under the License is distributed on an "AS IS" basis,
  152. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  153. * for the specific language governing rights and limitations under the
  154. * License.
  155. *
  156. * The Original Code is Ajax.org Code Editor (ACE).
  157. *
  158. * The Initial Developer of the Original Code is
  159. * Ajax.org B.V.
  160. * Portions created by the Initial Developer are Copyright (C) 2010
  161. * the Initial Developer. All Rights Reserved.
  162. *
  163. * Contributor(s):
  164. * Fabian Jakobs <fabian AT ajax DOT org>
  165. * Mihai Sucan <mihai DOT sucan AT gmail DOT com>
  166. *
  167. * Alternatively, the contents of this file may be used under the terms of
  168. * either the GNU General Public License Version 2 or later (the "GPL"), or
  169. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  170. * in which case the provisions of the GPL or the LGPL are applicable instead
  171. * of those above. If you wish to allow use of your version of this file only
  172. * under the terms of either the GPL or the LGPL, and not to allow others to
  173. * use your version of this file under the terms of the MPL, indicate your
  174. * decision by deleting the provisions above and replace them with the notice
  175. * and other provisions required by the GPL or the LGPL. If you do not delete
  176. * the provisions above, a recipient may use your version of this file under
  177. * the terms of any one of the MPL, the GPL or the LGPL.
  178. *
  179. * ***** END LICENSE BLOCK ***** */
  180. 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) {
  181. "use strict";
  182. var oop = require("../lib/oop");
  183. var lang = require("../lib/lang");
  184. var unicode = require("../unicode");
  185. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  186. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  187. var JavaScriptHighlightRules = function() {
  188. // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
  189. var globals = lang.arrayToMap(
  190. // Constructors
  191. ("Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" +
  192. // E4X
  193. "Namespace|QName|XML|XMLList|" +
  194. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  195. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  196. // Errors
  197. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
  198. "SyntaxError|TypeError|URIError|" +
  199. // Non-constructor functions
  200. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" +
  201. "isNaN|parseFloat|parseInt|" +
  202. // Other
  203. "JSON|Math|" +
  204. // Pseudo
  205. "this|arguments|prototype|window|document"
  206. ).split("|")
  207. );
  208. var keywords = lang.arrayToMap(
  209. ("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  210. "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
  211. "const|yield|import|get|set").split("|")
  212. );
  213. // keywords which can be followed by regular expressions
  214. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
  215. var deprecated = lang.arrayToMap(
  216. ("__parent__|__count__|escape|unescape|with|__proto__").split("|")
  217. );
  218. var definitions = lang.arrayToMap(("const|let|var|function").split("|"));
  219. var buildinConstants = lang.arrayToMap(
  220. ("null|Infinity|NaN|undefined").split("|")
  221. );
  222. var futureReserved = lang.arrayToMap(
  223. ("class|enum|extends|super|export|implements|private|" +
  224. "public|interface|package|protected|static").split("|")
  225. );
  226. // TODO: Unicode escape sequences
  227. var identifierRe = "[" + unicode.packages.L + "\\$_]["
  228. + unicode.packages.L
  229. + unicode.packages.Mn + unicode.packages.Mc
  230. + unicode.packages.Nd
  231. + unicode.packages.Pc + "\\$_]*\\b";
  232. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  233. "u[0-9a-fA-F]{4}|" + // unicode
  234. "[0-2][0-7]{0,2}|" + // oct
  235. "3[0-6][0-7]?|" + // oct
  236. "37[0-7]?|" + // oct
  237. "[4-7][0-7]?|" + //oct
  238. ".)";
  239. // regexp must not have capturing parentheses. Use (?:) instead.
  240. // regexps are ordered -> the first match is used
  241. this.$rules = {
  242. "start" : [
  243. {
  244. token : "comment",
  245. regex : /\/\/.*$/
  246. },
  247. new DocCommentHighlightRules().getStartRule("doc-start"),
  248. {
  249. token : "comment", // multi line comment
  250. merge : true,
  251. regex : /\/\*/,
  252. next : "comment"
  253. }, {
  254. token : "string",
  255. regex : "'",
  256. next : "qstring"
  257. }, {
  258. token : "string",
  259. regex : '"',
  260. next : "qqstring"
  261. }, {
  262. token : "constant.numeric", // hex
  263. regex : /0[xX][0-9a-fA-F]+\b/
  264. }, {
  265. token : "constant.numeric", // float
  266. regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  267. }, { // match stuff like: Sound.prototype.play = function() { }
  268. token : [
  269. "storage.type",
  270. "punctuation.operator",
  271. "support.function",
  272. "punctuation.operator",
  273. "entity.name.function",
  274. "text",
  275. "keyword.operator",
  276. "text",
  277. "storage.type",
  278. "text",
  279. "paren.lparen",
  280. "variable.parameter",
  281. "paren.rparen"
  282. ],
  283. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  284. }, { // match stuff like: Sound.prototype.play = myfunc
  285. token : [
  286. "storage.type",
  287. "punctuation.operator",
  288. "support.function",
  289. "punctuation.operator",
  290. "entity.name.function",
  291. "text",
  292. "keyword.operator",
  293. "text"
  294. ],
  295. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)"
  296. }, { // match stuff like: Sound.play = function() { }
  297. token : [
  298. "storage.type",
  299. "punctuation.operator",
  300. "entity.name.function",
  301. "text",
  302. "keyword.operator",
  303. "text",
  304. "storage.type",
  305. "text",
  306. "paren.lparen",
  307. "variable.parameter",
  308. "paren.rparen"
  309. ],
  310. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  311. }, { // match stuff like: play = function() { }
  312. token : [
  313. "entity.name.function",
  314. "text",
  315. "keyword.operator",
  316. "text",
  317. "storage.type",
  318. "text",
  319. "paren.lparen",
  320. "variable.parameter",
  321. "paren.rparen"
  322. ],
  323. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  324. }, { // match regular function like: function myFunc(arg) { }
  325. token : [
  326. "storage.type",
  327. "text",
  328. "entity.name.function",
  329. "text",
  330. "paren.lparen",
  331. "variable.parameter",
  332. "paren.rparen"
  333. ],
  334. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()(.*?)(\\))"
  335. }, { // match stuff like: foobar: function() { }
  336. token : [
  337. "entity.name.function",
  338. "text",
  339. "punctuation.operator",
  340. "text",
  341. "storage.type",
  342. "text",
  343. "paren.lparen",
  344. "variable.parameter",
  345. "paren.rparen"
  346. ],
  347. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()(.*?)(\\))"
  348. }, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
  349. token : [
  350. "text",
  351. "text",
  352. "storage.type",
  353. "text",
  354. "paren.lparen",
  355. "variable.parameter",
  356. "paren.rparen"
  357. ],
  358. regex : "(:)(\\s*)(function)?(\\s*)(\\()([^)]*)(\\))"
  359. }, {
  360. token : "constant.language.boolean",
  361. regex : /(?:true|false)\b/
  362. }, {
  363. token : "keyword",
  364. regex : "(?:" + kwBeforeRe + ")\\b",
  365. next : "regex_allowed"
  366. }, {
  367. token : ["punctuation.operator", "support.function"],
  368. 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(?=\()/
  369. }, {
  370. token : ["punctuation.operator", "support.function.dom"],
  371. 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(?=\()/
  372. }, {
  373. token : ["punctuation.operator", "support.constant"],
  374. 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/
  375. }, {
  376. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  377. regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
  378. }, {
  379. token : function(value) {
  380. if (globals.hasOwnProperty(value))
  381. return "variable.language";
  382. else if (deprecated.hasOwnProperty(value))
  383. return "invalid.deprecated";
  384. else if (definitions.hasOwnProperty(value))
  385. return "storage.type";
  386. else if (keywords.hasOwnProperty(value))
  387. return "keyword";
  388. else if (buildinConstants.hasOwnProperty(value))
  389. return "constant.language";
  390. else if (futureReserved.hasOwnProperty(value))
  391. return "invalid.illegal";
  392. else if (value == "debugger")
  393. return "invalid.deprecated";
  394. else
  395. return "identifier";
  396. },
  397. regex : identifierRe
  398. }, {
  399. token : "keyword.operator",
  400. regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
  401. next : "regex_allowed"
  402. }, {
  403. token : "punctuation.operator",
  404. regex : /\?|\:|\,|\;|\./,
  405. next : "regex_allowed"
  406. }, {
  407. token : "paren.lparen",
  408. regex : /[\[({]/,
  409. next : "regex_allowed"
  410. }, {
  411. token : "paren.rparen",
  412. regex : /[\])}]/
  413. }, {
  414. token : "keyword.operator",
  415. regex : /\/=?/,
  416. next : "regex_allowed"
  417. }, {
  418. token: "comment",
  419. regex: /^#!.*$/
  420. }, {
  421. token : "text",
  422. regex : /\s+/
  423. }
  424. ],
  425. // regular expressions are only allowed after certain tokens. This
  426. // makes sure we don't mix up regexps with the divison operator
  427. "regex_allowed": [
  428. {
  429. token : "comment", // multi line comment
  430. merge : true,
  431. regex : "\\/\\*",
  432. next : "comment_regex_allowed"
  433. }, {
  434. token : "comment",
  435. regex : "\\/\\/.*$"
  436. }, {
  437. token: "string.regexp",
  438. regex: "\\/",
  439. next: "regex",
  440. merge: true
  441. }, {
  442. token : "text",
  443. regex : "\\s+"
  444. }, {
  445. // immediately return to the start mode without matching
  446. // anything
  447. token: "empty",
  448. regex: "",
  449. next: "start"
  450. }
  451. ],
  452. "regex": [
  453. {
  454. token: "regexp.keyword.operator",
  455. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
  456. next: "regex"
  457. }, {
  458. // flag
  459. token: "string.regexp",
  460. regex: "/\\w*",
  461. next: "start",
  462. merge: true
  463. }, {
  464. token: "string.regexp",
  465. regex: "[^\\\\/\\[]+",
  466. next: "regex",
  467. merge: true
  468. }, {
  469. token: "string.regexp.charachterclass",
  470. regex: "\\[",
  471. next: "regex_character_class",
  472. merge: true
  473. }, {
  474. token: "empty",
  475. regex: "",
  476. next: "start"
  477. }
  478. ],
  479. "regex_character_class": [
  480. {
  481. token: "regexp.keyword.operator",
  482. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)",
  483. next: "regex_character_class"
  484. }, {
  485. token: "string.regexp.charachterclass",
  486. regex: "]",
  487. next: "regex",
  488. merge: true
  489. }, {
  490. token: "string.regexp.charachterclass",
  491. regex: "[^\\\\\\]]+",
  492. next: "regex_character_class",
  493. merge: true
  494. }, {
  495. token: "empty",
  496. regex: "",
  497. next: "start"
  498. }
  499. ],
  500. "comment_regex_allowed" : [
  501. {
  502. token : "comment", // closing comment
  503. regex : ".*?\\*\\/",
  504. merge : true,
  505. next : "regex_allowed"
  506. }, {
  507. token : "comment", // comment spanning whole line
  508. merge : true,
  509. regex : ".+"
  510. }
  511. ],
  512. "comment" : [
  513. {
  514. token : "comment", // closing comment
  515. regex : ".*?\\*\\/",
  516. merge : true,
  517. next : "start"
  518. }, {
  519. token : "comment", // comment spanning whole line
  520. merge : true,
  521. regex : ".+"
  522. }
  523. ],
  524. "qqstring" : [
  525. {
  526. token : "constant.language.escape",
  527. regex : escapedRe
  528. }, {
  529. token : "string",
  530. regex : '[^"\\\\]+'
  531. }, {
  532. token : "string",
  533. regex : '"',
  534. next : "start"
  535. }
  536. ],
  537. "qstring" : [
  538. {
  539. token : "constant.language.escape",
  540. regex : escapedRe
  541. }, {
  542. token : "string",
  543. regex : "[^'\\\\]+"
  544. }, {
  545. token : "string",
  546. regex : "'",
  547. next : "start"
  548. }
  549. ]
  550. };
  551. this.embedRules(DocCommentHighlightRules, "doc-",
  552. [ new DocCommentHighlightRules().getEndRule("start") ]);
  553. };
  554. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  555. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  556. });
  557. /* ***** BEGIN LICENSE BLOCK *****
  558. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  559. *
  560. * The contents of this file are subject to the Mozilla Public License Version
  561. * 1.1 (the "License"); you may not use this file except in compliance with
  562. * the License. You may obtain a copy of the License at
  563. * http://www.mozilla.org/MPL/
  564. *
  565. * Software distributed under the License is distributed on an "AS IS" basis,
  566. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  567. * for the specific language governing rights and limitations under the
  568. * License.
  569. *
  570. * The Original Code is Ajax.org Code Editor (ACE).
  571. *
  572. * The Initial Developer of the Original Code is
  573. * Ajax.org B.V.
  574. * Portions created by the Initial Developer are Copyright (C) 2010
  575. * the Initial Developer. All Rights Reserved.
  576. *
  577. * Contributor(s):
  578. * Fabian Jakobs <fabian AT ajax DOT org>
  579. *
  580. * Alternatively, the contents of this file may be used under the terms of
  581. * either the GNU General Public License Version 2 or later (the "GPL"), or
  582. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  583. * in which case the provisions of the GPL or the LGPL are applicable instead
  584. * of those above. If you wish to allow use of your version of this file only
  585. * under the terms of either the GPL or the LGPL, and not to allow others to
  586. * use your version of this file under the terms of the MPL, indicate your
  587. * decision by deleting the provisions above and replace them with the notice
  588. * and other provisions required by the GPL or the LGPL. If you do not delete
  589. * the provisions above, a recipient may use your version of this file under
  590. * the terms of any one of the MPL, the GPL or the LGPL.
  591. *
  592. * ***** END LICENSE BLOCK ***** */
  593. define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
  594. "use strict";
  595. var oop = require("../lib/oop");
  596. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  597. var DocCommentHighlightRules = function() {
  598. this.$rules = {
  599. "start" : [ {
  600. token : "comment.doc.tag",
  601. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  602. }, {
  603. token : "comment.doc",
  604. merge : true,
  605. regex : "\\s+"
  606. }, {
  607. token : "comment.doc",
  608. merge : true,
  609. regex : "TODO"
  610. }, {
  611. token : "comment.doc",
  612. merge : true,
  613. regex : "[^@\\*]+"
  614. }, {
  615. token : "comment.doc",
  616. merge : true,
  617. regex : "."
  618. }]
  619. };
  620. };
  621. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  622. (function() {
  623. this.getStartRule = function(start) {
  624. return {
  625. token : "comment.doc", // doc comment
  626. merge : true,
  627. regex : "\\/\\*(?=\\*)",
  628. next : start
  629. };
  630. };
  631. this.getEndRule = function (start) {
  632. return {
  633. token : "comment.doc", // closing comment
  634. merge : true,
  635. regex : "\\*\\/",
  636. next : start
  637. };
  638. };
  639. }).call(DocCommentHighlightRules.prototype);
  640. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  641. });
  642. /* ***** BEGIN LICENSE BLOCK *****
  643. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  644. *
  645. * The contents of this file are subject to the Mozilla Public License Version
  646. * 1.1 (the "License"); you may not use this file except in compliance with
  647. * the License. You may obtain a copy of the License at
  648. * http://www.mozilla.org/MPL/
  649. *
  650. * Software distributed under the License is distributed on an "AS IS" basis,
  651. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  652. * for the specific language governing rights and limitations under the
  653. * License.
  654. *
  655. * The Original Code is Ajax.org Code Editor (ACE).
  656. *
  657. * The Initial Developer of the Original Code is
  658. * Ajax.org B.V.
  659. * Portions created by the Initial Developer are Copyright (C) 2010
  660. * the Initial Developer. All Rights Reserved.
  661. *
  662. * Contributor(s):
  663. * Fabian Jakobs <fabian AT ajax DOT org>
  664. *
  665. * Alternatively, the contents of this file may be used under the terms of
  666. * either the GNU General Public License Version 2 or later (the "GPL"), or
  667. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  668. * in which case the provisions of the GPL or the LGPL are applicable instead
  669. * of those above. If you wish to allow use of your version of this file only
  670. * under the terms of either the GPL or the LGPL, and not to allow others to
  671. * use your version of this file under the terms of the MPL, indicate your
  672. * decision by deleting the provisions above and replace them with the notice
  673. * and other provisions required by the GPL or the LGPL. If you do not delete
  674. * the provisions above, a recipient may use your version of this file under
  675. * the terms of any one of the MPL, the GPL or the LGPL.
  676. *
  677. * ***** END LICENSE BLOCK ***** */
  678. define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  679. "use strict";
  680. var Range = require("../range").Range;
  681. var MatchingBraceOutdent = function() {};
  682. (function() {
  683. this.checkOutdent = function(line, input) {
  684. if (! /^\s+$/.test(line))
  685. return false;
  686. return /^\s*\}/.test(input);
  687. };
  688. this.autoOutdent = function(doc, row) {
  689. var line = doc.getLine(row);
  690. var match = line.match(/^(\s*\})/);
  691. if (!match) return 0;
  692. var column = match[1].length;
  693. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  694. if (!openBracePos || openBracePos.row == row) return 0;
  695. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  696. doc.replace(new Range(row, 0, row, column-1), indent);
  697. };
  698. this.$getIndent = function(line) {
  699. var match = line.match(/^(\s+)/);
  700. if (match) {
  701. return match[1];
  702. }
  703. return "";
  704. };
  705. }).call(MatchingBraceOutdent.prototype);
  706. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  707. });
  708. /* vim:ts=4:sts=4:sw=4:
  709. * ***** BEGIN LICENSE BLOCK *****
  710. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  711. *
  712. * The contents of this file are subject to the Mozilla Public License Version
  713. * 1.1 (the "License"); you may not use this file except in compliance with
  714. * the License. You may obtain a copy of the License at
  715. * http://www.mozilla.org/MPL/
  716. *
  717. * Software distributed under the License is distributed on an "AS IS" basis,
  718. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  719. * for the specific language governing rights and limitations under the
  720. * License.
  721. *
  722. * The Original Code is Ajax.org Code Editor (ACE).
  723. *
  724. * The Initial Developer of the Original Code is
  725. * Ajax.org B.V.
  726. * Portions created by the Initial Developer are Copyright (C) 2010
  727. * the Initial Developer. All Rights Reserved.
  728. *
  729. * Contributor(s):
  730. * Chris Spencer <chris.ag.spencer AT googlemail DOT com>
  731. *
  732. * Alternatively, the contents of this file may be used under the terms of
  733. * either the GNU General Public License Version 2 or later (the "GPL"), or
  734. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  735. * in which case the provisions of the GPL or the LGPL are applicable instead
  736. * of those above. If you wish to allow use of your version of this file only
  737. * under the terms of either the GPL or the LGPL, and not to allow others to
  738. * use your version of this file under the terms of the MPL, indicate your
  739. * decision by deleting the provisions above and replace them with the notice
  740. * and other provisions required by the GPL or the LGPL. If you do not delete
  741. * the provisions above, a recipient may use your version of this file under
  742. * the terms of any one of the MPL, the GPL or the LGPL.
  743. *
  744. * ***** END LICENSE BLOCK ***** */
  745. define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
  746. "use strict";
  747. var oop = require("../../lib/oop");
  748. var Behaviour = require('../behaviour').Behaviour;
  749. var CstyleBehaviour = function () {
  750. this.add("braces", "insertion", function (state, action, editor, session, text) {
  751. if (text == '{') {
  752. var selection = editor.getSelectionRange();
  753. var selected = session.doc.getTextRange(selection);
  754. if (selected !== "") {
  755. return {
  756. text: '{' + selected + '}',
  757. selection: false
  758. };
  759. } else {
  760. return {
  761. text: '{}',
  762. selection: [1, 1]
  763. };
  764. }
  765. } else if (text == '}') {
  766. var cursor = editor.getCursorPosition();
  767. var line = session.doc.getLine(cursor.row);
  768. var rightChar = line.substring(cursor.column, cursor.column + 1);
  769. if (rightChar == '}') {
  770. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  771. if (matching !== null) {
  772. return {
  773. text: '',
  774. selection: [1, 1]
  775. };
  776. }
  777. }
  778. } else if (text == "\n") {
  779. var cursor = editor.getCursorPosition();
  780. var line = session.doc.getLine(cursor.row);
  781. var rightChar = line.substring(cursor.column, cursor.column + 1);
  782. if (rightChar == '}') {
  783. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
  784. if (!openBracePos)
  785. return null;
  786. var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
  787. var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
  788. return {
  789. text: '\n' + indent + '\n' + next_indent,
  790. selection: [1, indent.length, 1, indent.length]
  791. };
  792. }
  793. }
  794. });
  795. this.add("braces", "deletion", function (state, action, editor, session, range) {
  796. var selected = session.doc.getTextRange(range);
  797. if (!range.isMultiLine() && selected == '{') {
  798. var line = session.doc.getLine(range.start.row);
  799. var rightChar = line.substring(range.end.column, range.end.column + 1);
  800. if (rightChar == '}') {
  801. range.end.column++;
  802. return range;
  803. }
  804. }
  805. });
  806. this.add("parens", "insertion", function (state, action, editor, session, text) {
  807. if (text == '(') {
  808. var selection = editor.getSelectionRange();
  809. var selected = session.doc.getTextRange(selection);
  810. if (selected !== "") {
  811. return {
  812. text: '(' + selected + ')',
  813. selection: false
  814. };
  815. } else {
  816. return {
  817. text: '()',
  818. selection: [1, 1]
  819. };
  820. }
  821. } else if (text == ')') {
  822. var cursor = editor.getCursorPosition();
  823. var line = session.doc.getLine(cursor.row);
  824. var rightChar = line.substring(cursor.column, cursor.column + 1);
  825. if (rightChar == ')') {
  826. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  827. if (matching !== null) {
  828. return {
  829. text: '',
  830. selection: [1, 1]
  831. };
  832. }
  833. }
  834. }
  835. });
  836. this.add("parens", "deletion", function (state, action, editor, session, range) {
  837. var selected = session.doc.getTextRange(range);
  838. if (!range.isMultiLine() && selected == '(') {
  839. var line = session.doc.getLine(range.start.row);
  840. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  841. if (rightChar == ')') {
  842. range.end.column++;
  843. return range;
  844. }
  845. }
  846. });
  847. this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
  848. if (text == '"' || text == "'") {
  849. var quote = text;
  850. var selection = editor.getSelectionRange();
  851. var selected = session.doc.getTextRange(selection);
  852. if (selected !== "") {
  853. return {
  854. text: quote + selected + quote,
  855. selection: false
  856. };
  857. } else {
  858. var cursor = editor.getCursorPosition();
  859. var line = session.doc.getLine(cursor.row);
  860. var leftChar = line.substring(cursor.column-1, cursor.column);
  861. // We're escaped.
  862. if (leftChar == '\\') {
  863. return null;
  864. }
  865. // Find what token we're inside.
  866. var tokens = session.getTokens(selection.start.row, selection.start.row)[0].tokens;
  867. var col = 0, token;
  868. var quotepos = -1; // Track whether we're inside an open quote.
  869. for (var x = 0; x < tokens.length; x++) {
  870. token = tokens[x];
  871. if (token.type == "string") {
  872. quotepos = -1;
  873. } else if (quotepos < 0) {
  874. quotepos = token.value.indexOf(quote);
  875. }
  876. if ((token.value.length + col) > selection.start.column) {
  877. break;
  878. }
  879. col += tokens[x].value.length;
  880. }
  881. // Try and be smart about when we auto insert.
  882. 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)))) {
  883. return {
  884. text: quote + quote,
  885. selection: [1,1]
  886. };
  887. } else if (token && token.type === "string") {
  888. // Ignore input and move right one if we're typing over the closing quote.
  889. var rightChar = line.substring(cursor.column, cursor.column + 1);
  890. if (rightChar == quote) {
  891. return {
  892. text: '',
  893. selection: [1, 1]
  894. };
  895. }
  896. }
  897. }
  898. }
  899. });
  900. this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
  901. var selected = session.doc.getTextRange(range);
  902. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  903. var line = session.doc.getLine(range.start.row);
  904. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  905. if (rightChar == '"') {
  906. range.end.column++;
  907. return range;
  908. }
  909. }
  910. });
  911. };
  912. oop.inherits(CstyleBehaviour, Behaviour);
  913. exports.CstyleBehaviour = CstyleBehaviour;
  914. });/* ***** BEGIN LICENSE BLOCK *****
  915. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  916. *
  917. * The contents of this file are subject to the Mozilla Public License Version
  918. * 1.1 (the "License"); you may not use this file except in compliance with
  919. * the License. You may obtain a copy of the License at
  920. * http://www.mozilla.org/MPL/
  921. *
  922. * Software distributed under the License is distributed on an "AS IS" basis,
  923. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  924. * for the specific language governing rights and limitations under the
  925. * License.
  926. *
  927. * The Original Code is Ajax.org Code Editor (ACE).
  928. *
  929. * The Initial Developer of the Original Code is
  930. * Ajax.org B.V.
  931. * Portions created by the Initial Developer are Copyright (C) 2010
  932. * the Initial Developer. All Rights Reserved.
  933. *
  934. * Contributor(s):
  935. * Fabian Jakobs <fabian AT ajax DOT org>
  936. *
  937. * Alternatively, the contents of this file may be used under the terms of
  938. * either the GNU General Public License Version 2 or later (the "GPL"), or
  939. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  940. * in which case the provisions of the GPL or the LGPL are applicable instead
  941. * of those above. If you wish to allow use of your version of this file only
  942. * under the terms of either the GPL or the LGPL, and not to allow others to
  943. * use your version of this file under the terms of the MPL, indicate your
  944. * decision by deleting the provisions above and replace them with the notice
  945. * and other provisions required by the GPL or the LGPL. If you do not delete
  946. * the provisions above, a recipient may use your version of this file under
  947. * the terms of any one of the MPL, the GPL or the LGPL.
  948. *
  949. * ***** END LICENSE BLOCK ***** */
  950. define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
  951. "use strict";
  952. var oop = require("../../lib/oop");
  953. var Range = require("../../range").Range;
  954. var BaseFoldMode = require("./fold_mode").FoldMode;
  955. var FoldMode = exports.FoldMode = function() {};
  956. oop.inherits(FoldMode, BaseFoldMode);
  957. (function() {
  958. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  959. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  960. this.getFoldWidgetRange = function(session, foldStyle, row) {
  961. var line = session.getLine(row);
  962. var match = line.match(this.foldingStartMarker);
  963. if (match) {
  964. var i = match.index;
  965. if (match[1])
  966. return this.openingBracketBlock(session, match[1], row, i);
  967. var range = session.getCommentFoldRange(row, i + match[0].length);
  968. range.end.column -= 2;
  969. return range;
  970. }
  971. if (foldStyle !== "markbeginend")
  972. return;
  973. var match = line.match(this.foldingStopMarker);
  974. if (match) {
  975. var i = match.index + match[0].length;
  976. if (match[2]) {
  977. var range = session.getCommentFoldRange(row, i);
  978. range.end.column -= 2;
  979. return range;
  980. }
  981. var end = {row: row, column: i};
  982. var start = session.$findOpeningBracket(match[1], end);
  983. if (!start)
  984. return;
  985. start.column++;
  986. end.column--;
  987. return Range.fromPoints(start, end);
  988. }
  989. };
  990. }).call(FoldMode.prototype);
  991. });/* ***** BEGIN LICENSE BLOCK *****
  992. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  993. *
  994. * The contents of this file are subject to the Mozilla Public License Version
  995. * 1.1 (the "License"); you may not use this file except in compliance with
  996. * the License. You may obtain a copy of the License at
  997. * http://www.mozilla.org/MPL/
  998. *
  999. * Software distributed under the License is distributed on an "AS IS" basis,
  1000. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  1001. * for the specific language governing rights and limitations under the
  1002. * License.
  1003. *
  1004. * The Original Code is Ajax.org Code Editor (ACE).
  1005. *
  1006. * The Initial Developer of the Original Code is
  1007. * Ajax.org B.V.
  1008. * Portions created by the Initial Developer are Copyright (C) 2010
  1009. * the Initial Developer. All Rights Reserved.
  1010. *
  1011. * Contributor(s):
  1012. * Fabian Jakobs <fabian AT ajax DOT org>
  1013. *
  1014. * Alternatively, the contents of this file may be used under the terms of
  1015. * either the GNU General Public License Version 2 or later (the "GPL"), or
  1016. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  1017. * in which case the provisions of the GPL or the LGPL are applicable instead
  1018. * of those above. If you wish to allow use of your version of this file only
  1019. * under the terms of either the GPL or the LGPL, and not to allow others to
  1020. * use your version of this file under the terms of the MPL, indicate your
  1021. * decision by deleting the provisions above and replace them with the notice
  1022. * and other provisions required by the GPL or the LGPL. If you do not delete
  1023. * the provisions above, a recipient may use your version of this file under
  1024. * the terms of any one of the MPL, the GPL or the LGPL.
  1025. *
  1026. * ***** END LICENSE BLOCK ***** */
  1027. define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
  1028. "use strict";
  1029. var Range = require("../../range").Range;
  1030. var FoldMode = exports.FoldMode = function() {};
  1031. (function() {
  1032. this.foldingStartMarker = null;
  1033. this.foldingStopMarker = null;
  1034. // must return "" if there's no fold, to enable caching
  1035. this.getFoldWidget = function(session, foldStyle, row) {
  1036. var line = session.getLine(row);
  1037. if (this.foldingStartMarker.test(line))
  1038. return "start";
  1039. if (foldStyle == "markbeginend"
  1040. && this.foldingStopMarker
  1041. && this.foldingStopMarker.test(line))
  1042. return "end";
  1043. return "";
  1044. };
  1045. this.getFoldWidgetRange = function(session, foldStyle, row) {
  1046. return null;
  1047. };
  1048. this.indentationBlock = function(session, row, column) {
  1049. var re = /^\s*/;
  1050. var startRow = row;
  1051. var endRow = row;
  1052. var line = session.getLine(row);
  1053. var startColumn = column || line.length;
  1054. var startLevel = line.match(re)[0].length;
  1055. var maxRow = session.getLength()
  1056. while (++row < maxRow) {
  1057. line = session.getLine(row);
  1058. var level = line.match(re)[0].length;
  1059. if (level == line.length)
  1060. continue;
  1061. if (level <= startLevel)
  1062. break;
  1063. endRow = row;
  1064. }
  1065. if (endRow > startRow) {
  1066. var endColumn = session.getLine(endRow).length;
  1067. return new Range(startRow, startColumn, endRow, endColumn);
  1068. }
  1069. };
  1070. this.openingBracketBlock = function(session, bracket, row, column) {
  1071. var start = {row: row, column: column + 1};
  1072. var end = session.$findClosingBracket(bracket, start);
  1073. if (!end)
  1074. return;
  1075. var fw = session.foldWidgets[end.row];
  1076. if (fw == null)
  1077. fw = this.getFoldWidget(session, end.row);
  1078. if (fw == "start") {
  1079. end.row --;
  1080. end.column = session.getLine(end.row).length;
  1081. }
  1082. return Range.fromPoints(start, end);
  1083. };
  1084. }).call(FoldMode.prototype);
  1085. });