formagic 0.3.9 → 0.3.10

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