mode-java-uncompressed.js 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  1. define('ace/mode/java', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/java_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 JavaHighlightRules = require("./java_highlight_rules").JavaHighlightRules;
  7. var Mode = function() {
  8. JavaScriptMode.call(this);
  9. this.$tokenizer = new Tokenizer(new JavaHighlightRules().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/java_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 JavaHighlightRules = function() {
  1111. // taken from http://download.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html
  1112. var keywords = lang.arrayToMap(
  1113. ("abstract|continue|for|new|switch|" +
  1114. "assert|default|goto|package|synchronized|" +
  1115. "boolean|do|if|private|this|" +
  1116. "break|double|implements|protected|throw|" +
  1117. "byte|else|import|public|throws|" +
  1118. "case|enum|instanceof|return|transient|" +
  1119. "catch|extends|int|short|try|" +
  1120. "char|final|interface|static|void|" +
  1121. "class|finally|long|strictfp|volatile|" +
  1122. "const|float|native|super|while").split("|")
  1123. );
  1124. var buildinConstants = lang.arrayToMap(
  1125. ("null|Infinity|NaN|undefined").split("|")
  1126. );
  1127. var langClasses = lang.arrayToMap(
  1128. ("AbstractMethodError|AssertionError|ClassCircularityError|"+
  1129. "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
  1130. "ExceptionInInitializerError|IllegalAccessError|"+
  1131. "IllegalThreadStateException|InstantiationError|InternalError|"+
  1132. "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+
  1133. "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+
  1134. "SuppressWarnings|TypeNotPresentException|UnknownError|"+
  1135. "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+
  1136. "InstantiationException|IndexOutOfBoundsException|"+
  1137. "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+
  1138. "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+
  1139. "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+
  1140. "InterruptedException|NoSuchMethodException|IllegalAccessException|"+
  1141. "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+
  1142. "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+
  1143. "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+
  1144. "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+
  1145. "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+
  1146. "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+
  1147. "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+
  1148. "ArrayStoreException|ClassCastException|LinkageError|"+
  1149. "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
  1150. "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
  1151. "Cloneable|Class|CharSequence|Comparable|String|Object").split("|")
  1152. );
  1153. var importClasses = lang.arrayToMap(
  1154. ("").split("|")
  1155. );
  1156. // regexp must not have capturing parentheses. Use (?:) instead.
  1157. // regexps are ordered -> the first match is used
  1158. this.$rules = {
  1159. "start" : [
  1160. {
  1161. token : "comment",
  1162. regex : "\\/\\/.*$"
  1163. },
  1164. new DocCommentHighlightRules().getStartRule("doc-start"),
  1165. {
  1166. token : "comment", // multi line comment
  1167. merge : true,
  1168. regex : "\\/\\*",
  1169. next : "comment"
  1170. }, {
  1171. token : "string.regexp",
  1172. regex : "[/](?:(?:\\[(?:\\\\]|[^\\]])+\\])|(?:\\\\/|[^\\]/]))*[/]\\w*\\s*(?=[).,;]|$)"
  1173. }, {
  1174. token : "string", // single line
  1175. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  1176. }, {
  1177. token : "string", // single line
  1178. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  1179. }, {
  1180. token : "constant.numeric", // hex
  1181. regex : "0[xX][0-9a-fA-F]+\\b"
  1182. }, {
  1183. token : "constant.numeric", // float
  1184. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  1185. }, {
  1186. token : "constant.language.boolean",
  1187. regex : "(?:true|false)\\b"
  1188. }, {
  1189. token : function(value) {
  1190. if (value == "this")
  1191. return "variable.language";
  1192. else if (keywords.hasOwnProperty(value))
  1193. return "keyword";
  1194. else if (langClasses.hasOwnProperty(value))
  1195. return "support.function";
  1196. else if (importClasses.hasOwnProperty(value))
  1197. return "support.function";
  1198. else if (buildinConstants.hasOwnProperty(value))
  1199. return "constant.language";
  1200. else
  1201. return "identifier";
  1202. },
  1203. // TODO: Unicode escape sequences
  1204. // TODO: Unicode identifiers
  1205. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  1206. }, {
  1207. token : "keyword.operator",
  1208. regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
  1209. }, {
  1210. token : "lparen",
  1211. regex : "[[({]"
  1212. }, {
  1213. token : "rparen",
  1214. regex : "[\\])}]"
  1215. }, {
  1216. token : "text",
  1217. regex : "\\s+"
  1218. }
  1219. ],
  1220. "comment" : [
  1221. {
  1222. token : "comment", // closing comment
  1223. regex : ".*?\\*\\/",
  1224. next : "start"
  1225. }, {
  1226. token : "comment", // comment spanning whole line
  1227. merge : true,
  1228. regex : ".+"
  1229. }
  1230. ]
  1231. };
  1232. this.embedRules(DocCommentHighlightRules, "doc-",
  1233. [ new DocCommentHighlightRules().getEndRule("start") ]);
  1234. };
  1235. oop.inherits(JavaHighlightRules, TextHighlightRules);
  1236. exports.JavaHighlightRules = JavaHighlightRules;
  1237. });