mode-java.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  1. define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. }
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. define("ace/mode/javascript_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  46. var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
  47. var JavaScriptHighlightRules = function(options) {
  48. var keywordMapper = this.createKeywordMapper({
  49. "variable.language":
  50. "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
  51. "Namespace|QName|XML|XMLList|" + // E4X
  52. "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
  53. "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
  54. "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
  55. "SyntaxError|TypeError|URIError|" +
  56. "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
  57. "isNaN|parseFloat|parseInt|" +
  58. "JSON|Math|" + // Other
  59. "this|arguments|prototype|window|document" , // Pseudo
  60. "keyword":
  61. "const|yield|import|get|set|" +
  62. "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
  63. "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
  64. "__parent__|__count__|escape|unescape|with|__proto__|" +
  65. "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
  66. "storage.type":
  67. "const|let|var|function",
  68. "constant.language":
  69. "null|Infinity|NaN|undefined",
  70. "support.function":
  71. "alert",
  72. "constant.language.boolean": "true|false"
  73. }, "identifier");
  74. var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
  75. var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
  76. "u[0-9a-fA-F]{4}|" + // unicode
  77. "[0-2][0-7]{0,2}|" + // oct
  78. "3[0-6][0-7]?|" + // oct
  79. "37[0-7]?|" + // oct
  80. "[4-7][0-7]?|" + //oct
  81. ".)";
  82. this.$rules = {
  83. "no_regex" : [
  84. {
  85. token : "comment",
  86. regex : "\\/\\/",
  87. next : "line_comment"
  88. },
  89. DocCommentHighlightRules.getStartRule("doc-start"),
  90. {
  91. token : "comment", // multi line comment
  92. regex : /\/\*/,
  93. next : "comment"
  94. }, {
  95. token : "string",
  96. regex : "'(?=.)",
  97. next : "qstring"
  98. }, {
  99. token : "string",
  100. regex : '"(?=.)',
  101. next : "qqstring"
  102. }, {
  103. token : "constant.numeric", // hex
  104. regex : /0[xX][0-9a-fA-F]+\b/
  105. }, {
  106. token : "constant.numeric", // float
  107. regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
  108. }, {
  109. token : [
  110. "storage.type", "punctuation.operator", "support.function",
  111. "punctuation.operator", "entity.name.function", "text","keyword.operator"
  112. ],
  113. regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
  114. next: "function_arguments"
  115. }, {
  116. token : [
  117. "storage.type", "punctuation.operator", "entity.name.function", "text",
  118. "keyword.operator", "text", "storage.type", "text", "paren.lparen"
  119. ],
  120. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  121. next: "function_arguments"
  122. }, {
  123. token : [
  124. "entity.name.function", "text", "keyword.operator", "text", "storage.type",
  125. "text", "paren.lparen"
  126. ],
  127. regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
  128. next: "function_arguments"
  129. }, {
  130. token : [
  131. "storage.type", "punctuation.operator", "entity.name.function", "text",
  132. "keyword.operator", "text",
  133. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  134. ],
  135. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
  136. next: "function_arguments"
  137. }, {
  138. token : [
  139. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  140. ],
  141. regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
  142. next: "function_arguments"
  143. }, {
  144. token : [
  145. "entity.name.function", "text", "punctuation.operator",
  146. "text", "storage.type", "text", "paren.lparen"
  147. ],
  148. regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
  149. next: "function_arguments"
  150. }, {
  151. token : [
  152. "text", "text", "storage.type", "text", "paren.lparen"
  153. ],
  154. regex : "(:)(\\s*)(function)(\\s*)(\\()",
  155. next: "function_arguments"
  156. }, {
  157. token : "keyword",
  158. regex : "(?:" + kwBeforeRe + ")\\b",
  159. next : "start"
  160. }, {
  161. token : ["support.constant"],
  162. regex : /that\b/
  163. }, {
  164. token : ["storage.type", "punctuation.operator", "support.function.firebug"],
  165. regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
  166. }, {
  167. token : keywordMapper,
  168. regex : identifierRe
  169. }, {
  170. token : "punctuation.operator",
  171. regex : /[.](?![.])/,
  172. next : "property"
  173. }, {
  174. token : "keyword.operator",
  175. regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
  176. next : "start"
  177. }, {
  178. token : "punctuation.operator",
  179. regex : /[?:,;.]/,
  180. next : "start"
  181. }, {
  182. token : "paren.lparen",
  183. regex : /[\[({]/,
  184. next : "start"
  185. }, {
  186. token : "paren.rparen",
  187. regex : /[\])}]/
  188. }, {
  189. token: "comment",
  190. regex: /^#!.*$/
  191. }
  192. ],
  193. property: [{
  194. token : "text",
  195. regex : "\\s+"
  196. }, {
  197. token : [
  198. "storage.type", "punctuation.operator", "entity.name.function", "text",
  199. "keyword.operator", "text",
  200. "storage.type", "text", "entity.name.function", "text", "paren.lparen"
  201. ],
  202. regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()",
  203. next: "function_arguments"
  204. }, {
  205. token : "punctuation.operator",
  206. regex : /[.](?![.])/
  207. }, {
  208. token : "support.function",
  209. regex : /(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:op|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(?=\()/
  210. }, {
  211. token : "support.function.dom",
  212. 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|ClassName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
  213. }, {
  214. token : "support.constant",
  215. 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/
  216. }, {
  217. token : "identifier",
  218. regex : identifierRe
  219. }, {
  220. regex: "",
  221. token: "empty",
  222. next: "no_regex"
  223. }
  224. ],
  225. "start": [
  226. DocCommentHighlightRules.getStartRule("doc-start"),
  227. {
  228. token : "comment", // multi line comment
  229. regex : "\\/\\*",
  230. next : "comment_regex_allowed"
  231. }, {
  232. token : "comment",
  233. regex : "\\/\\/",
  234. next : "line_comment_regex_allowed"
  235. }, {
  236. token: "string.regexp",
  237. regex: "\\/",
  238. next: "regex"
  239. }, {
  240. token : "text",
  241. regex : "\\s+|^$",
  242. next : "start"
  243. }, {
  244. token: "empty",
  245. regex: "",
  246. next: "no_regex"
  247. }
  248. ],
  249. "regex": [
  250. {
  251. token: "regexp.keyword.operator",
  252. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  253. }, {
  254. token: "string.regexp",
  255. regex: "/[sxngimy]*",
  256. next: "no_regex"
  257. }, {
  258. token : "invalid",
  259. regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
  260. }, {
  261. token : "constant.language.escape",
  262. regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
  263. }, {
  264. token : "constant.language.delimiter",
  265. regex: /\|/
  266. }, {
  267. token: "constant.language.escape",
  268. regex: /\[\^?/,
  269. next: "regex_character_class"
  270. }, {
  271. token: "empty",
  272. regex: "$",
  273. next: "no_regex"
  274. }, {
  275. defaultToken: "string.regexp"
  276. }
  277. ],
  278. "regex_character_class": [
  279. {
  280. token: "regexp.charclass.keyword.operator",
  281. regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
  282. }, {
  283. token: "constant.language.escape",
  284. regex: "]",
  285. next: "regex"
  286. }, {
  287. token: "constant.language.escape",
  288. regex: "-"
  289. }, {
  290. token: "empty",
  291. regex: "$",
  292. next: "no_regex"
  293. }, {
  294. defaultToken: "string.regexp.charachterclass"
  295. }
  296. ],
  297. "function_arguments": [
  298. {
  299. token: "variable.parameter",
  300. regex: identifierRe
  301. }, {
  302. token: "punctuation.operator",
  303. regex: "[, ]+"
  304. }, {
  305. token: "punctuation.operator",
  306. regex: "$"
  307. }, {
  308. token: "empty",
  309. regex: "",
  310. next: "no_regex"
  311. }
  312. ],
  313. "comment_regex_allowed" : [
  314. DocCommentHighlightRules.getTagRule(),
  315. {token : "comment", regex : "\\*\\/", next : "start"},
  316. {defaultToken : "comment", caseInsensitive: true}
  317. ],
  318. "comment" : [
  319. DocCommentHighlightRules.getTagRule(),
  320. {token : "comment", regex : "\\*\\/", next : "no_regex"},
  321. {defaultToken : "comment", caseInsensitive: true}
  322. ],
  323. "line_comment_regex_allowed" : [
  324. DocCommentHighlightRules.getTagRule(),
  325. {token : "comment", regex : "$|^", next : "start"},
  326. {defaultToken : "comment", caseInsensitive: true}
  327. ],
  328. "line_comment" : [
  329. DocCommentHighlightRules.getTagRule(),
  330. {token : "comment", regex : "$|^", next : "no_regex"},
  331. {defaultToken : "comment", caseInsensitive: true}
  332. ],
  333. "qqstring" : [
  334. {
  335. token : "constant.language.escape",
  336. regex : escapedRe
  337. }, {
  338. token : "string",
  339. regex : "\\\\$",
  340. next : "qqstring"
  341. }, {
  342. token : "string",
  343. regex : '"|$',
  344. next : "no_regex"
  345. }, {
  346. defaultToken: "string"
  347. }
  348. ],
  349. "qstring" : [
  350. {
  351. token : "constant.language.escape",
  352. regex : escapedRe
  353. }, {
  354. token : "string",
  355. regex : "\\\\$",
  356. next : "qstring"
  357. }, {
  358. token : "string",
  359. regex : "'|$",
  360. next : "no_regex"
  361. }, {
  362. defaultToken: "string"
  363. }
  364. ]
  365. };
  366. if (!options || !options.noES6) {
  367. this.$rules.no_regex.unshift({
  368. regex: "[{}]", onMatch: function(val, state, stack) {
  369. this.next = val == "{" ? this.nextState : "";
  370. if (val == "{" && stack.length) {
  371. stack.unshift("start", state);
  372. return "paren";
  373. }
  374. if (val == "}" && stack.length) {
  375. stack.shift();
  376. this.next = stack.shift();
  377. if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1)
  378. return "paren.quasi.end";
  379. }
  380. return val == "{" ? "paren.lparen" : "paren.rparen";
  381. },
  382. nextState: "start"
  383. }, {
  384. token : "string.quasi.start",
  385. regex : /`/,
  386. push : [{
  387. token : "constant.language.escape",
  388. regex : escapedRe
  389. }, {
  390. token : "paren.quasi.start",
  391. regex : /\${/,
  392. push : "start"
  393. }, {
  394. token : "string.quasi.end",
  395. regex : /`/,
  396. next : "pop"
  397. }, {
  398. defaultToken: "string.quasi"
  399. }]
  400. });
  401. if (!options || !options.noJSX)
  402. JSX.call(this);
  403. }
  404. this.embedRules(DocCommentHighlightRules, "doc-",
  405. [ DocCommentHighlightRules.getEndRule("no_regex") ]);
  406. this.normalizeRules();
  407. };
  408. oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
  409. function JSX() {
  410. var tagRegex = identifierRe.replace("\\d", "\\d\\-");
  411. var jsxTag = {
  412. onMatch : function(val, state, stack) {
  413. var offset = val.charAt(1) == "/" ? 2 : 1;
  414. if (offset == 1) {
  415. if (state != this.nextState)
  416. stack.unshift(this.next, this.nextState, 0);
  417. else
  418. stack.unshift(this.next);
  419. stack[2]++;
  420. } else if (offset == 2) {
  421. if (state == this.nextState) {
  422. stack[1]--;
  423. if (!stack[1] || stack[1] < 0) {
  424. stack.shift();
  425. stack.shift();
  426. }
  427. }
  428. }
  429. return [{
  430. type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml",
  431. value: val.slice(0, offset)
  432. }, {
  433. type: "meta.tag.tag-name.xml",
  434. value: val.substr(offset)
  435. }];
  436. },
  437. regex : "</?" + tagRegex + "",
  438. next: "jsxAttributes",
  439. nextState: "jsx"
  440. };
  441. this.$rules.start.unshift(jsxTag);
  442. var jsxJsRule = {
  443. regex: "{",
  444. token: "paren.quasi.start",
  445. push: "start"
  446. };
  447. this.$rules.jsx = [
  448. jsxJsRule,
  449. jsxTag,
  450. {include : "reference"},
  451. {defaultToken: "string"}
  452. ];
  453. this.$rules.jsxAttributes = [{
  454. token : "meta.tag.punctuation.tag-close.xml",
  455. regex : "/?>",
  456. onMatch : function(value, currentState, stack) {
  457. if (currentState == stack[0])
  458. stack.shift();
  459. if (value.length == 2) {
  460. if (stack[0] == this.nextState)
  461. stack[1]--;
  462. if (!stack[1] || stack[1] < 0) {
  463. stack.splice(0, 2);
  464. }
  465. }
  466. this.next = stack[0] || "start";
  467. return [{type: this.token, value: value}];
  468. },
  469. nextState: "jsx"
  470. },
  471. jsxJsRule,
  472. {
  473. token : "entity.other.attribute-name.xml",
  474. regex : tagRegex
  475. }, {
  476. token : "keyword.operator.attribute-equals.xml",
  477. regex : "="
  478. }, {
  479. token : "text.tag-whitespace.xml",
  480. regex : "\\s+"
  481. }, {
  482. token : "string.attribute-value.xml",
  483. regex : "'",
  484. stateName : "jsx_attr_q",
  485. push : [
  486. {token : "string.attribute-value.xml", regex: "'", next: "pop"},
  487. jsxJsRule,
  488. {include : "reference"},
  489. {defaultToken : "string.attribute-value.xml"}
  490. ]
  491. }, {
  492. token : "string.attribute-value.xml",
  493. regex : '"',
  494. stateName : "jsx_attr_qq",
  495. push : [
  496. jsxJsRule,
  497. {token : "string.attribute-value.xml", regex: '"', next: "pop"},
  498. {include : "reference"},
  499. {defaultToken : "string.attribute-value.xml"}
  500. ]
  501. }];
  502. this.$rules.reference = [{
  503. token : "constant.language.escape.reference.xml",
  504. regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
  505. }];
  506. }
  507. exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
  508. });
  509. define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
  510. "use strict";
  511. var Range = require("../range").Range;
  512. var MatchingBraceOutdent = function() {};
  513. (function() {
  514. this.checkOutdent = function(line, input) {
  515. if (! /^\s+$/.test(line))
  516. return false;
  517. return /^\s*\}/.test(input);
  518. };
  519. this.autoOutdent = function(doc, row) {
  520. var line = doc.getLine(row);
  521. var match = line.match(/^(\s*\})/);
  522. if (!match) return 0;
  523. var column = match[1].length;
  524. var openBracePos = doc.findMatchingBracket({row: row, column: column});
  525. if (!openBracePos || openBracePos.row == row) return 0;
  526. var indent = this.$getIndent(doc.getLine(openBracePos.row));
  527. doc.replace(new Range(row, 0, row, column-1), indent);
  528. };
  529. this.$getIndent = function(line) {
  530. return line.match(/^\s*/)[0];
  531. };
  532. }).call(MatchingBraceOutdent.prototype);
  533. exports.MatchingBraceOutdent = MatchingBraceOutdent;
  534. });
  535. define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
  536. "use strict";
  537. var oop = require("../../lib/oop");
  538. var Behaviour = require("../behaviour").Behaviour;
  539. var TokenIterator = require("../../token_iterator").TokenIterator;
  540. var lang = require("../../lib/lang");
  541. var SAFE_INSERT_IN_TOKENS =
  542. ["text", "paren.rparen", "punctuation.operator"];
  543. var SAFE_INSERT_BEFORE_TOKENS =
  544. ["text", "paren.rparen", "punctuation.operator", "comment"];
  545. var context;
  546. var contextCache = {};
  547. var initContext = function(editor) {
  548. var id = -1;
  549. if (editor.multiSelect) {
  550. id = editor.selection.index;
  551. if (contextCache.rangeCount != editor.multiSelect.rangeCount)
  552. contextCache = {rangeCount: editor.multiSelect.rangeCount};
  553. }
  554. if (contextCache[id])
  555. return context = contextCache[id];
  556. context = contextCache[id] = {
  557. autoInsertedBrackets: 0,
  558. autoInsertedRow: -1,
  559. autoInsertedLineEnd: "",
  560. maybeInsertedBrackets: 0,
  561. maybeInsertedRow: -1,
  562. maybeInsertedLineStart: "",
  563. maybeInsertedLineEnd: ""
  564. };
  565. };
  566. var getWrapped = function(selection, selected, opening, closing) {
  567. var rowDiff = selection.end.row - selection.start.row;
  568. return {
  569. text: opening + selected + closing,
  570. selection: [
  571. 0,
  572. selection.start.column + 1,
  573. rowDiff,
  574. selection.end.column + (rowDiff ? 0 : 1)
  575. ]
  576. };
  577. };
  578. var CstyleBehaviour = function() {
  579. this.add("braces", "insertion", function(state, action, editor, session, text) {
  580. var cursor = editor.getCursorPosition();
  581. var line = session.doc.getLine(cursor.row);
  582. if (text == '{') {
  583. initContext(editor);
  584. var selection = editor.getSelectionRange();
  585. var selected = session.doc.getTextRange(selection);
  586. if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
  587. return getWrapped(selection, selected, '{', '}');
  588. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  589. if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
  590. CstyleBehaviour.recordAutoInsert(editor, session, "}");
  591. return {
  592. text: '{}',
  593. selection: [1, 1]
  594. };
  595. } else {
  596. CstyleBehaviour.recordMaybeInsert(editor, session, "{");
  597. return {
  598. text: '{',
  599. selection: [1, 1]
  600. };
  601. }
  602. }
  603. } else if (text == '}') {
  604. initContext(editor);
  605. var rightChar = line.substring(cursor.column, cursor.column + 1);
  606. if (rightChar == '}') {
  607. var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
  608. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  609. CstyleBehaviour.popAutoInsertedClosing();
  610. return {
  611. text: '',
  612. selection: [1, 1]
  613. };
  614. }
  615. }
  616. } else if (text == "\n" || text == "\r\n") {
  617. initContext(editor);
  618. var closing = "";
  619. if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
  620. closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
  621. CstyleBehaviour.clearMaybeInsertedClosing();
  622. }
  623. var rightChar = line.substring(cursor.column, cursor.column + 1);
  624. if (rightChar === '}') {
  625. var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
  626. if (!openBracePos)
  627. return null;
  628. var next_indent = this.$getIndent(session.getLine(openBracePos.row));
  629. } else if (closing) {
  630. var next_indent = this.$getIndent(line);
  631. } else {
  632. CstyleBehaviour.clearMaybeInsertedClosing();
  633. return;
  634. }
  635. var indent = next_indent + session.getTabString();
  636. return {
  637. text: '\n' + indent + '\n' + next_indent + closing,
  638. selection: [1, indent.length, 1, indent.length]
  639. };
  640. } else {
  641. CstyleBehaviour.clearMaybeInsertedClosing();
  642. }
  643. });
  644. this.add("braces", "deletion", function(state, action, editor, session, range) {
  645. var selected = session.doc.getTextRange(range);
  646. if (!range.isMultiLine() && selected == '{') {
  647. initContext(editor);
  648. var line = session.doc.getLine(range.start.row);
  649. var rightChar = line.substring(range.end.column, range.end.column + 1);
  650. if (rightChar == '}') {
  651. range.end.column++;
  652. return range;
  653. } else {
  654. context.maybeInsertedBrackets--;
  655. }
  656. }
  657. });
  658. this.add("parens", "insertion", function(state, action, editor, session, text) {
  659. if (text == '(') {
  660. initContext(editor);
  661. var selection = editor.getSelectionRange();
  662. var selected = session.doc.getTextRange(selection);
  663. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  664. return getWrapped(selection, selected, '(', ')');
  665. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  666. CstyleBehaviour.recordAutoInsert(editor, session, ")");
  667. return {
  668. text: '()',
  669. selection: [1, 1]
  670. };
  671. }
  672. } else if (text == ')') {
  673. initContext(editor);
  674. var cursor = editor.getCursorPosition();
  675. var line = session.doc.getLine(cursor.row);
  676. var rightChar = line.substring(cursor.column, cursor.column + 1);
  677. if (rightChar == ')') {
  678. var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
  679. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  680. CstyleBehaviour.popAutoInsertedClosing();
  681. return {
  682. text: '',
  683. selection: [1, 1]
  684. };
  685. }
  686. }
  687. }
  688. });
  689. this.add("parens", "deletion", function(state, action, editor, session, range) {
  690. var selected = session.doc.getTextRange(range);
  691. if (!range.isMultiLine() && selected == '(') {
  692. initContext(editor);
  693. var line = session.doc.getLine(range.start.row);
  694. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  695. if (rightChar == ')') {
  696. range.end.column++;
  697. return range;
  698. }
  699. }
  700. });
  701. this.add("brackets", "insertion", function(state, action, editor, session, text) {
  702. if (text == '[') {
  703. initContext(editor);
  704. var selection = editor.getSelectionRange();
  705. var selected = session.doc.getTextRange(selection);
  706. if (selected !== "" && editor.getWrapBehavioursEnabled()) {
  707. return getWrapped(selection, selected, '[', ']');
  708. } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
  709. CstyleBehaviour.recordAutoInsert(editor, session, "]");
  710. return {
  711. text: '[]',
  712. selection: [1, 1]
  713. };
  714. }
  715. } else if (text == ']') {
  716. initContext(editor);
  717. var cursor = editor.getCursorPosition();
  718. var line = session.doc.getLine(cursor.row);
  719. var rightChar = line.substring(cursor.column, cursor.column + 1);
  720. if (rightChar == ']') {
  721. var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
  722. if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
  723. CstyleBehaviour.popAutoInsertedClosing();
  724. return {
  725. text: '',
  726. selection: [1, 1]
  727. };
  728. }
  729. }
  730. }
  731. });
  732. this.add("brackets", "deletion", function(state, action, editor, session, range) {
  733. var selected = session.doc.getTextRange(range);
  734. if (!range.isMultiLine() && selected == '[') {
  735. initContext(editor);
  736. var line = session.doc.getLine(range.start.row);
  737. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  738. if (rightChar == ']') {
  739. range.end.column++;
  740. return range;
  741. }
  742. }
  743. });
  744. this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
  745. if (text == '"' || text == "'") {
  746. initContext(editor);
  747. var quote = text;
  748. var selection = editor.getSelectionRange();
  749. var selected = session.doc.getTextRange(selection);
  750. if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
  751. return getWrapped(selection, selected, quote, quote);
  752. } else if (!selected) {
  753. var cursor = editor.getCursorPosition();
  754. var line = session.doc.getLine(cursor.row);
  755. var leftChar = line.substring(cursor.column-1, cursor.column);
  756. var rightChar = line.substring(cursor.column, cursor.column + 1);
  757. var token = session.getTokenAt(cursor.row, cursor.column);
  758. var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
  759. if (leftChar == "\\" && token && /escape/.test(token.type))
  760. return null;
  761. var stringBefore = token && /string|escape/.test(token.type);
  762. var stringAfter = !rightToken || /string|escape/.test(rightToken.type);
  763. var pair;
  764. if (rightChar == quote) {
  765. pair = stringBefore !== stringAfter;
  766. } else {
  767. if (stringBefore && !stringAfter)
  768. return null; // wrap string with different quote
  769. if (stringBefore && stringAfter)
  770. return null; // do not pair quotes inside strings
  771. var wordRe = session.$mode.tokenRe;
  772. wordRe.lastIndex = 0;
  773. var isWordBefore = wordRe.test(leftChar);
  774. wordRe.lastIndex = 0;
  775. var isWordAfter = wordRe.test(leftChar);
  776. if (isWordBefore || isWordAfter)
  777. return null; // before or after alphanumeric
  778. if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
  779. return null; // there is rightChar and it isn't closing
  780. pair = true;
  781. }
  782. return {
  783. text: pair ? quote + quote : "",
  784. selection: [1,1]
  785. };
  786. }
  787. }
  788. });
  789. this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
  790. var selected = session.doc.getTextRange(range);
  791. if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
  792. initContext(editor);
  793. var line = session.doc.getLine(range.start.row);
  794. var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
  795. if (rightChar == selected) {
  796. range.end.column++;
  797. return range;
  798. }
  799. }
  800. });
  801. };
  802. CstyleBehaviour.isSaneInsertion = function(editor, session) {
  803. var cursor = editor.getCursorPosition();
  804. var iterator = new TokenIterator(session, cursor.row, cursor.column);
  805. if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
  806. var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
  807. if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
  808. return false;
  809. }
  810. iterator.stepForward();
  811. return iterator.getCurrentTokenRow() !== cursor.row ||
  812. this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
  813. };
  814. CstyleBehaviour.$matchTokenType = function(token, types) {
  815. return types.indexOf(token.type || token) > -1;
  816. };
  817. CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
  818. var cursor = editor.getCursorPosition();
  819. var line = session.doc.getLine(cursor.row);
  820. if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
  821. context.autoInsertedBrackets = 0;
  822. context.autoInsertedRow = cursor.row;
  823. context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
  824. context.autoInsertedBrackets++;
  825. };
  826. CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
  827. var cursor = editor.getCursorPosition();
  828. var line = session.doc.getLine(cursor.row);
  829. if (!this.isMaybeInsertedClosing(cursor, line))
  830. context.maybeInsertedBrackets = 0;
  831. context.maybeInsertedRow = cursor.row;
  832. context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
  833. context.maybeInsertedLineEnd = line.substr(cursor.column);
  834. context.maybeInsertedBrackets++;
  835. };
  836. CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
  837. return context.autoInsertedBrackets > 0 &&
  838. cursor.row === context.autoInsertedRow &&
  839. bracket === context.autoInsertedLineEnd[0] &&
  840. line.substr(cursor.column) === context.autoInsertedLineEnd;
  841. };
  842. CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
  843. return context.maybeInsertedBrackets > 0 &&
  844. cursor.row === context.maybeInsertedRow &&
  845. line.substr(cursor.column) === context.maybeInsertedLineEnd &&
  846. line.substr(0, cursor.column) == context.maybeInsertedLineStart;
  847. };
  848. CstyleBehaviour.popAutoInsertedClosing = function() {
  849. context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
  850. context.autoInsertedBrackets--;
  851. };
  852. CstyleBehaviour.clearMaybeInsertedClosing = function() {
  853. if (context) {
  854. context.maybeInsertedBrackets = 0;
  855. context.maybeInsertedRow = -1;
  856. }
  857. };
  858. oop.inherits(CstyleBehaviour, Behaviour);
  859. exports.CstyleBehaviour = CstyleBehaviour;
  860. });
  861. define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  862. "use strict";
  863. var oop = require("../../lib/oop");
  864. var Range = require("../../range").Range;
  865. var BaseFoldMode = require("./fold_mode").FoldMode;
  866. var FoldMode = exports.FoldMode = function(commentRegex) {
  867. if (commentRegex) {
  868. this.foldingStartMarker = new RegExp(
  869. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  870. );
  871. this.foldingStopMarker = new RegExp(
  872. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  873. );
  874. }
  875. };
  876. oop.inherits(FoldMode, BaseFoldMode);
  877. (function() {
  878. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  879. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  880. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  881. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  882. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  883. this._getFoldWidgetBase = this.getFoldWidget;
  884. this.getFoldWidget = function(session, foldStyle, row) {
  885. var line = session.getLine(row);
  886. if (this.singleLineBlockCommentRe.test(line)) {
  887. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  888. return "";
  889. }
  890. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  891. if (!fw && this.startRegionRe.test(line))
  892. return "start"; // lineCommentRegionStart
  893. return fw;
  894. };
  895. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  896. var line = session.getLine(row);
  897. if (this.startRegionRe.test(line))
  898. return this.getCommentRegionBlock(session, line, row);
  899. var match = line.match(this.foldingStartMarker);
  900. if (match) {
  901. var i = match.index;
  902. if (match[1])
  903. return this.openingBracketBlock(session, match[1], row, i);
  904. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  905. if (range && !range.isMultiLine()) {
  906. if (forceMultiline) {
  907. range = this.getSectionRange(session, row);
  908. } else if (foldStyle != "all")
  909. range = null;
  910. }
  911. return range;
  912. }
  913. if (foldStyle === "markbegin")
  914. return;
  915. var match = line.match(this.foldingStopMarker);
  916. if (match) {
  917. var i = match.index + match[0].length;
  918. if (match[1])
  919. return this.closingBracketBlock(session, match[1], row, i);
  920. return session.getCommentFoldRange(row, i, -1);
  921. }
  922. };
  923. this.getSectionRange = function(session, row) {
  924. var line = session.getLine(row);
  925. var startIndent = line.search(/\S/);
  926. var startRow = row;
  927. var startColumn = line.length;
  928. row = row + 1;
  929. var endRow = row;
  930. var maxRow = session.getLength();
  931. while (++row < maxRow) {
  932. line = session.getLine(row);
  933. var indent = line.search(/\S/);
  934. if (indent === -1)
  935. continue;
  936. if (startIndent > indent)
  937. break;
  938. var subRange = this.getFoldWidgetRange(session, "all", row);
  939. if (subRange) {
  940. if (subRange.start.row <= startRow) {
  941. break;
  942. } else if (subRange.isMultiLine()) {
  943. row = subRange.end.row;
  944. } else if (startIndent == indent) {
  945. break;
  946. }
  947. }
  948. endRow = row;
  949. }
  950. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  951. };
  952. this.getCommentRegionBlock = function(session, line, row) {
  953. var startColumn = line.search(/\s*$/);
  954. var maxRow = session.getLength();
  955. var startRow = row;
  956. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  957. var depth = 1;
  958. while (++row < maxRow) {
  959. line = session.getLine(row);
  960. var m = re.exec(line);
  961. if (!m) continue;
  962. if (m[1]) depth--;
  963. else depth++;
  964. if (!depth) break;
  965. }
  966. var endRow = row;
  967. if (endRow > startRow) {
  968. return new Range(startRow, startColumn, endRow, line.length);
  969. }
  970. };
  971. }).call(FoldMode.prototype);
  972. });
  973. define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","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) {
  974. "use strict";
  975. var oop = require("../lib/oop");
  976. var TextMode = require("./text").Mode;
  977. var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
  978. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  979. var Range = require("../range").Range;
  980. var WorkerClient = require("../worker/worker_client").WorkerClient;
  981. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  982. var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  983. var Mode = function() {
  984. this.HighlightRules = JavaScriptHighlightRules;
  985. this.$outdent = new MatchingBraceOutdent();
  986. this.$behaviour = new CstyleBehaviour();
  987. this.foldingRules = new CStyleFoldMode();
  988. };
  989. oop.inherits(Mode, TextMode);
  990. (function() {
  991. this.lineCommentStart = "//";
  992. this.blockComment = {start: "/*", end: "*/"};
  993. this.getNextLineIndent = function(state, line, tab) {
  994. var indent = this.$getIndent(line);
  995. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  996. var tokens = tokenizedLine.tokens;
  997. var endState = tokenizedLine.state;
  998. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  999. return indent;
  1000. }
  1001. if (state == "start" || state == "no_regex") {
  1002. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  1003. if (match) {
  1004. indent += tab;
  1005. }
  1006. } else if (state == "doc-start") {
  1007. if (endState == "start" || endState == "no_regex") {
  1008. return "";
  1009. }
  1010. var match = line.match(/^\s*(\/?)\*/);
  1011. if (match) {
  1012. if (match[1]) {
  1013. indent += " ";
  1014. }
  1015. indent += "* ";
  1016. }
  1017. }
  1018. return indent;
  1019. };
  1020. this.checkOutdent = function(state, line, input) {
  1021. return this.$outdent.checkOutdent(line, input);
  1022. };
  1023. this.autoOutdent = function(state, doc, row) {
  1024. this.$outdent.autoOutdent(doc, row);
  1025. };
  1026. this.createWorker = function(session) {
  1027. var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
  1028. worker.attachToDocument(session.getDocument());
  1029. worker.on("annotate", function(results) {
  1030. session.setAnnotations(results.data);
  1031. });
  1032. worker.on("terminate", function() {
  1033. session.clearAnnotations();
  1034. });
  1035. return worker;
  1036. };
  1037. this.$id = "ace/mode/javascript";
  1038. }).call(Mode.prototype);
  1039. exports.Mode = Mode;
  1040. });
  1041. define("ace/mode/java_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
  1042. "use strict";
  1043. var oop = require("../lib/oop");
  1044. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  1045. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  1046. var JavaHighlightRules = function() {
  1047. var keywords = (
  1048. "abstract|continue|for|new|switch|" +
  1049. "assert|default|goto|package|synchronized|" +
  1050. "boolean|do|if|private|this|" +
  1051. "break|double|implements|protected|throw|" +
  1052. "byte|else|import|public|throws|" +
  1053. "case|enum|instanceof|return|transient|" +
  1054. "catch|extends|int|short|try|" +
  1055. "char|final|interface|static|void|" +
  1056. "class|finally|long|strictfp|volatile|" +
  1057. "const|float|native|super|while"
  1058. );
  1059. var buildinConstants = ("null|Infinity|NaN|undefined");
  1060. var langClasses = (
  1061. "AbstractMethodError|AssertionError|ClassCircularityError|"+
  1062. "ClassFormatError|Deprecated|EnumConstantNotPresentException|"+
  1063. "ExceptionInInitializerError|IllegalAccessError|"+
  1064. "IllegalThreadStateException|InstantiationError|InternalError|"+
  1065. "NegativeArraySizeException|NoSuchFieldError|Override|Process|"+
  1066. "ProcessBuilder|SecurityManager|StringIndexOutOfBoundsException|"+
  1067. "SuppressWarnings|TypeNotPresentException|UnknownError|"+
  1068. "UnsatisfiedLinkError|UnsupportedClassVersionError|VerifyError|"+
  1069. "InstantiationException|IndexOutOfBoundsException|"+
  1070. "ArrayIndexOutOfBoundsException|CloneNotSupportedException|"+
  1071. "NoSuchFieldException|IllegalArgumentException|NumberFormatException|"+
  1072. "SecurityException|Void|InheritableThreadLocal|IllegalStateException|"+
  1073. "InterruptedException|NoSuchMethodException|IllegalAccessException|"+
  1074. "UnsupportedOperationException|Enum|StrictMath|Package|Compiler|"+
  1075. "Readable|Runtime|StringBuilder|Math|IncompatibleClassChangeError|"+
  1076. "NoSuchMethodError|ThreadLocal|RuntimePermission|ArithmeticException|"+
  1077. "NullPointerException|Long|Integer|Short|Byte|Double|Number|Float|"+
  1078. "Character|Boolean|StackTraceElement|Appendable|StringBuffer|"+
  1079. "Iterable|ThreadGroup|Runnable|Thread|IllegalMonitorStateException|"+
  1080. "StackOverflowError|OutOfMemoryError|VirtualMachineError|"+
  1081. "ArrayStoreException|ClassCastException|LinkageError|"+
  1082. "NoClassDefFoundError|ClassNotFoundException|RuntimeException|"+
  1083. "Exception|ThreadDeath|Error|Throwable|System|ClassLoader|"+
  1084. "Cloneable|Class|CharSequence|Comparable|String|Object"
  1085. );
  1086. var keywordMapper = this.createKeywordMapper({
  1087. "variable.language": "this",
  1088. "keyword": keywords,
  1089. "constant.language": buildinConstants,
  1090. "support.function": langClasses
  1091. }, "identifier");
  1092. this.$rules = {
  1093. "start" : [
  1094. {
  1095. token : "comment",
  1096. regex : "\\/\\/.*$"
  1097. },
  1098. DocCommentHighlightRules.getStartRule("doc-start"),
  1099. {
  1100. token : "comment", // multi line comment
  1101. regex : "\\/\\*",
  1102. next : "comment"
  1103. }, {
  1104. token : "string", // single line
  1105. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
  1106. }, {
  1107. token : "string", // single line
  1108. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  1109. }, {
  1110. token : "constant.numeric", // hex
  1111. regex : "0[xX][0-9a-fA-F]+\\b"
  1112. }, {
  1113. token : "constant.numeric", // float
  1114. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  1115. }, {
  1116. token : "constant.language.boolean",
  1117. regex : "(?:true|false)\\b"
  1118. }, {
  1119. token : keywordMapper,
  1120. regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  1121. }, {
  1122. token : "keyword.operator",
  1123. regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|instanceof|new|delete|typeof|void)"
  1124. }, {
  1125. token : "lparen",
  1126. regex : "[[({]"
  1127. }, {
  1128. token : "rparen",
  1129. regex : "[\\])}]"
  1130. }, {
  1131. token : "text",
  1132. regex : "\\s+"
  1133. }
  1134. ],
  1135. "comment" : [
  1136. {
  1137. token : "comment", // closing comment
  1138. regex : ".*?\\*\\/",
  1139. next : "start"
  1140. }, {
  1141. token : "comment", // comment spanning whole line
  1142. regex : ".+"
  1143. }
  1144. ]
  1145. };
  1146. this.embedRules(DocCommentHighlightRules, "doc-",
  1147. [ DocCommentHighlightRules.getEndRule("start") ]);
  1148. };
  1149. oop.inherits(JavaHighlightRules, TextHighlightRules);
  1150. exports.JavaHighlightRules = JavaHighlightRules;
  1151. });
  1152. define("ace/mode/java",["require","exports","module","ace/lib/oop","ace/mode/javascript","ace/mode/java_highlight_rules"], function(require, exports, module) {
  1153. "use strict";
  1154. var oop = require("../lib/oop");
  1155. var JavaScriptMode = require("./javascript").Mode;
  1156. var JavaHighlightRules = require("./java_highlight_rules").JavaHighlightRules;
  1157. var Mode = function() {
  1158. JavaScriptMode.call(this);
  1159. this.HighlightRules = JavaHighlightRules;
  1160. };
  1161. oop.inherits(Mode, JavaScriptMode);
  1162. (function() {
  1163. this.createWorker = function(session) {
  1164. return null;
  1165. };
  1166. this.$id = "ace/mode/java";
  1167. }).call(Mode.prototype);
  1168. exports.Mode = Mode;
  1169. });