Chinthakayala,Sheshashailavas(sc2914) | 8f6a6c4 | 2018-06-27 16:11:44 +0000 | [diff] [blame] | 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 | |
| 4 | var oop = require("../lib/oop"); |
| 5 | var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 6 | |
| 7 | var DocCommentHighlightRules = function() { |
| 8 | this.$rules = { |
| 9 | "start" : [ { |
| 10 | token : "comment.doc.tag", |
| 11 | regex : "@[\\w\\d_]+" // TODO: fix email addresses |
| 12 | }, |
| 13 | DocCommentHighlightRules.getTagRule(), |
| 14 | { |
| 15 | defaultToken : "comment.doc", |
| 16 | caseInsensitive: true |
| 17 | }] |
| 18 | }; |
| 19 | }; |
| 20 | |
| 21 | oop.inherits(DocCommentHighlightRules, TextHighlightRules); |
| 22 | |
| 23 | DocCommentHighlightRules.getTagRule = function(start) { |
| 24 | return { |
| 25 | token : "comment.doc.tag.storage.type", |
| 26 | regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b" |
| 27 | }; |
| 28 | }; |
| 29 | |
| 30 | DocCommentHighlightRules.getStartRule = function(start) { |
| 31 | return { |
| 32 | token : "comment.doc", // doc comment |
| 33 | regex : "\\/\\*(?=\\*)", |
| 34 | next : start |
| 35 | }; |
| 36 | }; |
| 37 | |
| 38 | DocCommentHighlightRules.getEndRule = function (start) { |
| 39 | return { |
| 40 | token : "comment.doc", // closing comment |
| 41 | regex : "\\*\\/", |
| 42 | next : start |
| 43 | }; |
| 44 | }; |
| 45 | |
| 46 | |
| 47 | exports.DocCommentHighlightRules = DocCommentHighlightRules; |
| 48 | |
| 49 | }); |
| 50 | |
| 51 | 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) { |
| 52 | "use strict"; |
| 53 | |
| 54 | var oop = require("../lib/oop"); |
| 55 | var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; |
| 56 | var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 57 | var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*"; |
| 58 | |
| 59 | var JavaScriptHighlightRules = function(options) { |
| 60 | var keywordMapper = this.createKeywordMapper({ |
| 61 | "variable.language": |
| 62 | "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors |
| 63 | "Namespace|QName|XML|XMLList|" + // E4X |
| 64 | "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" + |
| 65 | "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" + |
| 66 | "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors |
| 67 | "SyntaxError|TypeError|URIError|" + |
| 68 | "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions |
| 69 | "isNaN|parseFloat|parseInt|" + |
| 70 | "JSON|Math|" + // Other |
| 71 | "this|arguments|prototype|window|document" , // Pseudo |
| 72 | "keyword": |
| 73 | "const|yield|import|get|set|async|await|" + |
| 74 | "break|case|catch|continue|default|delete|do|else|finally|for|function|" + |
| 75 | "if|in|of|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" + |
| 76 | "__parent__|__count__|escape|unescape|with|__proto__|" + |
| 77 | "class|enum|extends|super|export|implements|private|public|interface|package|protected|static", |
| 78 | "storage.type": |
| 79 | "const|let|var|function", |
| 80 | "constant.language": |
| 81 | "null|Infinity|NaN|undefined", |
| 82 | "support.function": |
| 83 | "alert", |
| 84 | "constant.language.boolean": "true|false" |
| 85 | }, "identifier"); |
| 86 | var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void"; |
| 87 | |
| 88 | var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex |
| 89 | "u[0-9a-fA-F]{4}|" + // unicode |
| 90 | "u{[0-9a-fA-F]{1,6}}|" + // es6 unicode |
| 91 | "[0-2][0-7]{0,2}|" + // oct |
| 92 | "3[0-7][0-7]?|" + // oct |
| 93 | "[4-7][0-7]?|" + //oct |
| 94 | ".)"; |
| 95 | |
| 96 | this.$rules = { |
| 97 | "no_regex" : [ |
| 98 | DocCommentHighlightRules.getStartRule("doc-start"), |
| 99 | comments("no_regex"), |
| 100 | { |
| 101 | token : "string", |
| 102 | regex : "'(?=.)", |
| 103 | next : "qstring" |
| 104 | }, { |
| 105 | token : "string", |
| 106 | regex : '"(?=.)', |
| 107 | next : "qqstring" |
| 108 | }, { |
| 109 | token : "constant.numeric", // hexadecimal, octal and binary |
| 110 | regex : /0(?:[xX][0-9a-fA-F]+|[oO][0-7]+|[bB][01]+)\b/ |
| 111 | }, { |
| 112 | token : "constant.numeric", // decimal integers and floats |
| 113 | regex : /(?:\d\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+\b)?/ |
| 114 | }, { |
| 115 | token : [ |
| 116 | "storage.type", "punctuation.operator", "support.function", |
| 117 | "punctuation.operator", "entity.name.function", "text","keyword.operator" |
| 118 | ], |
| 119 | regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)", |
| 120 | next: "function_arguments" |
| 121 | }, { |
| 122 | token : [ |
| 123 | "storage.type", "punctuation.operator", "entity.name.function", "text", |
| 124 | "keyword.operator", "text", "storage.type", "text", "paren.lparen" |
| 125 | ], |
| 126 | regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", |
| 127 | next: "function_arguments" |
| 128 | }, { |
| 129 | token : [ |
| 130 | "entity.name.function", "text", "keyword.operator", "text", "storage.type", |
| 131 | "text", "paren.lparen" |
| 132 | ], |
| 133 | regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()", |
| 134 | next: "function_arguments" |
| 135 | }, { |
| 136 | token : [ |
| 137 | "storage.type", "punctuation.operator", "entity.name.function", "text", |
| 138 | "keyword.operator", "text", |
| 139 | "storage.type", "text", "entity.name.function", "text", "paren.lparen" |
| 140 | ], |
| 141 | regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()", |
| 142 | next: "function_arguments" |
| 143 | }, { |
| 144 | token : [ |
| 145 | "storage.type", "text", "entity.name.function", "text", "paren.lparen" |
| 146 | ], |
| 147 | regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()", |
| 148 | next: "function_arguments" |
| 149 | }, { |
| 150 | token : [ |
| 151 | "entity.name.function", "text", "punctuation.operator", |
| 152 | "text", "storage.type", "text", "paren.lparen" |
| 153 | ], |
| 154 | regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()", |
| 155 | next: "function_arguments" |
| 156 | }, { |
| 157 | token : [ |
| 158 | "text", "text", "storage.type", "text", "paren.lparen" |
| 159 | ], |
| 160 | regex : "(:)(\\s*)(function)(\\s*)(\\()", |
| 161 | next: "function_arguments" |
| 162 | }, { |
| 163 | token : "keyword", |
| 164 | regex : "from(?=\\s*('|\"))" |
| 165 | }, { |
| 166 | token : "keyword", |
| 167 | regex : "(?:" + kwBeforeRe + ")\\b", |
| 168 | next : "start" |
| 169 | }, { |
| 170 | token : ["support.constant"], |
| 171 | regex : /that\b/ |
| 172 | }, { |
| 173 | token : ["storage.type", "punctuation.operator", "support.function.firebug"], |
| 174 | regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/ |
| 175 | }, { |
| 176 | token : keywordMapper, |
| 177 | regex : identifierRe |
| 178 | }, { |
| 179 | token : "punctuation.operator", |
| 180 | regex : /[.](?![.])/, |
| 181 | next : "property" |
| 182 | }, { |
| 183 | token : "storage.type", |
| 184 | regex : /=>/ |
| 185 | }, { |
| 186 | token : "keyword.operator", |
| 187 | regex : /--|\+\+|\.{3}|===|==|=|!=|!==|<+=?|>+=?|!|&&|\|\||\?:|[!$%&*+\-~\/^]=?/, |
| 188 | next : "start" |
| 189 | }, { |
| 190 | token : "punctuation.operator", |
| 191 | regex : /[?:,;.]/, |
| 192 | next : "start" |
| 193 | }, { |
| 194 | token : "paren.lparen", |
| 195 | regex : /[\[({]/, |
| 196 | next : "start" |
| 197 | }, { |
| 198 | token : "paren.rparen", |
| 199 | regex : /[\])}]/ |
| 200 | }, { |
| 201 | token: "comment", |
| 202 | regex: /^#!.*$/ |
| 203 | } |
| 204 | ], |
| 205 | property: [{ |
| 206 | token : "text", |
| 207 | regex : "\\s+" |
| 208 | }, { |
| 209 | token : [ |
| 210 | "storage.type", "punctuation.operator", "entity.name.function", "text", |
| 211 | "keyword.operator", "text", |
| 212 | "storage.type", "text", "entity.name.function", "text", "paren.lparen" |
| 213 | ], |
| 214 | regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(?:(\\s+)(\\w+))?(\\s*)(\\()", |
| 215 | next: "function_arguments" |
| 216 | }, { |
| 217 | token : "punctuation.operator", |
| 218 | regex : /[.](?![.])/ |
| 219 | }, { |
| 220 | token : "support.function", |
| 221 | 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(?=\()/ |
| 222 | }, { |
| 223 | token : "support.function.dom", |
| 224 | 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(?=\()/ |
| 225 | }, { |
| 226 | token : "support.constant", |
| 227 | 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/ |
| 228 | }, { |
| 229 | token : "identifier", |
| 230 | regex : identifierRe |
| 231 | }, { |
| 232 | regex: "", |
| 233 | token: "empty", |
| 234 | next: "no_regex" |
| 235 | } |
| 236 | ], |
| 237 | "start": [ |
| 238 | DocCommentHighlightRules.getStartRule("doc-start"), |
| 239 | comments("start"), |
| 240 | { |
| 241 | token: "string.regexp", |
| 242 | regex: "\\/", |
| 243 | next: "regex" |
| 244 | }, { |
| 245 | token : "text", |
| 246 | regex : "\\s+|^$", |
| 247 | next : "start" |
| 248 | }, { |
| 249 | token: "empty", |
| 250 | regex: "", |
| 251 | next: "no_regex" |
| 252 | } |
| 253 | ], |
| 254 | "regex": [ |
| 255 | { |
| 256 | token: "regexp.keyword.operator", |
| 257 | regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" |
| 258 | }, { |
| 259 | token: "string.regexp", |
| 260 | regex: "/[sxngimy]*", |
| 261 | next: "no_regex" |
| 262 | }, { |
| 263 | token : "invalid", |
| 264 | regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/ |
| 265 | }, { |
| 266 | token : "constant.language.escape", |
| 267 | regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/ |
| 268 | }, { |
| 269 | token : "constant.language.delimiter", |
| 270 | regex: /\|/ |
| 271 | }, { |
| 272 | token: "constant.language.escape", |
| 273 | regex: /\[\^?/, |
| 274 | next: "regex_character_class" |
| 275 | }, { |
| 276 | token: "empty", |
| 277 | regex: "$", |
| 278 | next: "no_regex" |
| 279 | }, { |
| 280 | defaultToken: "string.regexp" |
| 281 | } |
| 282 | ], |
| 283 | "regex_character_class": [ |
| 284 | { |
| 285 | token: "regexp.charclass.keyword.operator", |
| 286 | regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)" |
| 287 | }, { |
| 288 | token: "constant.language.escape", |
| 289 | regex: "]", |
| 290 | next: "regex" |
| 291 | }, { |
| 292 | token: "constant.language.escape", |
| 293 | regex: "-" |
| 294 | }, { |
| 295 | token: "empty", |
| 296 | regex: "$", |
| 297 | next: "no_regex" |
| 298 | }, { |
| 299 | defaultToken: "string.regexp.charachterclass" |
| 300 | } |
| 301 | ], |
| 302 | "function_arguments": [ |
| 303 | { |
| 304 | token: "variable.parameter", |
| 305 | regex: identifierRe |
| 306 | }, { |
| 307 | token: "punctuation.operator", |
| 308 | regex: "[, ]+" |
| 309 | }, { |
| 310 | token: "punctuation.operator", |
| 311 | regex: "$" |
| 312 | }, { |
| 313 | token: "empty", |
| 314 | regex: "", |
| 315 | next: "no_regex" |
| 316 | } |
| 317 | ], |
| 318 | "qqstring" : [ |
| 319 | { |
| 320 | token : "constant.language.escape", |
| 321 | regex : escapedRe |
| 322 | }, { |
| 323 | token : "string", |
| 324 | regex : "\\\\$", |
| 325 | consumeLineEnd : true |
| 326 | }, { |
| 327 | token : "string", |
| 328 | regex : '"|$', |
| 329 | next : "no_regex" |
| 330 | }, { |
| 331 | defaultToken: "string" |
| 332 | } |
| 333 | ], |
| 334 | "qstring" : [ |
| 335 | { |
| 336 | token : "constant.language.escape", |
| 337 | regex : escapedRe |
| 338 | }, { |
| 339 | token : "string", |
| 340 | regex : "\\\\$", |
| 341 | consumeLineEnd : true |
| 342 | }, { |
| 343 | token : "string", |
| 344 | regex : "'|$", |
| 345 | next : "no_regex" |
| 346 | }, { |
| 347 | defaultToken: "string" |
| 348 | } |
| 349 | ] |
| 350 | }; |
| 351 | |
| 352 | |
| 353 | if (!options || !options.noES6) { |
| 354 | this.$rules.no_regex.unshift({ |
| 355 | regex: "[{}]", onMatch: function(val, state, stack) { |
| 356 | this.next = val == "{" ? this.nextState : ""; |
| 357 | if (val == "{" && stack.length) { |
| 358 | stack.unshift("start", state); |
| 359 | } |
| 360 | else if (val == "}" && stack.length) { |
| 361 | stack.shift(); |
| 362 | this.next = stack.shift(); |
| 363 | if (this.next.indexOf("string") != -1 || this.next.indexOf("jsx") != -1) |
| 364 | return "paren.quasi.end"; |
| 365 | } |
| 366 | return val == "{" ? "paren.lparen" : "paren.rparen"; |
| 367 | }, |
| 368 | nextState: "start" |
| 369 | }, { |
| 370 | token : "string.quasi.start", |
| 371 | regex : /`/, |
| 372 | push : [{ |
| 373 | token : "constant.language.escape", |
| 374 | regex : escapedRe |
| 375 | }, { |
| 376 | token : "paren.quasi.start", |
| 377 | regex : /\${/, |
| 378 | push : "start" |
| 379 | }, { |
| 380 | token : "string.quasi.end", |
| 381 | regex : /`/, |
| 382 | next : "pop" |
| 383 | }, { |
| 384 | defaultToken: "string.quasi" |
| 385 | }] |
| 386 | }); |
| 387 | |
| 388 | if (!options || options.jsx != false) |
| 389 | JSX.call(this); |
| 390 | } |
| 391 | |
| 392 | this.embedRules(DocCommentHighlightRules, "doc-", |
| 393 | [ DocCommentHighlightRules.getEndRule("no_regex") ]); |
| 394 | |
| 395 | this.normalizeRules(); |
| 396 | }; |
| 397 | |
| 398 | oop.inherits(JavaScriptHighlightRules, TextHighlightRules); |
| 399 | |
| 400 | function JSX() { |
| 401 | var tagRegex = identifierRe.replace("\\d", "\\d\\-"); |
| 402 | var jsxTag = { |
| 403 | onMatch : function(val, state, stack) { |
| 404 | var offset = val.charAt(1) == "/" ? 2 : 1; |
| 405 | if (offset == 1) { |
| 406 | if (state != this.nextState) |
| 407 | stack.unshift(this.next, this.nextState, 0); |
| 408 | else |
| 409 | stack.unshift(this.next); |
| 410 | stack[2]++; |
| 411 | } else if (offset == 2) { |
| 412 | if (state == this.nextState) { |
| 413 | stack[1]--; |
| 414 | if (!stack[1] || stack[1] < 0) { |
| 415 | stack.shift(); |
| 416 | stack.shift(); |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | return [{ |
| 421 | type: "meta.tag.punctuation." + (offset == 1 ? "" : "end-") + "tag-open.xml", |
| 422 | value: val.slice(0, offset) |
| 423 | }, { |
| 424 | type: "meta.tag.tag-name.xml", |
| 425 | value: val.substr(offset) |
| 426 | }]; |
| 427 | }, |
| 428 | regex : "</?" + tagRegex + "", |
| 429 | next: "jsxAttributes", |
| 430 | nextState: "jsx" |
| 431 | }; |
| 432 | this.$rules.start.unshift(jsxTag); |
| 433 | var jsxJsRule = { |
| 434 | regex: "{", |
| 435 | token: "paren.quasi.start", |
| 436 | push: "start" |
| 437 | }; |
| 438 | this.$rules.jsx = [ |
| 439 | jsxJsRule, |
| 440 | jsxTag, |
| 441 | {include : "reference"}, |
| 442 | {defaultToken: "string"} |
| 443 | ]; |
| 444 | this.$rules.jsxAttributes = [{ |
| 445 | token : "meta.tag.punctuation.tag-close.xml", |
| 446 | regex : "/?>", |
| 447 | onMatch : function(value, currentState, stack) { |
| 448 | if (currentState == stack[0]) |
| 449 | stack.shift(); |
| 450 | if (value.length == 2) { |
| 451 | if (stack[0] == this.nextState) |
| 452 | stack[1]--; |
| 453 | if (!stack[1] || stack[1] < 0) { |
| 454 | stack.splice(0, 2); |
| 455 | } |
| 456 | } |
| 457 | this.next = stack[0] || "start"; |
| 458 | return [{type: this.token, value: value}]; |
| 459 | }, |
| 460 | nextState: "jsx" |
| 461 | }, |
| 462 | jsxJsRule, |
| 463 | comments("jsxAttributes"), |
| 464 | { |
| 465 | token : "entity.other.attribute-name.xml", |
| 466 | regex : tagRegex |
| 467 | }, { |
| 468 | token : "keyword.operator.attribute-equals.xml", |
| 469 | regex : "=" |
| 470 | }, { |
| 471 | token : "text.tag-whitespace.xml", |
| 472 | regex : "\\s+" |
| 473 | }, { |
| 474 | token : "string.attribute-value.xml", |
| 475 | regex : "'", |
| 476 | stateName : "jsx_attr_q", |
| 477 | push : [ |
| 478 | {token : "string.attribute-value.xml", regex: "'", next: "pop"}, |
| 479 | {include : "reference"}, |
| 480 | {defaultToken : "string.attribute-value.xml"} |
| 481 | ] |
| 482 | }, { |
| 483 | token : "string.attribute-value.xml", |
| 484 | regex : '"', |
| 485 | stateName : "jsx_attr_qq", |
| 486 | push : [ |
| 487 | {token : "string.attribute-value.xml", regex: '"', next: "pop"}, |
| 488 | {include : "reference"}, |
| 489 | {defaultToken : "string.attribute-value.xml"} |
| 490 | ] |
| 491 | }, |
| 492 | jsxTag |
| 493 | ]; |
| 494 | this.$rules.reference = [{ |
| 495 | token : "constant.language.escape.reference.xml", |
| 496 | regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" |
| 497 | }]; |
| 498 | } |
| 499 | |
| 500 | function comments(next) { |
| 501 | return [ |
| 502 | { |
| 503 | token : "comment", // multi line comment |
| 504 | regex : /\/\*/, |
| 505 | next: [ |
| 506 | DocCommentHighlightRules.getTagRule(), |
| 507 | {token : "comment", regex : "\\*\\/", next : next || "pop"}, |
| 508 | {defaultToken : "comment", caseInsensitive: true} |
| 509 | ] |
| 510 | }, { |
| 511 | token : "comment", |
| 512 | regex : "\\/\\/", |
| 513 | next: [ |
| 514 | DocCommentHighlightRules.getTagRule(), |
| 515 | {token : "comment", regex : "$|^", next : next || "pop"}, |
| 516 | {defaultToken : "comment", caseInsensitive: true} |
| 517 | ] |
| 518 | } |
| 519 | ]; |
| 520 | } |
| 521 | exports.JavaScriptHighlightRules = JavaScriptHighlightRules; |
| 522 | }); |
| 523 | |
| 524 | define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) { |
| 525 | "use strict"; |
| 526 | |
| 527 | var Range = require("../range").Range; |
| 528 | |
| 529 | var MatchingBraceOutdent = function() {}; |
| 530 | |
| 531 | (function() { |
| 532 | |
| 533 | this.checkOutdent = function(line, input) { |
| 534 | if (! /^\s+$/.test(line)) |
| 535 | return false; |
| 536 | |
| 537 | return /^\s*\}/.test(input); |
| 538 | }; |
| 539 | |
| 540 | this.autoOutdent = function(doc, row) { |
| 541 | var line = doc.getLine(row); |
| 542 | var match = line.match(/^(\s*\})/); |
| 543 | |
| 544 | if (!match) return 0; |
| 545 | |
| 546 | var column = match[1].length; |
| 547 | var openBracePos = doc.findMatchingBracket({row: row, column: column}); |
| 548 | |
| 549 | if (!openBracePos || openBracePos.row == row) return 0; |
| 550 | |
| 551 | var indent = this.$getIndent(doc.getLine(openBracePos.row)); |
| 552 | doc.replace(new Range(row, 0, row, column-1), indent); |
| 553 | }; |
| 554 | |
| 555 | this.$getIndent = function(line) { |
| 556 | return line.match(/^\s*/)[0]; |
| 557 | }; |
| 558 | |
| 559 | }).call(MatchingBraceOutdent.prototype); |
| 560 | |
| 561 | exports.MatchingBraceOutdent = MatchingBraceOutdent; |
| 562 | }); |
| 563 | |
| 564 | define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) { |
| 565 | "use strict"; |
| 566 | |
| 567 | var oop = require("../../lib/oop"); |
| 568 | var Range = require("../../range").Range; |
| 569 | var BaseFoldMode = require("./fold_mode").FoldMode; |
| 570 | |
| 571 | var FoldMode = exports.FoldMode = function(commentRegex) { |
| 572 | if (commentRegex) { |
| 573 | this.foldingStartMarker = new RegExp( |
| 574 | this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start) |
| 575 | ); |
| 576 | this.foldingStopMarker = new RegExp( |
| 577 | this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end) |
| 578 | ); |
| 579 | } |
| 580 | }; |
| 581 | oop.inherits(FoldMode, BaseFoldMode); |
| 582 | |
| 583 | (function() { |
| 584 | |
| 585 | this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 586 | this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 587 | this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/; |
| 588 | this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 589 | this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 590 | this._getFoldWidgetBase = this.getFoldWidget; |
| 591 | this.getFoldWidget = function(session, foldStyle, row) { |
| 592 | var line = session.getLine(row); |
| 593 | |
| 594 | if (this.singleLineBlockCommentRe.test(line)) { |
| 595 | if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 596 | return ""; |
| 597 | } |
| 598 | |
| 599 | var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 600 | |
| 601 | if (!fw && this.startRegionRe.test(line)) |
| 602 | return "start"; // lineCommentRegionStart |
| 603 | |
| 604 | return fw; |
| 605 | }; |
| 606 | |
| 607 | this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) { |
| 608 | var line = session.getLine(row); |
| 609 | |
| 610 | if (this.startRegionRe.test(line)) |
| 611 | return this.getCommentRegionBlock(session, line, row); |
| 612 | |
| 613 | var match = line.match(this.foldingStartMarker); |
| 614 | if (match) { |
| 615 | var i = match.index; |
| 616 | |
| 617 | if (match[1]) |
| 618 | return this.openingBracketBlock(session, match[1], row, i); |
| 619 | |
| 620 | var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 621 | |
| 622 | if (range && !range.isMultiLine()) { |
| 623 | if (forceMultiline) { |
| 624 | range = this.getSectionRange(session, row); |
| 625 | } else if (foldStyle != "all") |
| 626 | range = null; |
| 627 | } |
| 628 | |
| 629 | return range; |
| 630 | } |
| 631 | |
| 632 | if (foldStyle === "markbegin") |
| 633 | return; |
| 634 | |
| 635 | var match = line.match(this.foldingStopMarker); |
| 636 | if (match) { |
| 637 | var i = match.index + match[0].length; |
| 638 | |
| 639 | if (match[1]) |
| 640 | return this.closingBracketBlock(session, match[1], row, i); |
| 641 | |
| 642 | return session.getCommentFoldRange(row, i, -1); |
| 643 | } |
| 644 | }; |
| 645 | |
| 646 | this.getSectionRange = function(session, row) { |
| 647 | var line = session.getLine(row); |
| 648 | var startIndent = line.search(/\S/); |
| 649 | var startRow = row; |
| 650 | var startColumn = line.length; |
| 651 | row = row + 1; |
| 652 | var endRow = row; |
| 653 | var maxRow = session.getLength(); |
| 654 | while (++row < maxRow) { |
| 655 | line = session.getLine(row); |
| 656 | var indent = line.search(/\S/); |
| 657 | if (indent === -1) |
| 658 | continue; |
| 659 | if (startIndent > indent) |
| 660 | break; |
| 661 | var subRange = this.getFoldWidgetRange(session, "all", row); |
| 662 | |
| 663 | if (subRange) { |
| 664 | if (subRange.start.row <= startRow) { |
| 665 | break; |
| 666 | } else if (subRange.isMultiLine()) { |
| 667 | row = subRange.end.row; |
| 668 | } else if (startIndent == indent) { |
| 669 | break; |
| 670 | } |
| 671 | } |
| 672 | endRow = row; |
| 673 | } |
| 674 | |
| 675 | return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 676 | }; |
| 677 | this.getCommentRegionBlock = function(session, line, row) { |
| 678 | var startColumn = line.search(/\s*$/); |
| 679 | var maxRow = session.getLength(); |
| 680 | var startRow = row; |
| 681 | |
| 682 | var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 683 | var depth = 1; |
| 684 | while (++row < maxRow) { |
| 685 | line = session.getLine(row); |
| 686 | var m = re.exec(line); |
| 687 | if (!m) continue; |
| 688 | if (m[1]) depth--; |
| 689 | else depth++; |
| 690 | |
| 691 | if (!depth) break; |
| 692 | } |
| 693 | |
| 694 | var endRow = row; |
| 695 | if (endRow > startRow) { |
| 696 | return new Range(startRow, startColumn, endRow, line.length); |
| 697 | } |
| 698 | }; |
| 699 | |
| 700 | }).call(FoldMode.prototype); |
| 701 | |
| 702 | }); |
| 703 | |
| 704 | define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) { |
| 705 | "use strict"; |
| 706 | |
| 707 | var oop = require("../lib/oop"); |
| 708 | var TextMode = require("./text").Mode; |
| 709 | var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; |
| 710 | var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; |
| 711 | var WorkerClient = require("../worker/worker_client").WorkerClient; |
| 712 | var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; |
| 713 | var CStyleFoldMode = require("./folding/cstyle").FoldMode; |
| 714 | |
| 715 | var Mode = function() { |
| 716 | this.HighlightRules = JavaScriptHighlightRules; |
| 717 | |
| 718 | this.$outdent = new MatchingBraceOutdent(); |
| 719 | this.$behaviour = new CstyleBehaviour(); |
| 720 | this.foldingRules = new CStyleFoldMode(); |
| 721 | }; |
| 722 | oop.inherits(Mode, TextMode); |
| 723 | |
| 724 | (function() { |
| 725 | |
| 726 | this.lineCommentStart = "//"; |
| 727 | this.blockComment = {start: "/*", end: "*/"}; |
| 728 | this.$quotes = {'"': '"', "'": "'", "`": "`"}; |
| 729 | |
| 730 | this.getNextLineIndent = function(state, line, tab) { |
| 731 | var indent = this.$getIndent(line); |
| 732 | |
| 733 | var tokenizedLine = this.getTokenizer().getLineTokens(line, state); |
| 734 | var tokens = tokenizedLine.tokens; |
| 735 | var endState = tokenizedLine.state; |
| 736 | |
| 737 | if (tokens.length && tokens[tokens.length-1].type == "comment") { |
| 738 | return indent; |
| 739 | } |
| 740 | |
| 741 | if (state == "start" || state == "no_regex") { |
| 742 | var match = line.match(/^.*(?:\bcase\b.*:|[\{\(\[])\s*$/); |
| 743 | if (match) { |
| 744 | indent += tab; |
| 745 | } |
| 746 | } else if (state == "doc-start") { |
| 747 | if (endState == "start" || endState == "no_regex") { |
| 748 | return ""; |
| 749 | } |
| 750 | var match = line.match(/^\s*(\/?)\*/); |
| 751 | if (match) { |
| 752 | if (match[1]) { |
| 753 | indent += " "; |
| 754 | } |
| 755 | indent += "* "; |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | return indent; |
| 760 | }; |
| 761 | |
| 762 | this.checkOutdent = function(state, line, input) { |
| 763 | return this.$outdent.checkOutdent(line, input); |
| 764 | }; |
| 765 | |
| 766 | this.autoOutdent = function(state, doc, row) { |
| 767 | this.$outdent.autoOutdent(doc, row); |
| 768 | }; |
| 769 | |
| 770 | this.createWorker = function(session) { |
| 771 | var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker"); |
| 772 | worker.attachToDocument(session.getDocument()); |
| 773 | |
| 774 | worker.on("annotate", function(results) { |
| 775 | session.setAnnotations(results.data); |
| 776 | }); |
| 777 | |
| 778 | worker.on("terminate", function() { |
| 779 | session.clearAnnotations(); |
| 780 | }); |
| 781 | |
| 782 | return worker; |
| 783 | }; |
| 784 | |
| 785 | this.$id = "ace/mode/javascript"; |
| 786 | }).call(Mode.prototype); |
| 787 | |
| 788 | exports.Mode = Mode; |
| 789 | }); |
| 790 | |
| 791 | define("ace/mode/css_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text_highlight_rules"], function(require, exports, module) { |
| 792 | "use strict"; |
| 793 | |
| 794 | var oop = require("../lib/oop"); |
| 795 | var lang = require("../lib/lang"); |
| 796 | var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 797 | var supportType = exports.supportType = "align-content|align-items|align-self|all|animation|animation-delay|animation-direction|animation-duration|animation-fill-mode|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|backface-visibility|background|background-attachment|background-blend-mode|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|border|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|bottom|box-shadow|box-sizing|caption-side|clear|clip|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|cursor|direction|display|empty-cells|filter|flex|flex-basis|flex-direction|flex-flow|flex-grow|flex-shrink|flex-wrap|float|font|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|hanging-punctuation|height|justify-content|left|letter-spacing|line-height|list-style|list-style-image|list-style-position|list-style-type|margin|margin-bottom|margin-left|margin-right|margin-top|max-height|max-width|min-height|min-width|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|order|outline|outline-color|outline-offset|outline-style|outline-width|overflow|overflow-x|overflow-y|padding|padding-bottom|padding-left|padding-right|padding-top|page-break-after|page-break-before|page-break-inside|perspective|perspective-origin|position|quotes|resize|right|tab-size|table-layout|text-align|text-align-last|text-decoration|text-decoration-color|text-decoration-line|text-decoration-style|text-indent|text-justify|text-overflow|text-shadow|text-transform|top|transform|transform-origin|transform-style|transition|transition-delay|transition-duration|transition-property|transition-timing-function|unicode-bidi|vertical-align|visibility|white-space|width|word-break|word-spacing|word-wrap|z-index"; |
| 798 | var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters"; |
| 799 | var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero"; |
| 800 | var supportConstantColor = exports.supportConstantColor = "aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen"; |
| 801 | var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|cursive|fantasy|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace"; |
| 802 | |
| 803 | var numRe = exports.numRe = "\\-?(?:(?:[0-9]+(?:\\.[0-9]+)?)|(?:\\.[0-9]+))"; |
| 804 | var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b"; |
| 805 | var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b"; |
| 806 | |
| 807 | var CssHighlightRules = function() { |
| 808 | |
| 809 | var keywordMapper = this.createKeywordMapper({ |
| 810 | "support.function": supportFunction, |
| 811 | "support.constant": supportConstant, |
| 812 | "support.type": supportType, |
| 813 | "support.constant.color": supportConstantColor, |
| 814 | "support.constant.fonts": supportConstantFonts |
| 815 | }, "text", true); |
| 816 | |
| 817 | this.$rules = { |
| 818 | "start" : [{ |
| 819 | include : ["strings", "url", "comments"] |
| 820 | }, { |
| 821 | token: "paren.lparen", |
| 822 | regex: "\\{", |
| 823 | next: "ruleset" |
| 824 | }, { |
| 825 | token: "paren.rparen", |
| 826 | regex: "\\}" |
| 827 | }, { |
| 828 | token: "string", |
| 829 | regex: "@", |
| 830 | next: "media" |
| 831 | }, { |
| 832 | token: "keyword", |
| 833 | regex: "#[a-z0-9-_]+" |
| 834 | }, { |
| 835 | token: "keyword", |
| 836 | regex: "%" |
| 837 | }, { |
| 838 | token: "variable", |
| 839 | regex: "\\.[a-z0-9-_]+" |
| 840 | }, { |
| 841 | token: "string", |
| 842 | regex: ":[a-z0-9-_]+" |
| 843 | }, { |
| 844 | token : "constant.numeric", |
| 845 | regex : numRe |
| 846 | }, { |
| 847 | token: "constant", |
| 848 | regex: "[a-z0-9-_]+" |
| 849 | }, { |
| 850 | caseInsensitive: true |
| 851 | }], |
| 852 | |
| 853 | "media": [{ |
| 854 | include : ["strings", "url", "comments"] |
| 855 | }, { |
| 856 | token: "paren.lparen", |
| 857 | regex: "\\{", |
| 858 | next: "start" |
| 859 | }, { |
| 860 | token: "paren.rparen", |
| 861 | regex: "\\}", |
| 862 | next: "start" |
| 863 | }, { |
| 864 | token: "string", |
| 865 | regex: ";", |
| 866 | next: "start" |
| 867 | }, { |
| 868 | token: "keyword", |
| 869 | regex: "(?:media|supports|document|charset|import|namespace|media|supports|document" |
| 870 | + "|page|font|keyframes|viewport|counter-style|font-feature-values" |
| 871 | + "|swash|ornaments|annotation|stylistic|styleset|character-variant)" |
| 872 | }], |
| 873 | |
| 874 | "comments" : [{ |
| 875 | token: "comment", // multi line comment |
| 876 | regex: "\\/\\*", |
| 877 | push: [{ |
| 878 | token : "comment", |
| 879 | regex : "\\*\\/", |
| 880 | next : "pop" |
| 881 | }, { |
| 882 | defaultToken : "comment" |
| 883 | }] |
| 884 | }], |
| 885 | |
| 886 | "ruleset" : [{ |
| 887 | regex : "-(webkit|ms|moz|o)-", |
| 888 | token : "text" |
| 889 | }, { |
| 890 | token : "paren.rparen", |
| 891 | regex : "\\}", |
| 892 | next : "start" |
| 893 | }, { |
| 894 | include : ["strings", "url", "comments"] |
| 895 | }, { |
| 896 | token : ["constant.numeric", "keyword"], |
| 897 | regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)" |
| 898 | }, { |
| 899 | token : "constant.numeric", |
| 900 | regex : numRe |
| 901 | }, { |
| 902 | token : "constant.numeric", // hex6 color |
| 903 | regex : "#[a-f0-9]{6}" |
| 904 | }, { |
| 905 | token : "constant.numeric", // hex3 color |
| 906 | regex : "#[a-f0-9]{3}" |
| 907 | }, { |
| 908 | token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"], |
| 909 | regex : pseudoElements |
| 910 | }, { |
| 911 | token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"], |
| 912 | regex : pseudoClasses |
| 913 | }, { |
| 914 | include: "url" |
| 915 | }, { |
| 916 | token : keywordMapper, |
| 917 | regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*" |
| 918 | }, { |
| 919 | caseInsensitive: true |
| 920 | }], |
| 921 | |
| 922 | url: [{ |
| 923 | token : "support.function", |
| 924 | regex : "(?:url(:?-prefix)?|domain|regexp)\\(", |
| 925 | push: [{ |
| 926 | token : "support.function", |
| 927 | regex : "\\)", |
| 928 | next : "pop" |
| 929 | }, { |
| 930 | defaultToken: "string" |
| 931 | }] |
| 932 | }], |
| 933 | |
| 934 | strings: [{ |
| 935 | token : "string.start", |
| 936 | regex : "'", |
| 937 | push : [{ |
| 938 | token : "string.end", |
| 939 | regex : "'|$", |
| 940 | next: "pop" |
| 941 | }, { |
| 942 | include : "escapes" |
| 943 | }, { |
| 944 | token : "constant.language.escape", |
| 945 | regex : /\\$/, |
| 946 | consumeLineEnd: true |
| 947 | }, { |
| 948 | defaultToken: "string" |
| 949 | }] |
| 950 | }, { |
| 951 | token : "string.start", |
| 952 | regex : '"', |
| 953 | push : [{ |
| 954 | token : "string.end", |
| 955 | regex : '"|$', |
| 956 | next: "pop" |
| 957 | }, { |
| 958 | include : "escapes" |
| 959 | }, { |
| 960 | token : "constant.language.escape", |
| 961 | regex : /\\$/, |
| 962 | consumeLineEnd: true |
| 963 | }, { |
| 964 | defaultToken: "string" |
| 965 | }] |
| 966 | }], |
| 967 | escapes: [{ |
| 968 | token : "constant.language.escape", |
| 969 | regex : /\\([a-fA-F\d]{1,6}|[^a-fA-F\d])/ |
| 970 | }] |
| 971 | |
| 972 | }; |
| 973 | |
| 974 | this.normalizeRules(); |
| 975 | }; |
| 976 | |
| 977 | oop.inherits(CssHighlightRules, TextHighlightRules); |
| 978 | |
| 979 | exports.CssHighlightRules = CssHighlightRules; |
| 980 | |
| 981 | }); |
| 982 | |
| 983 | define("ace/mode/css_completions",["require","exports","module"], function(require, exports, module) { |
| 984 | "use strict"; |
| 985 | |
| 986 | var propertyMap = { |
| 987 | "background": {"#$0": 1}, |
| 988 | "background-color": {"#$0": 1, "transparent": 1, "fixed": 1}, |
| 989 | "background-image": {"url('/$0')": 1}, |
| 990 | "background-repeat": {"repeat": 1, "repeat-x": 1, "repeat-y": 1, "no-repeat": 1, "inherit": 1}, |
| 991 | "background-position": {"bottom":2, "center":2, "left":2, "right":2, "top":2, "inherit":2}, |
| 992 | "background-attachment": {"scroll": 1, "fixed": 1}, |
| 993 | "background-size": {"cover": 1, "contain": 1}, |
| 994 | "background-clip": {"border-box": 1, "padding-box": 1, "content-box": 1}, |
| 995 | "background-origin": {"border-box": 1, "padding-box": 1, "content-box": 1}, |
| 996 | "border": {"solid $0": 1, "dashed $0": 1, "dotted $0": 1, "#$0": 1}, |
| 997 | "border-color": {"#$0": 1}, |
| 998 | "border-style": {"solid":2, "dashed":2, "dotted":2, "double":2, "groove":2, "hidden":2, "inherit":2, "inset":2, "none":2, "outset":2, "ridged":2}, |
| 999 | "border-collapse": {"collapse": 1, "separate": 1}, |
| 1000 | "bottom": {"px": 1, "em": 1, "%": 1}, |
| 1001 | "clear": {"left": 1, "right": 1, "both": 1, "none": 1}, |
| 1002 | "color": {"#$0": 1, "rgb(#$00,0,0)": 1}, |
| 1003 | "cursor": {"default": 1, "pointer": 1, "move": 1, "text": 1, "wait": 1, "help": 1, "progress": 1, "n-resize": 1, "ne-resize": 1, "e-resize": 1, "se-resize": 1, "s-resize": 1, "sw-resize": 1, "w-resize": 1, "nw-resize": 1}, |
| 1004 | "display": {"none": 1, "block": 1, "inline": 1, "inline-block": 1, "table-cell": 1}, |
| 1005 | "empty-cells": {"show": 1, "hide": 1}, |
| 1006 | "float": {"left": 1, "right": 1, "none": 1}, |
| 1007 | "font-family": {"Arial":2,"Comic Sans MS":2,"Consolas":2,"Courier New":2,"Courier":2,"Georgia":2,"Monospace":2,"Sans-Serif":2, "Segoe UI":2,"Tahoma":2,"Times New Roman":2,"Trebuchet MS":2,"Verdana": 1}, |
| 1008 | "font-size": {"px": 1, "em": 1, "%": 1}, |
| 1009 | "font-weight": {"bold": 1, "normal": 1}, |
| 1010 | "font-style": {"italic": 1, "normal": 1}, |
| 1011 | "font-variant": {"normal": 1, "small-caps": 1}, |
| 1012 | "height": {"px": 1, "em": 1, "%": 1}, |
| 1013 | "left": {"px": 1, "em": 1, "%": 1}, |
| 1014 | "letter-spacing": {"normal": 1}, |
| 1015 | "line-height": {"normal": 1}, |
| 1016 | "list-style-type": {"none": 1, "disc": 1, "circle": 1, "square": 1, "decimal": 1, "decimal-leading-zero": 1, "lower-roman": 1, "upper-roman": 1, "lower-greek": 1, "lower-latin": 1, "upper-latin": 1, "georgian": 1, "lower-alpha": 1, "upper-alpha": 1}, |
| 1017 | "margin": {"px": 1, "em": 1, "%": 1}, |
| 1018 | "margin-right": {"px": 1, "em": 1, "%": 1}, |
| 1019 | "margin-left": {"px": 1, "em": 1, "%": 1}, |
| 1020 | "margin-top": {"px": 1, "em": 1, "%": 1}, |
| 1021 | "margin-bottom": {"px": 1, "em": 1, "%": 1}, |
| 1022 | "max-height": {"px": 1, "em": 1, "%": 1}, |
| 1023 | "max-width": {"px": 1, "em": 1, "%": 1}, |
| 1024 | "min-height": {"px": 1, "em": 1, "%": 1}, |
| 1025 | "min-width": {"px": 1, "em": 1, "%": 1}, |
| 1026 | "overflow": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1}, |
| 1027 | "overflow-x": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1}, |
| 1028 | "overflow-y": {"hidden": 1, "visible": 1, "auto": 1, "scroll": 1}, |
| 1029 | "padding": {"px": 1, "em": 1, "%": 1}, |
| 1030 | "padding-top": {"px": 1, "em": 1, "%": 1}, |
| 1031 | "padding-right": {"px": 1, "em": 1, "%": 1}, |
| 1032 | "padding-bottom": {"px": 1, "em": 1, "%": 1}, |
| 1033 | "padding-left": {"px": 1, "em": 1, "%": 1}, |
| 1034 | "page-break-after": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1}, |
| 1035 | "page-break-before": {"auto": 1, "always": 1, "avoid": 1, "left": 1, "right": 1}, |
| 1036 | "position": {"absolute": 1, "relative": 1, "fixed": 1, "static": 1}, |
| 1037 | "right": {"px": 1, "em": 1, "%": 1}, |
| 1038 | "table-layout": {"fixed": 1, "auto": 1}, |
| 1039 | "text-decoration": {"none": 1, "underline": 1, "line-through": 1, "blink": 1}, |
| 1040 | "text-align": {"left": 1, "right": 1, "center": 1, "justify": 1}, |
| 1041 | "text-transform": {"capitalize": 1, "uppercase": 1, "lowercase": 1, "none": 1}, |
| 1042 | "top": {"px": 1, "em": 1, "%": 1}, |
| 1043 | "vertical-align": {"top": 1, "bottom": 1}, |
| 1044 | "visibility": {"hidden": 1, "visible": 1}, |
| 1045 | "white-space": {"nowrap": 1, "normal": 1, "pre": 1, "pre-line": 1, "pre-wrap": 1}, |
| 1046 | "width": {"px": 1, "em": 1, "%": 1}, |
| 1047 | "word-spacing": {"normal": 1}, |
| 1048 | "filter": {"alpha(opacity=$0100)": 1}, |
| 1049 | |
| 1050 | "text-shadow": {"$02px 2px 2px #777": 1}, |
| 1051 | "text-overflow": {"ellipsis-word": 1, "clip": 1, "ellipsis": 1}, |
| 1052 | "-moz-border-radius": 1, |
| 1053 | "-moz-border-radius-topright": 1, |
| 1054 | "-moz-border-radius-bottomright": 1, |
| 1055 | "-moz-border-radius-topleft": 1, |
| 1056 | "-moz-border-radius-bottomleft": 1, |
| 1057 | "-webkit-border-radius": 1, |
| 1058 | "-webkit-border-top-right-radius": 1, |
| 1059 | "-webkit-border-top-left-radius": 1, |
| 1060 | "-webkit-border-bottom-right-radius": 1, |
| 1061 | "-webkit-border-bottom-left-radius": 1, |
| 1062 | "-moz-box-shadow": 1, |
| 1063 | "-webkit-box-shadow": 1, |
| 1064 | "transform": {"rotate($00deg)": 1, "skew($00deg)": 1}, |
| 1065 | "-moz-transform": {"rotate($00deg)": 1, "skew($00deg)": 1}, |
| 1066 | "-webkit-transform": {"rotate($00deg)": 1, "skew($00deg)": 1 } |
| 1067 | }; |
| 1068 | |
| 1069 | var CssCompletions = function() { |
| 1070 | |
| 1071 | }; |
| 1072 | |
| 1073 | (function() { |
| 1074 | |
| 1075 | this.completionsDefined = false; |
| 1076 | |
| 1077 | this.defineCompletions = function() { |
| 1078 | if (document) { |
| 1079 | var style = document.createElement('c').style; |
| 1080 | |
| 1081 | for (var i in style) { |
| 1082 | if (typeof style[i] !== 'string') |
| 1083 | continue; |
| 1084 | |
| 1085 | var name = i.replace(/[A-Z]/g, function(x) { |
| 1086 | return '-' + x.toLowerCase(); |
| 1087 | }); |
| 1088 | |
| 1089 | if (!propertyMap.hasOwnProperty(name)) |
| 1090 | propertyMap[name] = 1; |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | this.completionsDefined = true; |
| 1095 | }; |
| 1096 | |
| 1097 | this.getCompletions = function(state, session, pos, prefix) { |
| 1098 | if (!this.completionsDefined) { |
| 1099 | this.defineCompletions(); |
| 1100 | } |
| 1101 | |
| 1102 | var token = session.getTokenAt(pos.row, pos.column); |
| 1103 | |
| 1104 | if (!token) |
| 1105 | return []; |
| 1106 | if (state==='ruleset'){ |
| 1107 | var line = session.getLine(pos.row).substr(0, pos.column); |
| 1108 | if (/:[^;]+$/.test(line)) { |
| 1109 | /([\w\-]+):[^:]*$/.test(line); |
| 1110 | |
| 1111 | return this.getPropertyValueCompletions(state, session, pos, prefix); |
| 1112 | } else { |
| 1113 | return this.getPropertyCompletions(state, session, pos, prefix); |
| 1114 | } |
| 1115 | } |
| 1116 | |
| 1117 | return []; |
| 1118 | }; |
| 1119 | |
| 1120 | this.getPropertyCompletions = function(state, session, pos, prefix) { |
| 1121 | var properties = Object.keys(propertyMap); |
| 1122 | return properties.map(function(property){ |
| 1123 | return { |
| 1124 | caption: property, |
| 1125 | snippet: property + ': $0;', |
| 1126 | meta: "property", |
| 1127 | score: Number.MAX_VALUE |
| 1128 | }; |
| 1129 | }); |
| 1130 | }; |
| 1131 | |
| 1132 | this.getPropertyValueCompletions = function(state, session, pos, prefix) { |
| 1133 | var line = session.getLine(pos.row).substr(0, pos.column); |
| 1134 | var property = (/([\w\-]+):[^:]*$/.exec(line) || {})[1]; |
| 1135 | |
| 1136 | if (!property) |
| 1137 | return []; |
| 1138 | var values = []; |
| 1139 | if (property in propertyMap && typeof propertyMap[property] === "object") { |
| 1140 | values = Object.keys(propertyMap[property]); |
| 1141 | } |
| 1142 | return values.map(function(value){ |
| 1143 | return { |
| 1144 | caption: value, |
| 1145 | snippet: value, |
| 1146 | meta: "property value", |
| 1147 | score: Number.MAX_VALUE |
| 1148 | }; |
| 1149 | }); |
| 1150 | }; |
| 1151 | |
| 1152 | }).call(CssCompletions.prototype); |
| 1153 | |
| 1154 | exports.CssCompletions = CssCompletions; |
| 1155 | }); |
| 1156 | |
| 1157 | define("ace/mode/behaviour/css",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/mode/behaviour/cstyle","ace/token_iterator"], function(require, exports, module) { |
| 1158 | "use strict"; |
| 1159 | |
| 1160 | var oop = require("../../lib/oop"); |
| 1161 | var Behaviour = require("../behaviour").Behaviour; |
| 1162 | var CstyleBehaviour = require("./cstyle").CstyleBehaviour; |
| 1163 | var TokenIterator = require("../../token_iterator").TokenIterator; |
| 1164 | |
| 1165 | var CssBehaviour = function () { |
| 1166 | |
| 1167 | this.inherit(CstyleBehaviour); |
| 1168 | |
| 1169 | this.add("colon", "insertion", function (state, action, editor, session, text) { |
| 1170 | if (text === ':') { |
| 1171 | var cursor = editor.getCursorPosition(); |
| 1172 | var iterator = new TokenIterator(session, cursor.row, cursor.column); |
| 1173 | var token = iterator.getCurrentToken(); |
| 1174 | if (token && token.value.match(/\s+/)) { |
| 1175 | token = iterator.stepBackward(); |
| 1176 | } |
| 1177 | if (token && token.type === 'support.type') { |
| 1178 | var line = session.doc.getLine(cursor.row); |
| 1179 | var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 1180 | if (rightChar === ':') { |
| 1181 | return { |
| 1182 | text: '', |
| 1183 | selection: [1, 1] |
| 1184 | }; |
| 1185 | } |
| 1186 | if (!line.substring(cursor.column).match(/^\s*;/)) { |
| 1187 | return { |
| 1188 | text: ':;', |
| 1189 | selection: [1, 1] |
| 1190 | }; |
| 1191 | } |
| 1192 | } |
| 1193 | } |
| 1194 | }); |
| 1195 | |
| 1196 | this.add("colon", "deletion", function (state, action, editor, session, range) { |
| 1197 | var selected = session.doc.getTextRange(range); |
| 1198 | if (!range.isMultiLine() && selected === ':') { |
| 1199 | var cursor = editor.getCursorPosition(); |
| 1200 | var iterator = new TokenIterator(session, cursor.row, cursor.column); |
| 1201 | var token = iterator.getCurrentToken(); |
| 1202 | if (token && token.value.match(/\s+/)) { |
| 1203 | token = iterator.stepBackward(); |
| 1204 | } |
| 1205 | if (token && token.type === 'support.type') { |
| 1206 | var line = session.doc.getLine(range.start.row); |
| 1207 | var rightChar = line.substring(range.end.column, range.end.column + 1); |
| 1208 | if (rightChar === ';') { |
| 1209 | range.end.column ++; |
| 1210 | return range; |
| 1211 | } |
| 1212 | } |
| 1213 | } |
| 1214 | }); |
| 1215 | |
| 1216 | this.add("semicolon", "insertion", function (state, action, editor, session, text) { |
| 1217 | if (text === ';') { |
| 1218 | var cursor = editor.getCursorPosition(); |
| 1219 | var line = session.doc.getLine(cursor.row); |
| 1220 | var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 1221 | if (rightChar === ';') { |
| 1222 | return { |
| 1223 | text: '', |
| 1224 | selection: [1, 1] |
| 1225 | }; |
| 1226 | } |
| 1227 | } |
| 1228 | }); |
| 1229 | |
| 1230 | }; |
| 1231 | oop.inherits(CssBehaviour, CstyleBehaviour); |
| 1232 | |
| 1233 | exports.CssBehaviour = CssBehaviour; |
| 1234 | }); |
| 1235 | |
| 1236 | define("ace/mode/css",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/css_highlight_rules","ace/mode/matching_brace_outdent","ace/worker/worker_client","ace/mode/css_completions","ace/mode/behaviour/css","ace/mode/folding/cstyle"], function(require, exports, module) { |
| 1237 | "use strict"; |
| 1238 | |
| 1239 | var oop = require("../lib/oop"); |
| 1240 | var TextMode = require("./text").Mode; |
| 1241 | var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; |
| 1242 | var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; |
| 1243 | var WorkerClient = require("../worker/worker_client").WorkerClient; |
| 1244 | var CssCompletions = require("./css_completions").CssCompletions; |
| 1245 | var CssBehaviour = require("./behaviour/css").CssBehaviour; |
| 1246 | var CStyleFoldMode = require("./folding/cstyle").FoldMode; |
| 1247 | |
| 1248 | var Mode = function() { |
| 1249 | this.HighlightRules = CssHighlightRules; |
| 1250 | this.$outdent = new MatchingBraceOutdent(); |
| 1251 | this.$behaviour = new CssBehaviour(); |
| 1252 | this.$completer = new CssCompletions(); |
| 1253 | this.foldingRules = new CStyleFoldMode(); |
| 1254 | }; |
| 1255 | oop.inherits(Mode, TextMode); |
| 1256 | |
| 1257 | (function() { |
| 1258 | |
| 1259 | this.foldingRules = "cStyle"; |
| 1260 | this.blockComment = {start: "/*", end: "*/"}; |
| 1261 | |
| 1262 | this.getNextLineIndent = function(state, line, tab) { |
| 1263 | var indent = this.$getIndent(line); |
| 1264 | var tokens = this.getTokenizer().getLineTokens(line, state).tokens; |
| 1265 | if (tokens.length && tokens[tokens.length-1].type == "comment") { |
| 1266 | return indent; |
| 1267 | } |
| 1268 | |
| 1269 | var match = line.match(/^.*\{\s*$/); |
| 1270 | if (match) { |
| 1271 | indent += tab; |
| 1272 | } |
| 1273 | |
| 1274 | return indent; |
| 1275 | }; |
| 1276 | |
| 1277 | this.checkOutdent = function(state, line, input) { |
| 1278 | return this.$outdent.checkOutdent(line, input); |
| 1279 | }; |
| 1280 | |
| 1281 | this.autoOutdent = function(state, doc, row) { |
| 1282 | this.$outdent.autoOutdent(doc, row); |
| 1283 | }; |
| 1284 | |
| 1285 | this.getCompletions = function(state, session, pos, prefix) { |
| 1286 | return this.$completer.getCompletions(state, session, pos, prefix); |
| 1287 | }; |
| 1288 | |
| 1289 | this.createWorker = function(session) { |
| 1290 | var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker"); |
| 1291 | worker.attachToDocument(session.getDocument()); |
| 1292 | |
| 1293 | worker.on("annotate", function(e) { |
| 1294 | session.setAnnotations(e.data); |
| 1295 | }); |
| 1296 | |
| 1297 | worker.on("terminate", function() { |
| 1298 | session.clearAnnotations(); |
| 1299 | }); |
| 1300 | |
| 1301 | return worker; |
| 1302 | }; |
| 1303 | |
| 1304 | this.$id = "ace/mode/css"; |
| 1305 | }).call(Mode.prototype); |
| 1306 | |
| 1307 | exports.Mode = Mode; |
| 1308 | |
| 1309 | }); |
| 1310 | |
| 1311 | define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) { |
| 1312 | "use strict"; |
| 1313 | |
| 1314 | var oop = require("../lib/oop"); |
| 1315 | var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; |
| 1316 | |
| 1317 | var XmlHighlightRules = function(normalize) { |
| 1318 | var tagRegex = "[_:a-zA-Z\xc0-\uffff][-_:.a-zA-Z0-9\xc0-\uffff]*"; |
| 1319 | |
| 1320 | this.$rules = { |
| 1321 | start : [ |
| 1322 | {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"}, |
| 1323 | { |
| 1324 | token : ["punctuation.instruction.xml", "keyword.instruction.xml"], |
| 1325 | regex : "(<\\?)(" + tagRegex + ")", next : "processing_instruction" |
| 1326 | }, |
| 1327 | {token : "comment.start.xml", regex : "<\\!--", next : "comment"}, |
| 1328 | { |
| 1329 | token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"], |
| 1330 | regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true |
| 1331 | }, |
| 1332 | {include : "tag"}, |
| 1333 | {token : "text.end-tag-open.xml", regex: "</"}, |
| 1334 | {token : "text.tag-open.xml", regex: "<"}, |
| 1335 | {include : "reference"}, |
| 1336 | {defaultToken : "text.xml"} |
| 1337 | ], |
| 1338 | |
| 1339 | processing_instruction : [{ |
| 1340 | token : "entity.other.attribute-name.decl-attribute-name.xml", |
| 1341 | regex : tagRegex |
| 1342 | }, { |
| 1343 | token : "keyword.operator.decl-attribute-equals.xml", |
| 1344 | regex : "=" |
| 1345 | }, { |
| 1346 | include: "whitespace" |
| 1347 | }, { |
| 1348 | include: "string" |
| 1349 | }, { |
| 1350 | token : "punctuation.xml-decl.xml", |
| 1351 | regex : "\\?>", |
| 1352 | next : "start" |
| 1353 | }], |
| 1354 | |
| 1355 | doctype : [ |
| 1356 | {include : "whitespace"}, |
| 1357 | {include : "string"}, |
| 1358 | {token : "xml-pe.doctype.xml", regex : ">", next : "start"}, |
| 1359 | {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"}, |
| 1360 | {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"} |
| 1361 | ], |
| 1362 | |
| 1363 | int_subset : [{ |
| 1364 | token : "text.xml", |
| 1365 | regex : "\\s+" |
| 1366 | }, { |
| 1367 | token: "punctuation.int-subset.xml", |
| 1368 | regex: "]", |
| 1369 | next: "pop" |
| 1370 | }, { |
| 1371 | token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"], |
| 1372 | regex : "(<\\!)(" + tagRegex + ")", |
| 1373 | push : [{ |
| 1374 | token : "text", |
| 1375 | regex : "\\s+" |
| 1376 | }, |
| 1377 | { |
| 1378 | token : "punctuation.markup-decl.xml", |
| 1379 | regex : ">", |
| 1380 | next : "pop" |
| 1381 | }, |
| 1382 | {include : "string"}] |
| 1383 | }], |
| 1384 | |
| 1385 | cdata : [ |
| 1386 | {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"}, |
| 1387 | {token : "text.xml", regex : "\\s+"}, |
| 1388 | {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"} |
| 1389 | ], |
| 1390 | |
| 1391 | comment : [ |
| 1392 | {token : "comment.end.xml", regex : "-->", next : "start"}, |
| 1393 | {defaultToken : "comment.xml"} |
| 1394 | ], |
| 1395 | |
| 1396 | reference : [{ |
| 1397 | token : "constant.language.escape.reference.xml", |
| 1398 | regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" |
| 1399 | }], |
| 1400 | |
| 1401 | attr_reference : [{ |
| 1402 | token : "constant.language.escape.reference.attribute-value.xml", |
| 1403 | regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)" |
| 1404 | }], |
| 1405 | |
| 1406 | tag : [{ |
| 1407 | token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"], |
| 1408 | regex : "(?:(<)|(</))((?:" + tagRegex + ":)?" + tagRegex + ")", |
| 1409 | next: [ |
| 1410 | {include : "attributes"}, |
| 1411 | {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"} |
| 1412 | ] |
| 1413 | }], |
| 1414 | |
| 1415 | tag_whitespace : [ |
| 1416 | {token : "text.tag-whitespace.xml", regex : "\\s+"} |
| 1417 | ], |
| 1418 | whitespace : [ |
| 1419 | {token : "text.whitespace.xml", regex : "\\s+"} |
| 1420 | ], |
| 1421 | string: [{ |
| 1422 | token : "string.xml", |
| 1423 | regex : "'", |
| 1424 | push : [ |
| 1425 | {token : "string.xml", regex: "'", next: "pop"}, |
| 1426 | {defaultToken : "string.xml"} |
| 1427 | ] |
| 1428 | }, { |
| 1429 | token : "string.xml", |
| 1430 | regex : '"', |
| 1431 | push : [ |
| 1432 | {token : "string.xml", regex: '"', next: "pop"}, |
| 1433 | {defaultToken : "string.xml"} |
| 1434 | ] |
| 1435 | }], |
| 1436 | |
| 1437 | attributes: [{ |
| 1438 | token : "entity.other.attribute-name.xml", |
| 1439 | regex : tagRegex |
| 1440 | }, { |
| 1441 | token : "keyword.operator.attribute-equals.xml", |
| 1442 | regex : "=" |
| 1443 | }, { |
| 1444 | include: "tag_whitespace" |
| 1445 | }, { |
| 1446 | include: "attribute_value" |
| 1447 | }], |
| 1448 | |
| 1449 | attribute_value: [{ |
| 1450 | token : "string.attribute-value.xml", |
| 1451 | regex : "'", |
| 1452 | push : [ |
| 1453 | {token : "string.attribute-value.xml", regex: "'", next: "pop"}, |
| 1454 | {include : "attr_reference"}, |
| 1455 | {defaultToken : "string.attribute-value.xml"} |
| 1456 | ] |
| 1457 | }, { |
| 1458 | token : "string.attribute-value.xml", |
| 1459 | regex : '"', |
| 1460 | push : [ |
| 1461 | {token : "string.attribute-value.xml", regex: '"', next: "pop"}, |
| 1462 | {include : "attr_reference"}, |
| 1463 | {defaultToken : "string.attribute-value.xml"} |
| 1464 | ] |
| 1465 | }] |
| 1466 | }; |
| 1467 | |
| 1468 | if (this.constructor === XmlHighlightRules) |
| 1469 | this.normalizeRules(); |
| 1470 | }; |
| 1471 | |
| 1472 | |
| 1473 | (function() { |
| 1474 | |
| 1475 | this.embedTagRules = function(HighlightRules, prefix, tag){ |
| 1476 | this.$rules.tag.unshift({ |
| 1477 | token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"], |
| 1478 | regex : "(<)(" + tag + "(?=\\s|>|$))", |
| 1479 | next: [ |
| 1480 | {include : "attributes"}, |
| 1481 | {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"} |
| 1482 | ] |
| 1483 | }); |
| 1484 | |
| 1485 | this.$rules[tag + "-end"] = [ |
| 1486 | {include : "attributes"}, |
| 1487 | {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start", |
| 1488 | onMatch : function(value, currentState, stack) { |
| 1489 | stack.splice(0); |
| 1490 | return this.token; |
| 1491 | }} |
| 1492 | ]; |
| 1493 | |
| 1494 | this.embedRules(HighlightRules, prefix, [{ |
| 1495 | token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"], |
| 1496 | regex : "(</)(" + tag + "(?=\\s|>|$))", |
| 1497 | next: tag + "-end" |
| 1498 | }, { |
| 1499 | token: "string.cdata.xml", |
| 1500 | regex : "<\\!\\[CDATA\\[" |
| 1501 | }, { |
| 1502 | token: "string.cdata.xml", |
| 1503 | regex : "\\]\\]>" |
| 1504 | }]); |
| 1505 | }; |
| 1506 | |
| 1507 | }).call(TextHighlightRules.prototype); |
| 1508 | |
| 1509 | oop.inherits(XmlHighlightRules, TextHighlightRules); |
| 1510 | |
| 1511 | exports.XmlHighlightRules = XmlHighlightRules; |
| 1512 | }); |
| 1513 | |
| 1514 | define("ace/mode/html_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/css_highlight_rules","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules"], function(require, exports, module) { |
| 1515 | "use strict"; |
| 1516 | |
| 1517 | var oop = require("../lib/oop"); |
| 1518 | var lang = require("../lib/lang"); |
| 1519 | var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; |
| 1520 | var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; |
| 1521 | var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules; |
| 1522 | |
| 1523 | var tagMap = lang.createMap({ |
| 1524 | a : 'anchor', |
| 1525 | button : 'form', |
| 1526 | form : 'form', |
| 1527 | img : 'image', |
| 1528 | input : 'form', |
| 1529 | label : 'form', |
| 1530 | option : 'form', |
| 1531 | script : 'script', |
| 1532 | select : 'form', |
| 1533 | textarea : 'form', |
| 1534 | style : 'style', |
| 1535 | table : 'table', |
| 1536 | tbody : 'table', |
| 1537 | td : 'table', |
| 1538 | tfoot : 'table', |
| 1539 | th : 'table', |
| 1540 | tr : 'table' |
| 1541 | }); |
| 1542 | |
| 1543 | var HtmlHighlightRules = function() { |
| 1544 | XmlHighlightRules.call(this); |
| 1545 | |
| 1546 | this.addRules({ |
| 1547 | attributes: [{ |
| 1548 | include : "tag_whitespace" |
| 1549 | }, { |
| 1550 | token : "entity.other.attribute-name.xml", |
| 1551 | regex : "[-_a-zA-Z0-9:.]+" |
| 1552 | }, { |
| 1553 | token : "keyword.operator.attribute-equals.xml", |
| 1554 | regex : "=", |
| 1555 | push : [{ |
| 1556 | include: "tag_whitespace" |
| 1557 | }, { |
| 1558 | token : "string.unquoted.attribute-value.html", |
| 1559 | regex : "[^<>='\"`\\s]+", |
| 1560 | next : "pop" |
| 1561 | }, { |
| 1562 | token : "empty", |
| 1563 | regex : "", |
| 1564 | next : "pop" |
| 1565 | }] |
| 1566 | }, { |
| 1567 | include : "attribute_value" |
| 1568 | }], |
| 1569 | tag: [{ |
| 1570 | token : function(start, tag) { |
| 1571 | var group = tagMap[tag]; |
| 1572 | return ["meta.tag.punctuation." + (start == "<" ? "" : "end-") + "tag-open.xml", |
| 1573 | "meta.tag" + (group ? "." + group : "") + ".tag-name.xml"]; |
| 1574 | }, |
| 1575 | regex : "(</?)([-_a-zA-Z0-9:.]+)", |
| 1576 | next: "tag_stuff" |
| 1577 | }], |
| 1578 | tag_stuff: [ |
| 1579 | {include : "attributes"}, |
| 1580 | {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"} |
| 1581 | ] |
| 1582 | }); |
| 1583 | |
| 1584 | this.embedTagRules(CssHighlightRules, "css-", "style"); |
| 1585 | this.embedTagRules(new JavaScriptHighlightRules({jsx: false}).getRules(), "js-", "script"); |
| 1586 | |
| 1587 | if (this.constructor === HtmlHighlightRules) |
| 1588 | this.normalizeRules(); |
| 1589 | }; |
| 1590 | |
| 1591 | oop.inherits(HtmlHighlightRules, XmlHighlightRules); |
| 1592 | |
| 1593 | exports.HtmlHighlightRules = HtmlHighlightRules; |
| 1594 | }); |
| 1595 | |
| 1596 | define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) { |
| 1597 | "use strict"; |
| 1598 | |
| 1599 | var oop = require("../../lib/oop"); |
| 1600 | var Behaviour = require("../behaviour").Behaviour; |
| 1601 | var TokenIterator = require("../../token_iterator").TokenIterator; |
| 1602 | var lang = require("../../lib/lang"); |
| 1603 | |
| 1604 | function is(token, type) { |
| 1605 | return token.type.lastIndexOf(type + ".xml") > -1; |
| 1606 | } |
| 1607 | |
| 1608 | var XmlBehaviour = function () { |
| 1609 | |
| 1610 | this.add("string_dquotes", "insertion", function (state, action, editor, session, text) { |
| 1611 | if (text == '"' || text == "'") { |
| 1612 | var quote = text; |
| 1613 | var selected = session.doc.getTextRange(editor.getSelectionRange()); |
| 1614 | if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) { |
| 1615 | return { |
| 1616 | text: quote + selected + quote, |
| 1617 | selection: false |
| 1618 | }; |
| 1619 | } |
| 1620 | |
| 1621 | var cursor = editor.getCursorPosition(); |
| 1622 | var line = session.doc.getLine(cursor.row); |
| 1623 | var rightChar = line.substring(cursor.column, cursor.column + 1); |
| 1624 | var iterator = new TokenIterator(session, cursor.row, cursor.column); |
| 1625 | var token = iterator.getCurrentToken(); |
| 1626 | |
| 1627 | if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) { |
| 1628 | return { |
| 1629 | text: "", |
| 1630 | selection: [1, 1] |
| 1631 | }; |
| 1632 | } |
| 1633 | |
| 1634 | if (!token) |
| 1635 | token = iterator.stepBackward(); |
| 1636 | |
| 1637 | if (!token) |
| 1638 | return; |
| 1639 | |
| 1640 | while (is(token, "tag-whitespace") || is(token, "whitespace")) { |
| 1641 | token = iterator.stepBackward(); |
| 1642 | } |
| 1643 | var rightSpace = !rightChar || rightChar.match(/\s/); |
| 1644 | if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) { |
| 1645 | return { |
| 1646 | text: quote + quote, |
| 1647 | selection: [1, 1] |
| 1648 | }; |
| 1649 | } |
| 1650 | } |
| 1651 | }); |
| 1652 | |
| 1653 | this.add("string_dquotes", "deletion", function(state, action, editor, session, range) { |
| 1654 | var selected = session.doc.getTextRange(range); |
| 1655 | if (!range.isMultiLine() && (selected == '"' || selected == "'")) { |
| 1656 | var line = session.doc.getLine(range.start.row); |
| 1657 | var rightChar = line.substring(range.start.column + 1, range.start.column + 2); |
| 1658 | if (rightChar == selected) { |
| 1659 | range.end.column++; |
| 1660 | return range; |
| 1661 | } |
| 1662 | } |
| 1663 | }); |
| 1664 | |
| 1665 | this.add("autoclosing", "insertion", function (state, action, editor, session, text) { |
| 1666 | if (text == '>') { |
| 1667 | var position = editor.getSelectionRange().start; |
| 1668 | var iterator = new TokenIterator(session, position.row, position.column); |
| 1669 | var token = iterator.getCurrentToken() || iterator.stepBackward(); |
| 1670 | if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value"))) |
| 1671 | return; |
| 1672 | if (is(token, "reference.attribute-value")) |
| 1673 | return; |
| 1674 | if (is(token, "attribute-value")) { |
| 1675 | var firstChar = token.value.charAt(0); |
| 1676 | if (firstChar == '"' || firstChar == "'") { |
| 1677 | var lastChar = token.value.charAt(token.value.length - 1); |
| 1678 | var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length; |
| 1679 | if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar) |
| 1680 | return; |
| 1681 | } |
| 1682 | } |
| 1683 | while (!is(token, "tag-name")) { |
| 1684 | token = iterator.stepBackward(); |
| 1685 | if (token.value == "<") { |
| 1686 | token = iterator.stepForward(); |
| 1687 | break; |
| 1688 | } |
| 1689 | } |
| 1690 | |
| 1691 | var tokenRow = iterator.getCurrentTokenRow(); |
| 1692 | var tokenColumn = iterator.getCurrentTokenColumn(); |
| 1693 | if (is(iterator.stepBackward(), "end-tag-open")) |
| 1694 | return; |
| 1695 | |
| 1696 | var element = token.value; |
| 1697 | if (tokenRow == position.row) |
| 1698 | element = element.substring(0, position.column - tokenColumn); |
| 1699 | |
| 1700 | if (this.voidElements.hasOwnProperty(element.toLowerCase())) |
| 1701 | return; |
| 1702 | |
| 1703 | return { |
| 1704 | text: ">" + "</" + element + ">", |
| 1705 | selection: [1, 1] |
| 1706 | }; |
| 1707 | } |
| 1708 | }); |
| 1709 | |
| 1710 | this.add("autoindent", "insertion", function (state, action, editor, session, text) { |
| 1711 | if (text == "\n") { |
| 1712 | var cursor = editor.getCursorPosition(); |
| 1713 | var line = session.getLine(cursor.row); |
| 1714 | var iterator = new TokenIterator(session, cursor.row, cursor.column); |
| 1715 | var token = iterator.getCurrentToken(); |
| 1716 | |
| 1717 | if (token && token.type.indexOf("tag-close") !== -1) { |
| 1718 | if (token.value == "/>") |
| 1719 | return; |
| 1720 | while (token && token.type.indexOf("tag-name") === -1) { |
| 1721 | token = iterator.stepBackward(); |
| 1722 | } |
| 1723 | |
| 1724 | if (!token) { |
| 1725 | return; |
| 1726 | } |
| 1727 | |
| 1728 | var tag = token.value; |
| 1729 | var row = iterator.getCurrentTokenRow(); |
| 1730 | token = iterator.stepBackward(); |
| 1731 | if (!token || token.type.indexOf("end-tag") !== -1) { |
| 1732 | return; |
| 1733 | } |
| 1734 | |
| 1735 | if (this.voidElements && !this.voidElements[tag]) { |
| 1736 | var nextToken = session.getTokenAt(cursor.row, cursor.column+1); |
| 1737 | var line = session.getLine(row); |
| 1738 | var nextIndent = this.$getIndent(line); |
| 1739 | var indent = nextIndent + session.getTabString(); |
| 1740 | |
| 1741 | if (nextToken && nextToken.value === "</") { |
| 1742 | return { |
| 1743 | text: "\n" + indent + "\n" + nextIndent, |
| 1744 | selection: [1, indent.length, 1, indent.length] |
| 1745 | }; |
| 1746 | } else { |
| 1747 | return { |
| 1748 | text: "\n" + indent |
| 1749 | }; |
| 1750 | } |
| 1751 | } |
| 1752 | } |
| 1753 | } |
| 1754 | }); |
| 1755 | |
| 1756 | }; |
| 1757 | |
| 1758 | oop.inherits(XmlBehaviour, Behaviour); |
| 1759 | |
| 1760 | exports.XmlBehaviour = XmlBehaviour; |
| 1761 | }); |
| 1762 | |
| 1763 | define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) { |
| 1764 | "use strict"; |
| 1765 | |
| 1766 | var oop = require("../../lib/oop"); |
| 1767 | var BaseFoldMode = require("./fold_mode").FoldMode; |
| 1768 | |
| 1769 | var FoldMode = exports.FoldMode = function(defaultMode, subModes) { |
| 1770 | this.defaultMode = defaultMode; |
| 1771 | this.subModes = subModes; |
| 1772 | }; |
| 1773 | oop.inherits(FoldMode, BaseFoldMode); |
| 1774 | |
| 1775 | (function() { |
| 1776 | |
| 1777 | |
| 1778 | this.$getMode = function(state) { |
| 1779 | if (typeof state != "string") |
| 1780 | state = state[0]; |
| 1781 | for (var key in this.subModes) { |
| 1782 | if (state.indexOf(key) === 0) |
| 1783 | return this.subModes[key]; |
| 1784 | } |
| 1785 | return null; |
| 1786 | }; |
| 1787 | |
| 1788 | this.$tryMode = function(state, session, foldStyle, row) { |
| 1789 | var mode = this.$getMode(state); |
| 1790 | return (mode ? mode.getFoldWidget(session, foldStyle, row) : ""); |
| 1791 | }; |
| 1792 | |
| 1793 | this.getFoldWidget = function(session, foldStyle, row) { |
| 1794 | return ( |
| 1795 | this.$tryMode(session.getState(row-1), session, foldStyle, row) || |
| 1796 | this.$tryMode(session.getState(row), session, foldStyle, row) || |
| 1797 | this.defaultMode.getFoldWidget(session, foldStyle, row) |
| 1798 | ); |
| 1799 | }; |
| 1800 | |
| 1801 | this.getFoldWidgetRange = function(session, foldStyle, row) { |
| 1802 | var mode = this.$getMode(session.getState(row-1)); |
| 1803 | |
| 1804 | if (!mode || !mode.getFoldWidget(session, foldStyle, row)) |
| 1805 | mode = this.$getMode(session.getState(row)); |
| 1806 | |
| 1807 | if (!mode || !mode.getFoldWidget(session, foldStyle, row)) |
| 1808 | mode = this.defaultMode; |
| 1809 | |
| 1810 | return mode.getFoldWidgetRange(session, foldStyle, row); |
| 1811 | }; |
| 1812 | |
| 1813 | }).call(FoldMode.prototype); |
| 1814 | |
| 1815 | }); |
| 1816 | |
| 1817 | define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/range","ace/mode/folding/fold_mode","ace/token_iterator"], function(require, exports, module) { |
| 1818 | "use strict"; |
| 1819 | |
| 1820 | var oop = require("../../lib/oop"); |
| 1821 | var lang = require("../../lib/lang"); |
| 1822 | var Range = require("../../range").Range; |
| 1823 | var BaseFoldMode = require("./fold_mode").FoldMode; |
| 1824 | var TokenIterator = require("../../token_iterator").TokenIterator; |
| 1825 | |
| 1826 | var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) { |
| 1827 | BaseFoldMode.call(this); |
| 1828 | this.voidElements = voidElements || {}; |
| 1829 | this.optionalEndTags = oop.mixin({}, this.voidElements); |
| 1830 | if (optionalEndTags) |
| 1831 | oop.mixin(this.optionalEndTags, optionalEndTags); |
| 1832 | |
| 1833 | }; |
| 1834 | oop.inherits(FoldMode, BaseFoldMode); |
| 1835 | |
| 1836 | var Tag = function() { |
| 1837 | this.tagName = ""; |
| 1838 | this.closing = false; |
| 1839 | this.selfClosing = false; |
| 1840 | this.start = {row: 0, column: 0}; |
| 1841 | this.end = {row: 0, column: 0}; |
| 1842 | }; |
| 1843 | |
| 1844 | function is(token, type) { |
| 1845 | return token.type.lastIndexOf(type + ".xml") > -1; |
| 1846 | } |
| 1847 | |
| 1848 | (function() { |
| 1849 | |
| 1850 | this.getFoldWidget = function(session, foldStyle, row) { |
| 1851 | var tag = this._getFirstTagInLine(session, row); |
| 1852 | |
| 1853 | if (!tag) |
| 1854 | return this.getCommentFoldWidget(session, row); |
| 1855 | |
| 1856 | if (tag.closing || (!tag.tagName && tag.selfClosing)) |
| 1857 | return foldStyle == "markbeginend" ? "end" : ""; |
| 1858 | |
| 1859 | if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase())) |
| 1860 | return ""; |
| 1861 | |
| 1862 | if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column)) |
| 1863 | return ""; |
| 1864 | |
| 1865 | return "start"; |
| 1866 | }; |
| 1867 | |
| 1868 | this.getCommentFoldWidget = function(session, row) { |
| 1869 | if (/comment/.test(session.getState(row)) && /<!-/.test(session.getLine(row))) |
| 1870 | return "start"; |
| 1871 | return ""; |
| 1872 | }; |
| 1873 | this._getFirstTagInLine = function(session, row) { |
| 1874 | var tokens = session.getTokens(row); |
| 1875 | var tag = new Tag(); |
| 1876 | |
| 1877 | for (var i = 0; i < tokens.length; i++) { |
| 1878 | var token = tokens[i]; |
| 1879 | if (is(token, "tag-open")) { |
| 1880 | tag.end.column = tag.start.column + token.value.length; |
| 1881 | tag.closing = is(token, "end-tag-open"); |
| 1882 | token = tokens[++i]; |
| 1883 | if (!token) |
| 1884 | return null; |
| 1885 | tag.tagName = token.value; |
| 1886 | tag.end.column += token.value.length; |
| 1887 | for (i++; i < tokens.length; i++) { |
| 1888 | token = tokens[i]; |
| 1889 | tag.end.column += token.value.length; |
| 1890 | if (is(token, "tag-close")) { |
| 1891 | tag.selfClosing = token.value == '/>'; |
| 1892 | break; |
| 1893 | } |
| 1894 | } |
| 1895 | return tag; |
| 1896 | } else if (is(token, "tag-close")) { |
| 1897 | tag.selfClosing = token.value == '/>'; |
| 1898 | return tag; |
| 1899 | } |
| 1900 | tag.start.column += token.value.length; |
| 1901 | } |
| 1902 | |
| 1903 | return null; |
| 1904 | }; |
| 1905 | |
| 1906 | this._findEndTagInLine = function(session, row, tagName, startColumn) { |
| 1907 | var tokens = session.getTokens(row); |
| 1908 | var column = 0; |
| 1909 | for (var i = 0; i < tokens.length; i++) { |
| 1910 | var token = tokens[i]; |
| 1911 | column += token.value.length; |
| 1912 | if (column < startColumn) |
| 1913 | continue; |
| 1914 | if (is(token, "end-tag-open")) { |
| 1915 | token = tokens[i + 1]; |
| 1916 | if (token && token.value == tagName) |
| 1917 | return true; |
| 1918 | } |
| 1919 | } |
| 1920 | return false; |
| 1921 | }; |
| 1922 | this._readTagForward = function(iterator) { |
| 1923 | var token = iterator.getCurrentToken(); |
| 1924 | if (!token) |
| 1925 | return null; |
| 1926 | |
| 1927 | var tag = new Tag(); |
| 1928 | do { |
| 1929 | if (is(token, "tag-open")) { |
| 1930 | tag.closing = is(token, "end-tag-open"); |
| 1931 | tag.start.row = iterator.getCurrentTokenRow(); |
| 1932 | tag.start.column = iterator.getCurrentTokenColumn(); |
| 1933 | } else if (is(token, "tag-name")) { |
| 1934 | tag.tagName = token.value; |
| 1935 | } else if (is(token, "tag-close")) { |
| 1936 | tag.selfClosing = token.value == "/>"; |
| 1937 | tag.end.row = iterator.getCurrentTokenRow(); |
| 1938 | tag.end.column = iterator.getCurrentTokenColumn() + token.value.length; |
| 1939 | iterator.stepForward(); |
| 1940 | return tag; |
| 1941 | } |
| 1942 | } while(token = iterator.stepForward()); |
| 1943 | |
| 1944 | return null; |
| 1945 | }; |
| 1946 | |
| 1947 | this._readTagBackward = function(iterator) { |
| 1948 | var token = iterator.getCurrentToken(); |
| 1949 | if (!token) |
| 1950 | return null; |
| 1951 | |
| 1952 | var tag = new Tag(); |
| 1953 | do { |
| 1954 | if (is(token, "tag-open")) { |
| 1955 | tag.closing = is(token, "end-tag-open"); |
| 1956 | tag.start.row = iterator.getCurrentTokenRow(); |
| 1957 | tag.start.column = iterator.getCurrentTokenColumn(); |
| 1958 | iterator.stepBackward(); |
| 1959 | return tag; |
| 1960 | } else if (is(token, "tag-name")) { |
| 1961 | tag.tagName = token.value; |
| 1962 | } else if (is(token, "tag-close")) { |
| 1963 | tag.selfClosing = token.value == "/>"; |
| 1964 | tag.end.row = iterator.getCurrentTokenRow(); |
| 1965 | tag.end.column = iterator.getCurrentTokenColumn() + token.value.length; |
| 1966 | } |
| 1967 | } while(token = iterator.stepBackward()); |
| 1968 | |
| 1969 | return null; |
| 1970 | }; |
| 1971 | |
| 1972 | this._pop = function(stack, tag) { |
| 1973 | while (stack.length) { |
| 1974 | |
| 1975 | var top = stack[stack.length-1]; |
| 1976 | if (!tag || top.tagName == tag.tagName) { |
| 1977 | return stack.pop(); |
| 1978 | } |
| 1979 | else if (this.optionalEndTags.hasOwnProperty(top.tagName)) { |
| 1980 | stack.pop(); |
| 1981 | continue; |
| 1982 | } else { |
| 1983 | return null; |
| 1984 | } |
| 1985 | } |
| 1986 | }; |
| 1987 | |
| 1988 | this.getFoldWidgetRange = function(session, foldStyle, row) { |
| 1989 | var firstTag = this._getFirstTagInLine(session, row); |
| 1990 | |
| 1991 | if (!firstTag) { |
| 1992 | return this.getCommentFoldWidget(session, row) |
| 1993 | && session.getCommentFoldRange(row, session.getLine(row).length); |
| 1994 | } |
| 1995 | |
| 1996 | var isBackward = firstTag.closing || firstTag.selfClosing; |
| 1997 | var stack = []; |
| 1998 | var tag; |
| 1999 | |
| 2000 | if (!isBackward) { |
| 2001 | var iterator = new TokenIterator(session, row, firstTag.start.column); |
| 2002 | var start = { |
| 2003 | row: row, |
| 2004 | column: firstTag.start.column + firstTag.tagName.length + 2 |
| 2005 | }; |
| 2006 | if (firstTag.start.row == firstTag.end.row) |
| 2007 | start.column = firstTag.end.column; |
| 2008 | while (tag = this._readTagForward(iterator)) { |
| 2009 | if (tag.selfClosing) { |
| 2010 | if (!stack.length) { |
| 2011 | tag.start.column += tag.tagName.length + 2; |
| 2012 | tag.end.column -= 2; |
| 2013 | return Range.fromPoints(tag.start, tag.end); |
| 2014 | } else |
| 2015 | continue; |
| 2016 | } |
| 2017 | |
| 2018 | if (tag.closing) { |
| 2019 | this._pop(stack, tag); |
| 2020 | if (stack.length == 0) |
| 2021 | return Range.fromPoints(start, tag.start); |
| 2022 | } |
| 2023 | else { |
| 2024 | stack.push(tag); |
| 2025 | } |
| 2026 | } |
| 2027 | } |
| 2028 | else { |
| 2029 | var iterator = new TokenIterator(session, row, firstTag.end.column); |
| 2030 | var end = { |
| 2031 | row: row, |
| 2032 | column: firstTag.start.column |
| 2033 | }; |
| 2034 | |
| 2035 | while (tag = this._readTagBackward(iterator)) { |
| 2036 | if (tag.selfClosing) { |
| 2037 | if (!stack.length) { |
| 2038 | tag.start.column += tag.tagName.length + 2; |
| 2039 | tag.end.column -= 2; |
| 2040 | return Range.fromPoints(tag.start, tag.end); |
| 2041 | } else |
| 2042 | continue; |
| 2043 | } |
| 2044 | |
| 2045 | if (!tag.closing) { |
| 2046 | this._pop(stack, tag); |
| 2047 | if (stack.length == 0) { |
| 2048 | tag.start.column += tag.tagName.length + 2; |
| 2049 | if (tag.start.row == tag.end.row && tag.start.column < tag.end.column) |
| 2050 | tag.start.column = tag.end.column; |
| 2051 | return Range.fromPoints(tag.start, end); |
| 2052 | } |
| 2053 | } |
| 2054 | else { |
| 2055 | stack.push(tag); |
| 2056 | } |
| 2057 | } |
| 2058 | } |
| 2059 | |
| 2060 | }; |
| 2061 | |
| 2062 | }).call(FoldMode.prototype); |
| 2063 | |
| 2064 | }); |
| 2065 | |
| 2066 | define("ace/mode/folding/html",["require","exports","module","ace/lib/oop","ace/mode/folding/mixed","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module) { |
| 2067 | "use strict"; |
| 2068 | |
| 2069 | var oop = require("../../lib/oop"); |
| 2070 | var MixedFoldMode = require("./mixed").FoldMode; |
| 2071 | var XmlFoldMode = require("./xml").FoldMode; |
| 2072 | var CStyleFoldMode = require("./cstyle").FoldMode; |
| 2073 | |
| 2074 | var FoldMode = exports.FoldMode = function(voidElements, optionalTags) { |
| 2075 | MixedFoldMode.call(this, new XmlFoldMode(voidElements, optionalTags), { |
| 2076 | "js-": new CStyleFoldMode(), |
| 2077 | "css-": new CStyleFoldMode() |
| 2078 | }); |
| 2079 | }; |
| 2080 | |
| 2081 | oop.inherits(FoldMode, MixedFoldMode); |
| 2082 | |
| 2083 | }); |
| 2084 | |
| 2085 | define("ace/mode/html_completions",["require","exports","module","ace/token_iterator"], function(require, exports, module) { |
| 2086 | "use strict"; |
| 2087 | |
| 2088 | var TokenIterator = require("../token_iterator").TokenIterator; |
| 2089 | |
| 2090 | var commonAttributes = [ |
| 2091 | "accesskey", |
| 2092 | "class", |
| 2093 | "contenteditable", |
| 2094 | "contextmenu", |
| 2095 | "dir", |
| 2096 | "draggable", |
| 2097 | "dropzone", |
| 2098 | "hidden", |
| 2099 | "id", |
| 2100 | "inert", |
| 2101 | "itemid", |
| 2102 | "itemprop", |
| 2103 | "itemref", |
| 2104 | "itemscope", |
| 2105 | "itemtype", |
| 2106 | "lang", |
| 2107 | "spellcheck", |
| 2108 | "style", |
| 2109 | "tabindex", |
| 2110 | "title", |
| 2111 | "translate" |
| 2112 | ]; |
| 2113 | |
| 2114 | var eventAttributes = [ |
| 2115 | "onabort", |
| 2116 | "onblur", |
| 2117 | "oncancel", |
| 2118 | "oncanplay", |
| 2119 | "oncanplaythrough", |
| 2120 | "onchange", |
| 2121 | "onclick", |
| 2122 | "onclose", |
| 2123 | "oncontextmenu", |
| 2124 | "oncuechange", |
| 2125 | "ondblclick", |
| 2126 | "ondrag", |
| 2127 | "ondragend", |
| 2128 | "ondragenter", |
| 2129 | "ondragleave", |
| 2130 | "ondragover", |
| 2131 | "ondragstart", |
| 2132 | "ondrop", |
| 2133 | "ondurationchange", |
| 2134 | "onemptied", |
| 2135 | "onended", |
| 2136 | "onerror", |
| 2137 | "onfocus", |
| 2138 | "oninput", |
| 2139 | "oninvalid", |
| 2140 | "onkeydown", |
| 2141 | "onkeypress", |
| 2142 | "onkeyup", |
| 2143 | "onload", |
| 2144 | "onloadeddata", |
| 2145 | "onloadedmetadata", |
| 2146 | "onloadstart", |
| 2147 | "onmousedown", |
| 2148 | "onmousemove", |
| 2149 | "onmouseout", |
| 2150 | "onmouseover", |
| 2151 | "onmouseup", |
| 2152 | "onmousewheel", |
| 2153 | "onpause", |
| 2154 | "onplay", |
| 2155 | "onplaying", |
| 2156 | "onprogress", |
| 2157 | "onratechange", |
| 2158 | "onreset", |
| 2159 | "onscroll", |
| 2160 | "onseeked", |
| 2161 | "onseeking", |
| 2162 | "onselect", |
| 2163 | "onshow", |
| 2164 | "onstalled", |
| 2165 | "onsubmit", |
| 2166 | "onsuspend", |
| 2167 | "ontimeupdate", |
| 2168 | "onvolumechange", |
| 2169 | "onwaiting" |
| 2170 | ]; |
| 2171 | |
| 2172 | var globalAttributes = commonAttributes.concat(eventAttributes); |
| 2173 | |
| 2174 | var attributeMap = { |
| 2175 | "html": {"manifest": 1}, |
| 2176 | "head": {}, |
| 2177 | "title": {}, |
| 2178 | "base": {"href": 1, "target": 1}, |
| 2179 | "link": {"href": 1, "hreflang": 1, "rel": {"stylesheet": 1, "icon": 1}, "media": {"all": 1, "screen": 1, "print": 1}, "type": {"text/css": 1, "image/png": 1, "image/jpeg": 1, "image/gif": 1}, "sizes": 1}, |
| 2180 | "meta": {"http-equiv": {"content-type": 1}, "name": {"description": 1, "keywords": 1}, "content": {"text/html; charset=UTF-8": 1}, "charset": 1}, |
| 2181 | "style": {"type": 1, "media": {"all": 1, "screen": 1, "print": 1}, "scoped": 1}, |
| 2182 | "script": {"charset": 1, "type": {"text/javascript": 1}, "src": 1, "defer": 1, "async": 1}, |
| 2183 | "noscript": {"href": 1}, |
| 2184 | "body": {"onafterprint": 1, "onbeforeprint": 1, "onbeforeunload": 1, "onhashchange": 1, "onmessage": 1, "onoffline": 1, "onpopstate": 1, "onredo": 1, "onresize": 1, "onstorage": 1, "onundo": 1, "onunload": 1}, |
| 2185 | "section": {}, |
| 2186 | "nav": {}, |
| 2187 | "article": {"pubdate": 1}, |
| 2188 | "aside": {}, |
| 2189 | "h1": {}, |
| 2190 | "h2": {}, |
| 2191 | "h3": {}, |
| 2192 | "h4": {}, |
| 2193 | "h5": {}, |
| 2194 | "h6": {}, |
| 2195 | "header": {}, |
| 2196 | "footer": {}, |
| 2197 | "address": {}, |
| 2198 | "main": {}, |
| 2199 | "p": {}, |
| 2200 | "hr": {}, |
| 2201 | "pre": {}, |
| 2202 | "blockquote": {"cite": 1}, |
| 2203 | "ol": {"start": 1, "reversed": 1}, |
| 2204 | "ul": {}, |
| 2205 | "li": {"value": 1}, |
| 2206 | "dl": {}, |
| 2207 | "dt": {}, |
| 2208 | "dd": {}, |
| 2209 | "figure": {}, |
| 2210 | "figcaption": {}, |
| 2211 | "div": {}, |
| 2212 | "a": {"href": 1, "target": {"_blank": 1, "top": 1}, "ping": 1, "rel": {"nofollow": 1, "alternate": 1, "author": 1, "bookmark": 1, "help": 1, "license": 1, "next": 1, "noreferrer": 1, "prefetch": 1, "prev": 1, "search": 1, "tag": 1}, "media": 1, "hreflang": 1, "type": 1}, |
| 2213 | "em": {}, |
| 2214 | "strong": {}, |
| 2215 | "small": {}, |
| 2216 | "s": {}, |
| 2217 | "cite": {}, |
| 2218 | "q": {"cite": 1}, |
| 2219 | "dfn": {}, |
| 2220 | "abbr": {}, |
| 2221 | "data": {}, |
| 2222 | "time": {"datetime": 1}, |
| 2223 | "code": {}, |
| 2224 | "var": {}, |
| 2225 | "samp": {}, |
| 2226 | "kbd": {}, |
| 2227 | "sub": {}, |
| 2228 | "sup": {}, |
| 2229 | "i": {}, |
| 2230 | "b": {}, |
| 2231 | "u": {}, |
| 2232 | "mark": {}, |
| 2233 | "ruby": {}, |
| 2234 | "rt": {}, |
| 2235 | "rp": {}, |
| 2236 | "bdi": {}, |
| 2237 | "bdo": {}, |
| 2238 | "span": {}, |
| 2239 | "br": {}, |
| 2240 | "wbr": {}, |
| 2241 | "ins": {"cite": 1, "datetime": 1}, |
| 2242 | "del": {"cite": 1, "datetime": 1}, |
| 2243 | "img": {"alt": 1, "src": 1, "height": 1, "width": 1, "usemap": 1, "ismap": 1}, |
| 2244 | "iframe": {"name": 1, "src": 1, "height": 1, "width": 1, "sandbox": {"allow-same-origin": 1, "allow-top-navigation": 1, "allow-forms": 1, "allow-scripts": 1}, "seamless": {"seamless": 1}}, |
| 2245 | "embed": {"src": 1, "height": 1, "width": 1, "type": 1}, |
| 2246 | "object": {"param": 1, "data": 1, "type": 1, "height" : 1, "width": 1, "usemap": 1, "name": 1, "form": 1, "classid": 1}, |
| 2247 | "param": {"name": 1, "value": 1}, |
| 2248 | "video": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "width": 1, "height": 1, "poster": 1, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1}}, |
| 2249 | "audio": {"src": 1, "autobuffer": 1, "autoplay": {"autoplay": 1}, "loop": {"loop": 1}, "controls": {"controls": 1}, "muted": {"muted": 1}, "preload": {"auto": 1, "metadata": 1, "none": 1 }}, |
| 2250 | "source": {"src": 1, "type": 1, "media": 1}, |
| 2251 | "track": {"kind": 1, "src": 1, "srclang": 1, "label": 1, "default": 1}, |
| 2252 | "canvas": {"width": 1, "height": 1}, |
| 2253 | "map": {"name": 1}, |
| 2254 | "area": {"shape": 1, "coords": 1, "href": 1, "hreflang": 1, "alt": 1, "target": 1, "media": 1, "rel": 1, "ping": 1, "type": 1}, |
| 2255 | "svg": {}, |
| 2256 | "math": {}, |
| 2257 | "table": {"summary": 1}, |
| 2258 | "caption": {}, |
| 2259 | "colgroup": {"span": 1}, |
| 2260 | "col": {"span": 1}, |
| 2261 | "tbody": {}, |
| 2262 | "thead": {}, |
| 2263 | "tfoot": {}, |
| 2264 | "tr": {}, |
| 2265 | "td": {"headers": 1, "rowspan": 1, "colspan": 1}, |
| 2266 | "th": {"headers": 1, "rowspan": 1, "colspan": 1, "scope": 1}, |
| 2267 | "form": {"accept-charset": 1, "action": 1, "autocomplete": 1, "enctype": {"multipart/form-data": 1, "application/x-www-form-urlencoded": 1}, "method": {"get": 1, "post": 1}, "name": 1, "novalidate": 1, "target": {"_blank": 1, "top": 1}}, |
| 2268 | "fieldset": {"disabled": 1, "form": 1, "name": 1}, |
| 2269 | "legend": {}, |
| 2270 | "label": {"form": 1, "for": 1}, |
| 2271 | "input": { |
| 2272 | "type": {"text": 1, "password": 1, "hidden": 1, "checkbox": 1, "submit": 1, "radio": 1, "file": 1, "button": 1, "reset": 1, "image": 31, "color": 1, "date": 1, "datetime": 1, "datetime-local": 1, "email": 1, "month": 1, "number": 1, "range": 1, "search": 1, "tel": 1, "time": 1, "url": 1, "week": 1}, |
| 2273 | "accept": 1, "alt": 1, "autocomplete": {"on": 1, "off": 1}, "autofocus": {"autofocus": 1}, "checked": {"checked": 1}, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": {"application/x-www-form-urlencoded": 1, "multipart/form-data": 1, "text/plain": 1}, "formmethod": {"get": 1, "post": 1}, "formnovalidate": {"formnovalidate": 1}, "formtarget": {"_blank": 1, "_self": 1, "_parent": 1, "_top": 1}, "height": 1, "list": 1, "max": 1, "maxlength": 1, "min": 1, "multiple": {"multiple": 1}, "name": 1, "pattern": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "size": 1, "src": 1, "step": 1, "width": 1, "files": 1, "value": 1}, |
| 2274 | "button": {"autofocus": 1, "disabled": {"disabled": 1}, "form": 1, "formaction": 1, "formenctype": 1, "formmethod": 1, "formnovalidate": 1, "formtarget": 1, "name": 1, "value": 1, "type": {"button": 1, "submit": 1}}, |
| 2275 | "select": {"autofocus": 1, "disabled": 1, "form": 1, "multiple": {"multiple": 1}, "name": 1, "size": 1, "readonly":{"readonly": 1}}, |
| 2276 | "datalist": {}, |
| 2277 | "optgroup": {"disabled": 1, "label": 1}, |
| 2278 | "option": {"disabled": 1, "selected": 1, "label": 1, "value": 1}, |
| 2279 | "textarea": {"autofocus": {"autofocus": 1}, "disabled": {"disabled": 1}, "form": 1, "maxlength": 1, "name": 1, "placeholder": 1, "readonly": {"readonly": 1}, "required": {"required": 1}, "rows": 1, "cols": 1, "wrap": {"on": 1, "off": 1, "hard": 1, "soft": 1}}, |
| 2280 | "keygen": {"autofocus": 1, "challenge": {"challenge": 1}, "disabled": {"disabled": 1}, "form": 1, "keytype": {"rsa": 1, "dsa": 1, "ec": 1}, "name": 1}, |
| 2281 | "output": {"for": 1, "form": 1, "name": 1}, |
| 2282 | "progress": {"value": 1, "max": 1}, |
| 2283 | "meter": {"value": 1, "min": 1, "max": 1, "low": 1, "high": 1, "optimum": 1}, |
| 2284 | "details": {"open": 1}, |
| 2285 | "summary": {}, |
| 2286 | "command": {"type": 1, "label": 1, "icon": 1, "disabled": 1, "checked": 1, "radiogroup": 1, "command": 1}, |
| 2287 | "menu": {"type": 1, "label": 1}, |
| 2288 | "dialog": {"open": 1} |
| 2289 | }; |
| 2290 | |
| 2291 | var elements = Object.keys(attributeMap); |
| 2292 | |
| 2293 | function is(token, type) { |
| 2294 | return token.type.lastIndexOf(type + ".xml") > -1; |
| 2295 | } |
| 2296 | |
| 2297 | function findTagName(session, pos) { |
| 2298 | var iterator = new TokenIterator(session, pos.row, pos.column); |
| 2299 | var token = iterator.getCurrentToken(); |
| 2300 | while (token && !is(token, "tag-name")){ |
| 2301 | token = iterator.stepBackward(); |
| 2302 | } |
| 2303 | if (token) |
| 2304 | return token.value; |
| 2305 | } |
| 2306 | |
| 2307 | function findAttributeName(session, pos) { |
| 2308 | var iterator = new TokenIterator(session, pos.row, pos.column); |
| 2309 | var token = iterator.getCurrentToken(); |
| 2310 | while (token && !is(token, "attribute-name")){ |
| 2311 | token = iterator.stepBackward(); |
| 2312 | } |
| 2313 | if (token) |
| 2314 | return token.value; |
| 2315 | } |
| 2316 | |
| 2317 | var HtmlCompletions = function() { |
| 2318 | |
| 2319 | }; |
| 2320 | |
| 2321 | (function() { |
| 2322 | |
| 2323 | this.getCompletions = function(state, session, pos, prefix) { |
| 2324 | var token = session.getTokenAt(pos.row, pos.column); |
| 2325 | |
| 2326 | if (!token) |
| 2327 | return []; |
| 2328 | if (is(token, "tag-name") || is(token, "tag-open") || is(token, "end-tag-open")) |
| 2329 | return this.getTagCompletions(state, session, pos, prefix); |
| 2330 | if (is(token, "tag-whitespace") || is(token, "attribute-name")) |
| 2331 | return this.getAttributeCompletions(state, session, pos, prefix); |
| 2332 | if (is(token, "attribute-value")) |
| 2333 | return this.getAttributeValueCompletions(state, session, pos, prefix); |
| 2334 | var line = session.getLine(pos.row).substr(0, pos.column); |
| 2335 | if (/&[a-z]*$/i.test(line)) |
| 2336 | return this.getHTMLEntityCompletions(state, session, pos, prefix); |
| 2337 | |
| 2338 | return []; |
| 2339 | }; |
| 2340 | |
| 2341 | this.getTagCompletions = function(state, session, pos, prefix) { |
| 2342 | return elements.map(function(element){ |
| 2343 | return { |
| 2344 | value: element, |
| 2345 | meta: "tag", |
| 2346 | score: Number.MAX_VALUE |
| 2347 | }; |
| 2348 | }); |
| 2349 | }; |
| 2350 | |
| 2351 | this.getAttributeCompletions = function(state, session, pos, prefix) { |
| 2352 | var tagName = findTagName(session, pos); |
| 2353 | if (!tagName) |
| 2354 | return []; |
| 2355 | var attributes = globalAttributes; |
| 2356 | if (tagName in attributeMap) { |
| 2357 | attributes = attributes.concat(Object.keys(attributeMap[tagName])); |
| 2358 | } |
| 2359 | return attributes.map(function(attribute){ |
| 2360 | return { |
| 2361 | caption: attribute, |
| 2362 | snippet: attribute + '="$0"', |
| 2363 | meta: "attribute", |
| 2364 | score: Number.MAX_VALUE |
| 2365 | }; |
| 2366 | }); |
| 2367 | }; |
| 2368 | |
| 2369 | this.getAttributeValueCompletions = function(state, session, pos, prefix) { |
| 2370 | var tagName = findTagName(session, pos); |
| 2371 | var attributeName = findAttributeName(session, pos); |
| 2372 | |
| 2373 | if (!tagName) |
| 2374 | return []; |
| 2375 | var values = []; |
| 2376 | if (tagName in attributeMap && attributeName in attributeMap[tagName] && typeof attributeMap[tagName][attributeName] === "object") { |
| 2377 | values = Object.keys(attributeMap[tagName][attributeName]); |
| 2378 | } |
| 2379 | return values.map(function(value){ |
| 2380 | return { |
| 2381 | caption: value, |
| 2382 | snippet: value, |
| 2383 | meta: "attribute value", |
| 2384 | score: Number.MAX_VALUE |
| 2385 | }; |
| 2386 | }); |
| 2387 | }; |
| 2388 | |
| 2389 | this.getHTMLEntityCompletions = function(state, session, pos, prefix) { |
| 2390 | var values = ['Aacute;', 'aacute;', 'Acirc;', 'acirc;', 'acute;', 'AElig;', 'aelig;', 'Agrave;', 'agrave;', 'alefsym;', 'Alpha;', 'alpha;', 'amp;', 'and;', 'ang;', 'Aring;', 'aring;', 'asymp;', 'Atilde;', 'atilde;', 'Auml;', 'auml;', 'bdquo;', 'Beta;', 'beta;', 'brvbar;', 'bull;', 'cap;', 'Ccedil;', 'ccedil;', 'cedil;', 'cent;', 'Chi;', 'chi;', 'circ;', 'clubs;', 'cong;', 'copy;', 'crarr;', 'cup;', 'curren;', 'Dagger;', 'dagger;', 'dArr;', 'darr;', 'deg;', 'Delta;', 'delta;', 'diams;', 'divide;', 'Eacute;', 'eacute;', 'Ecirc;', 'ecirc;', 'Egrave;', 'egrave;', 'empty;', 'emsp;', 'ensp;', 'Epsilon;', 'epsilon;', 'equiv;', 'Eta;', 'eta;', 'ETH;', 'eth;', 'Euml;', 'euml;', 'euro;', 'exist;', 'fnof;', 'forall;', 'frac12;', 'frac14;', 'frac34;', 'frasl;', 'Gamma;', 'gamma;', 'ge;', 'gt;', 'hArr;', 'harr;', 'hearts;', 'hellip;', 'Iacute;', 'iacute;', 'Icirc;', 'icirc;', 'iexcl;', 'Igrave;', 'igrave;', 'image;', 'infin;', 'int;', 'Iota;', 'iota;', 'iquest;', 'isin;', 'Iuml;', 'iuml;', 'Kappa;', 'kappa;', 'Lambda;', 'lambda;', 'lang;', 'laquo;', 'lArr;', 'larr;', 'lceil;', 'ldquo;', 'le;', 'lfloor;', 'lowast;', 'loz;', 'lrm;', 'lsaquo;', 'lsquo;', 'lt;', 'macr;', 'mdash;', 'micro;', 'middot;', 'minus;', 'Mu;', 'mu;', 'nabla;', 'nbsp;', 'ndash;', 'ne;', 'ni;', 'not;', 'notin;', 'nsub;', 'Ntilde;', 'ntilde;', 'Nu;', 'nu;', 'Oacute;', 'oacute;', 'Ocirc;', 'ocirc;', 'OElig;', 'oelig;', 'Ograve;', 'ograve;', 'oline;', 'Omega;', 'omega;', 'Omicron;', 'omicron;', 'oplus;', 'or;', 'ordf;', 'ordm;', 'Oslash;', 'oslash;', 'Otilde;', 'otilde;', 'otimes;', 'Ouml;', 'ouml;', 'para;', 'part;', 'permil;', 'perp;', 'Phi;', 'phi;', 'Pi;', 'pi;', 'piv;', 'plusmn;', 'pound;', 'Prime;', 'prime;', 'prod;', 'prop;', 'Psi;', 'psi;', 'quot;', 'radic;', 'rang;', 'raquo;', 'rArr;', 'rarr;', 'rceil;', 'rdquo;', 'real;', 'reg;', 'rfloor;', 'Rho;', 'rho;', 'rlm;', 'rsaquo;', 'rsquo;', 'sbquo;', 'Scaron;', 'scaron;', 'sdot;', 'sect;', 'shy;', 'Sigma;', 'sigma;', 'sigmaf;', 'sim;', 'spades;', 'sub;', 'sube;', 'sum;', 'sup;', 'sup1;', 'sup2;', 'sup3;', 'supe;', 'szlig;', 'Tau;', 'tau;', 'there4;', 'Theta;', 'theta;', 'thetasym;', 'thinsp;', 'THORN;', 'thorn;', 'tilde;', 'times;', 'trade;', 'Uacute;', 'uacute;', 'uArr;', 'uarr;', 'Ucirc;', 'ucirc;', 'Ugrave;', 'ugrave;', 'uml;', 'upsih;', 'Upsilon;', 'upsilon;', 'Uuml;', 'uuml;', 'weierp;', 'Xi;', 'xi;', 'Yacute;', 'yacute;', 'yen;', 'Yuml;', 'yuml;', 'Zeta;', 'zeta;', 'zwj;', 'zwnj;']; |
| 2391 | |
| 2392 | return values.map(function(value){ |
| 2393 | return { |
| 2394 | caption: value, |
| 2395 | snippet: value, |
| 2396 | meta: "html entity", |
| 2397 | score: Number.MAX_VALUE |
| 2398 | }; |
| 2399 | }); |
| 2400 | }; |
| 2401 | |
| 2402 | }).call(HtmlCompletions.prototype); |
| 2403 | |
| 2404 | exports.HtmlCompletions = HtmlCompletions; |
| 2405 | }); |
| 2406 | |
| 2407 | define("ace/mode/html",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/javascript","ace/mode/css","ace/mode/html_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/html","ace/mode/html_completions","ace/worker/worker_client"], function(require, exports, module) { |
| 2408 | "use strict"; |
| 2409 | |
| 2410 | var oop = require("../lib/oop"); |
| 2411 | var lang = require("../lib/lang"); |
| 2412 | var TextMode = require("./text").Mode; |
| 2413 | var JavaScriptMode = require("./javascript").Mode; |
| 2414 | var CssMode = require("./css").Mode; |
| 2415 | var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules; |
| 2416 | var XmlBehaviour = require("./behaviour/xml").XmlBehaviour; |
| 2417 | var HtmlFoldMode = require("./folding/html").FoldMode; |
| 2418 | var HtmlCompletions = require("./html_completions").HtmlCompletions; |
| 2419 | var WorkerClient = require("../worker/worker_client").WorkerClient; |
| 2420 | var voidElements = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "menuitem", "param", "source", "track", "wbr"]; |
| 2421 | var optionalEndTags = ["li", "dt", "dd", "p", "rt", "rp", "optgroup", "option", "colgroup", "td", "th"]; |
| 2422 | |
| 2423 | var Mode = function(options) { |
| 2424 | this.fragmentContext = options && options.fragmentContext; |
| 2425 | this.HighlightRules = HtmlHighlightRules; |
| 2426 | this.$behaviour = new XmlBehaviour(); |
| 2427 | this.$completer = new HtmlCompletions(); |
| 2428 | |
| 2429 | this.createModeDelegates({ |
| 2430 | "js-": JavaScriptMode, |
| 2431 | "css-": CssMode |
| 2432 | }); |
| 2433 | |
| 2434 | this.foldingRules = new HtmlFoldMode(this.voidElements, lang.arrayToMap(optionalEndTags)); |
| 2435 | }; |
| 2436 | oop.inherits(Mode, TextMode); |
| 2437 | |
| 2438 | (function() { |
| 2439 | |
| 2440 | this.blockComment = {start: "<!--", end: "-->"}; |
| 2441 | |
| 2442 | this.voidElements = lang.arrayToMap(voidElements); |
| 2443 | |
| 2444 | this.getNextLineIndent = function(state, line, tab) { |
| 2445 | return this.$getIndent(line); |
| 2446 | }; |
| 2447 | |
| 2448 | this.checkOutdent = function(state, line, input) { |
| 2449 | return false; |
| 2450 | }; |
| 2451 | |
| 2452 | this.getCompletions = function(state, session, pos, prefix) { |
| 2453 | return this.$completer.getCompletions(state, session, pos, prefix); |
| 2454 | }; |
| 2455 | |
| 2456 | this.createWorker = function(session) { |
| 2457 | if (this.constructor != Mode) |
| 2458 | return; |
| 2459 | var worker = new WorkerClient(["ace"], "ace/mode/html_worker", "Worker"); |
| 2460 | worker.attachToDocument(session.getDocument()); |
| 2461 | |
| 2462 | if (this.fragmentContext) |
| 2463 | worker.call("setOptions", [{context: this.fragmentContext}]); |
| 2464 | |
| 2465 | worker.on("error", function(e) { |
| 2466 | session.setAnnotations(e.data); |
| 2467 | }); |
| 2468 | |
| 2469 | worker.on("terminate", function() { |
| 2470 | session.clearAnnotations(); |
| 2471 | }); |
| 2472 | |
| 2473 | return worker; |
| 2474 | }; |
| 2475 | |
| 2476 | this.$id = "ace/mode/html"; |
| 2477 | }).call(Mode.prototype); |
| 2478 | |
| 2479 | exports.Mode = Mode; |
| 2480 | }); |