ace-rails-ap 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -1
  3. data/lib/ace/rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/ace/ace.js +6911 -5290
  5. data/vendor/assets/javascripts/ace/ext-chromevox.js +537 -0
  6. data/vendor/assets/javascripts/ace/ext-elastic_tabstops_lite.js +301 -0
  7. data/vendor/assets/javascripts/ace/ext-emmet.js +1109 -0
  8. data/vendor/assets/javascripts/ace/ext-keybinding_menu.js +207 -0
  9. data/vendor/assets/javascripts/ace/ext-language_tools.js +1665 -0
  10. data/vendor/assets/javascripts/ace/ext-modelist.js +168 -0
  11. data/vendor/assets/javascripts/ace/ext-old_ie.js +500 -0
  12. data/vendor/assets/javascripts/ace/ext-options.js +252 -0
  13. data/vendor/assets/javascripts/ace/ext-searchbox.js +421 -0
  14. data/vendor/assets/javascripts/ace/ext-settings_menu.js +632 -0
  15. data/vendor/assets/javascripts/ace/ext-spellcheck.js +68 -0
  16. data/vendor/assets/javascripts/ace/ext-split.js +271 -0
  17. data/vendor/assets/javascripts/ace/ext-static_highlight.js +178 -0
  18. data/vendor/assets/javascripts/ace/ext-statusbar.js +47 -0
  19. data/vendor/assets/javascripts/ace/ext-textarea.js +478 -0
  20. data/vendor/assets/javascripts/ace/ext-themelist.js +86 -0
  21. data/vendor/assets/javascripts/ace/ext-whitespace.js +206 -0
  22. data/vendor/assets/javascripts/ace/keybinding-emacs.js +822 -131
  23. data/vendor/assets/javascripts/ace/keybinding-vim.js +382 -258
  24. data/vendor/assets/javascripts/ace/mode-abap.js +261 -0
  25. data/vendor/assets/javascripts/ace/mode-actionscript.js +257 -0
  26. data/vendor/assets/javascripts/ace/mode-ada.js +118 -0
  27. data/vendor/assets/javascripts/ace/mode-asciidoc.js +373 -0
  28. data/vendor/assets/javascripts/ace/mode-assembly_x86.js +217 -0
  29. data/vendor/assets/javascripts/ace/mode-autohotkey.js +225 -0
  30. data/vendor/assets/javascripts/ace/mode-batchfile.js +213 -0
  31. data/vendor/assets/javascripts/ace/mode-c9search.js +144 -124
  32. data/vendor/assets/javascripts/ace/mode-c_cpp.js +296 -254
  33. data/vendor/assets/javascripts/ace/mode-clojure.js +113 -177
  34. data/vendor/assets/javascripts/ace/mode-cobol.js +125 -0
  35. data/vendor/assets/javascripts/ace/mode-coffee.js +152 -235
  36. data/vendor/assets/javascripts/ace/mode-coldfusion.js +823 -835
  37. data/vendor/assets/javascripts/ace/mode-csharp.js +325 -187
  38. data/vendor/assets/javascripts/ace/mode-css.js +583 -297
  39. data/vendor/assets/javascripts/ace/mode-curly.js +2423 -0
  40. data/vendor/assets/javascripts/ace/mode-d.js +492 -0
  41. data/vendor/assets/javascripts/ace/mode-dart.js +993 -0
  42. data/vendor/assets/javascripts/ace/mode-diff.js +124 -204
  43. data/vendor/assets/javascripts/ace/mode-django.js +2448 -0
  44. data/vendor/assets/javascripts/ace/mode-dot.js +361 -0
  45. data/vendor/assets/javascripts/ace/mode-ejs.js +2817 -0
  46. data/vendor/assets/javascripts/ace/mode-erlang.js +987 -0
  47. data/vendor/assets/javascripts/ace/mode-forth.js +280 -0
  48. data/vendor/assets/javascripts/ace/mode-ftl.js +1061 -0
  49. data/vendor/assets/javascripts/ace/mode-glsl.js +313 -275
  50. data/vendor/assets/javascripts/ace/mode-golang.js +268 -275
  51. data/vendor/assets/javascripts/ace/mode-groovy.js +347 -492
  52. data/vendor/assets/javascripts/ace/mode-haml.js +498 -0
  53. data/vendor/assets/javascripts/ace/mode-handlebars.js +2433 -0
  54. data/vendor/assets/javascripts/ace/mode-haskell.js +362 -0
  55. data/vendor/assets/javascripts/ace/mode-haxe.js +226 -202
  56. data/vendor/assets/javascripts/ace/mode-html.js +1099 -802
  57. data/vendor/assets/javascripts/ace/mode-html_completions.js +309 -0
  58. data/vendor/assets/javascripts/ace/mode-html_ruby.js +2822 -0
  59. data/vendor/assets/javascripts/ace/mode-ini.js +185 -0
  60. data/vendor/assets/javascripts/ace/mode-jack.js +653 -0
  61. data/vendor/assets/javascripts/ace/mode-jade.js +2081 -0
  62. data/vendor/assets/javascripts/ace/mode-java.js +339 -488
  63. data/vendor/assets/javascripts/ace/mode-javascript.js +342 -478
  64. data/vendor/assets/javascripts/ace/mode-json.js +215 -178
  65. data/vendor/assets/javascripts/ace/mode-jsoniq.js +2761 -0
  66. data/vendor/assets/javascripts/ace/mode-jsp.js +1553 -0
  67. data/vendor/assets/javascripts/ace/mode-jsx.js +325 -289
  68. data/vendor/assets/javascripts/ace/mode-julia.js +286 -0
  69. data/vendor/assets/javascripts/ace/mode-latex.js +141 -46
  70. data/vendor/assets/javascripts/ace/mode-less.js +493 -151
  71. data/vendor/assets/javascripts/ace/mode-liquid.js +594 -656
  72. data/vendor/assets/javascripts/ace/mode-lisp.js +137 -0
  73. data/vendor/assets/javascripts/ace/mode-livescript.js +288 -0
  74. data/vendor/assets/javascripts/ace/mode-logiql.js +669 -0
  75. data/vendor/assets/javascripts/ace/mode-lsl.js +890 -0
  76. data/vendor/assets/javascripts/ace/mode-lua.js +274 -368
  77. data/vendor/assets/javascripts/ace/mode-luapage.js +1331 -1107
  78. data/vendor/assets/javascripts/ace/mode-lucene.js +64 -0
  79. data/vendor/assets/javascripts/ace/mode-makefile.js +332 -0
  80. data/vendor/assets/javascripts/ace/mode-markdown.js +1303 -948
  81. data/vendor/assets/javascripts/ace/mode-matlab.js +230 -0
  82. data/vendor/assets/javascripts/ace/mode-mushcode.js +705 -0
  83. data/vendor/assets/javascripts/ace/mode-mushcode_high_rules.js +569 -0
  84. data/vendor/assets/javascripts/ace/mode-mysql.js +185 -0
  85. data/vendor/assets/javascripts/ace/mode-nix.js +935 -0
  86. data/vendor/assets/javascripts/ace/mode-objectivec.js +699 -0
  87. data/vendor/assets/javascripts/ace/mode-ocaml.js +44 -63
  88. data/vendor/assets/javascripts/ace/mode-pascal.js +233 -0
  89. data/vendor/assets/javascripts/ace/mode-perl.js +116 -189
  90. data/vendor/assets/javascripts/ace/mode-pgsql.js +886 -500
  91. data/vendor/assets/javascripts/ace/mode-php.js +1158 -380
  92. data/vendor/assets/javascripts/ace/mode-plain_text.js +56 -0
  93. data/vendor/assets/javascripts/ace/mode-powershell.js +222 -167
  94. data/vendor/assets/javascripts/ace/mode-prolog.js +354 -0
  95. data/vendor/assets/javascripts/ace/mode-properties.js +100 -0
  96. data/vendor/assets/javascripts/ace/mode-protobuf.js +885 -0
  97. data/vendor/assets/javascripts/ace/mode-python.js +99 -201
  98. data/vendor/assets/javascripts/ace/mode-r.js +337 -0
  99. data/vendor/assets/javascripts/ace/mode-rdoc.js +210 -0
  100. data/vendor/assets/javascripts/ace/mode-rhtml.js +2663 -0
  101. data/vendor/assets/javascripts/ace/mode-ruby.js +262 -136
  102. data/vendor/assets/javascripts/ace/mode-rust.js +245 -0
  103. data/vendor/assets/javascripts/ace/mode-sass.js +443 -0
  104. data/vendor/assets/javascripts/ace/mode-scad.js +225 -240
  105. data/vendor/assets/javascripts/ace/mode-scala.js +340 -494
  106. data/vendor/assets/javascripts/ace/mode-scheme.js +143 -0
  107. data/vendor/assets/javascripts/ace/mode-scss.js +499 -157
  108. data/vendor/assets/javascripts/ace/mode-sh.js +180 -110
  109. data/vendor/assets/javascripts/ace/mode-sjs.js +1154 -0
  110. data/vendor/assets/javascripts/ace/mode-snippets.js +198 -0
  111. data/vendor/assets/javascripts/ace/mode-soy_template.js +2707 -0
  112. data/vendor/assets/javascripts/ace/mode-space.js +160 -0
  113. data/vendor/assets/javascripts/ace/mode-sql.js +48 -69
  114. data/vendor/assets/javascripts/ace/mode-stylus.js +447 -0
  115. data/vendor/assets/javascripts/ace/mode-svg.js +552 -605
  116. data/vendor/assets/javascripts/ace/mode-tcl.js +139 -98
  117. data/vendor/assets/javascripts/ace/mode-tex.js +187 -0
  118. data/vendor/assets/javascripts/ace/mode-textile.js +29 -40
  119. data/vendor/assets/javascripts/ace/mode-tmsnippet.js +200 -0
  120. data/vendor/assets/javascripts/ace/mode-toml.js +177 -0
  121. data/vendor/assets/javascripts/ace/mode-twig.js +2228 -0
  122. data/vendor/assets/javascripts/ace/mode-typescript.js +1018 -0
  123. data/vendor/assets/javascripts/ace/mode-vbscript.js +250 -0
  124. data/vendor/assets/javascripts/ace/mode-velocity.js +1621 -0
  125. data/vendor/assets/javascripts/ace/mode-verilog.js +127 -0
  126. data/vendor/assets/javascripts/ace/mode-vhdl.js +139 -0
  127. data/vendor/assets/javascripts/ace/mode-xml.js +350 -242
  128. data/vendor/assets/javascripts/ace/mode-xquery.js +2490 -300
  129. data/vendor/assets/javascripts/ace/mode-yaml.js +146 -45
  130. data/vendor/assets/javascripts/ace/theme-ambiance.js +202 -0
  131. data/vendor/assets/javascripts/ace/theme-chaos.js +179 -0
  132. data/vendor/assets/javascripts/ace/theme-chrome.js +97 -153
  133. data/vendor/assets/javascripts/ace/theme-clouds.js +78 -119
  134. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +79 -120
  135. data/vendor/assets/javascripts/ace/theme-cobalt.js +89 -140
  136. data/vendor/assets/javascripts/ace/theme-crimson_editor.js +93 -145
  137. data/vendor/assets/javascripts/ace/theme-dawn.js +84 -143
  138. data/vendor/assets/javascripts/ace/theme-dreamweaver.js +99 -162
  139. data/vendor/assets/javascripts/ace/theme-eclipse.js +78 -111
  140. data/vendor/assets/javascripts/ace/theme-github.js +70 -121
  141. data/vendor/assets/javascripts/ace/theme-idle_fingers.js +75 -134
  142. data/vendor/assets/javascripts/ace/theme-kr.js +135 -0
  143. data/vendor/assets/javascripts/ace/theme-merbivore.js +80 -143
  144. data/vendor/assets/javascripts/ace/theme-merbivore_soft.js +81 -149
  145. data/vendor/assets/javascripts/ace/theme-mono_industrial.js +87 -146
  146. data/vendor/assets/javascripts/ace/theme-monokai.js +88 -146
  147. data/vendor/assets/javascripts/ace/theme-pastel_on_dark.js +82 -142
  148. data/vendor/assets/javascripts/ace/theme-solarized_dark.js +83 -144
  149. data/vendor/assets/javascripts/ace/theme-solarized_light.js +76 -133
  150. data/vendor/assets/javascripts/ace/theme-terminal.js +145 -0
  151. data/vendor/assets/javascripts/ace/theme-textmate.js +101 -158
  152. data/vendor/assets/javascripts/ace/theme-tomorrow.js +89 -163
  153. data/vendor/assets/javascripts/ace/theme-tomorrow_night.js +89 -163
  154. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue.js +89 -165
  155. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright.js +101 -162
  156. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties.js +90 -160
  157. data/vendor/assets/javascripts/ace/theme-twilight.js +87 -158
  158. data/vendor/assets/javascripts/ace/theme-vibrant_ink.js +75 -140
  159. data/vendor/assets/javascripts/ace/theme-xcode.js +120 -0
  160. data/vendor/assets/javascripts/ace/worker-coffee.js +3049 -2665
  161. data/vendor/assets/javascripts/ace/worker-css.js +1779 -4376
  162. data/vendor/assets/javascripts/ace/worker-javascript.js +8701 -9008
  163. data/vendor/assets/javascripts/ace/worker-json.js +709 -1340
  164. data/vendor/assets/javascripts/ace/worker-lua.js +3525 -0
  165. data/vendor/assets/javascripts/ace/worker-php.js +6893 -0
  166. data/vendor/assets/javascripts/ace/worker-xquery.js +19924 -64507
  167. metadata +100 -17
@@ -1,37 +1,30 @@
1
1
  /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
2
+ * Distributed under the BSD license:
3
3
  *
4
- * The contents of this file are subject to the Mozilla Public License Version
5
- * 1.1 (the "License"); you may not use this file except in compliance with
6
- * the License. You may obtain a copy of the License at
7
- * http://www.mozilla.org/MPL/
4
+ * Copyright (c) 2010, Ajax.org B.V.
5
+ * All rights reserved.
8
6
  *
9
- * Software distributed under the License is distributed on an "AS IS" basis,
10
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
- * for the specific language governing rights and limitations under the
12
- * License.
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the name of Ajax.org B.V. nor the
15
+ * names of its contributors may be used to endorse or promote products
16
+ * derived from this software without specific prior written permission.
13
17
  *
14
- * The Original Code is Ajax.org Code Editor (ACE).
15
- *
16
- * The Initial Developer of the Original Code is
17
- * Ajax.org B.V.
18
- * Portions created by the Initial Developer are Copyright (C) 2010
19
- * the Initial Developer. All Rights Reserved.
20
- *
21
- * Contributor(s):
22
- * Fabian Jakobs <fabian AT ajax DOT org>
23
- *
24
- * Alternatively, the contents of this file may be used under the terms of
25
- * either the GNU General Public License Version 2 or later (the "GPL"), or
26
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
- * in which case the provisions of the GPL or the LGPL are applicable instead
28
- * of those above. If you wish to allow use of your version of this file only
29
- * under the terms of either the GPL or the LGPL, and not to allow others to
30
- * use your version of this file under the terms of the MPL, indicate your
31
- * decision by deleting the provisions above and replace them with the notice
32
- * and other provisions required by the GPL or the LGPL. If you do not delete
33
- * the provisions above, a recipient may use your version of this file under
34
- * the terms of any one of the MPL, the GPL or the LGPL.
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
28
  *
36
29
  * ***** END LICENSE BLOCK ***** */
37
30
 
@@ -49,7 +42,8 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
49
42
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
50
43
 
51
44
  var Mode = function() {
52
- this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
45
+ this.HighlightRules = JavaScriptHighlightRules;
46
+
53
47
  this.$outdent = new MatchingBraceOutdent();
54
48
  this.$behaviour = new CstyleBehaviour();
55
49
  this.foldingRules = new CStyleFoldMode();
@@ -58,53 +52,27 @@ oop.inherits(Mode, TextMode);
58
52
 
59
53
  (function() {
60
54
 
61
-
62
- this.toggleCommentLines = function(state, doc, startRow, endRow) {
63
- var outdent = true;
64
- var re = /^(\s*)\/\//;
65
-
66
- for (var i=startRow; i<= endRow; i++) {
67
- if (!re.test(doc.getLine(i))) {
68
- outdent = false;
69
- break;
70
- }
71
- }
72
-
73
- if (outdent) {
74
- var deleteRange = new Range(0, 0, 0, 0);
75
- for (var i=startRow; i<= endRow; i++)
76
- {
77
- var line = doc.getLine(i);
78
- var m = line.match(re);
79
- deleteRange.start.row = i;
80
- deleteRange.end.row = i;
81
- deleteRange.end.column = m[0].length;
82
- doc.replace(deleteRange, m[1]);
83
- }
84
- }
85
- else {
86
- doc.indentRows(startRow, endRow, "//");
87
- }
88
- };
55
+ this.lineCommentStart = "//";
56
+ this.blockComment = {start: "/*", end: "*/"};
89
57
 
90
58
  this.getNextLineIndent = function(state, line, tab) {
91
59
  var indent = this.$getIndent(line);
92
60
 
93
- var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
61
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
94
62
  var tokens = tokenizedLine.tokens;
95
63
  var endState = tokenizedLine.state;
96
64
 
97
65
  if (tokens.length && tokens[tokens.length-1].type == "comment") {
98
66
  return indent;
99
67
  }
100
-
101
- if (state == "start" || state == "regex_allowed") {
68
+
69
+ if (state == "start" || state == "no_regex") {
102
70
  var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
103
71
  if (match) {
104
72
  indent += tab;
105
73
  }
106
74
  } else if (state == "doc-start") {
107
- if (endState == "start" || state == "regex_allowed") {
75
+ if (endState == "start" || endState == "no_regex") {
108
76
  return "";
109
77
  }
110
78
  var match = line.match(/^\s*(\/?)\*/);
@@ -126,105 +94,64 @@ oop.inherits(Mode, TextMode);
126
94
  this.autoOutdent = function(state, doc, row) {
127
95
  this.$outdent.autoOutdent(doc, row);
128
96
  };
129
-
97
+
130
98
  this.createWorker = function(session) {
131
99
  var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
132
100
  worker.attachToDocument(session.getDocument());
133
-
101
+
134
102
  worker.on("jslint", function(results) {
135
- var errors = [];
136
- for (var i=0; i<results.data.length; i++) {
137
- var error = results.data[i];
138
- if (error)
139
- errors.push({
140
- row: error.line-1,
141
- column: error.character-1,
142
- text: error.reason,
143
- type: "warning",
144
- lint: error
145
- });
146
- }
147
- session.setAnnotations(errors);
148
- });
149
-
150
- worker.on("narcissus", function(e) {
151
- session.setAnnotations([e.data]);
103
+ session.setAnnotations(results.data);
152
104
  });
153
-
105
+
154
106
  worker.on("terminate", function() {
155
107
  session.clearAnnotations();
156
108
  });
157
-
109
+
158
110
  return worker;
159
111
  };
160
112
 
113
+ this.$id = "ace/mode/javascript";
161
114
  }).call(Mode.prototype);
162
115
 
163
116
  exports.Mode = Mode;
164
117
  });
165
118
 
166
- define('ace/mode/javascript_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/unicode', 'ace/mode/doc_comment_highlight_rules', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
119
+ 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) {
167
120
 
168
121
 
169
122
  var oop = require("../lib/oop");
170
- var lang = require("../lib/lang");
171
- var unicode = require("../unicode");
172
123
  var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
173
124
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
174
125
 
175
126
  var JavaScriptHighlightRules = function() {
176
-
177
- // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
178
- var globals = lang.arrayToMap(
179
- // Constructors
180
- ("Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" +
181
- // E4X
182
- "Namespace|QName|XML|XMLList|" +
183
- "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
184
- "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
185
- // Errors
186
- "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
187
- "SyntaxError|TypeError|URIError|" +
188
- // Non-constructor functions
189
- "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" +
190
- "isNaN|parseFloat|parseInt|" +
191
- // Other
192
- "JSON|Math|" +
193
- // Pseudo
194
- "this|arguments|prototype|window|document"
195
- ).split("|")
196
- );
197
-
198
- var keywords = lang.arrayToMap(
199
- ("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
200
- "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
201
- "const|yield|import|get|set").split("|")
202
- );
203
-
204
- // keywords which can be followed by regular expressions
205
- var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
206
-
207
- var deprecated = lang.arrayToMap(
208
- ("__parent__|__count__|escape|unescape|with|__proto__").split("|")
209
- );
210
-
211
- var definitions = lang.arrayToMap(("const|let|var|function").split("|"));
212
-
213
- var buildinConstants = lang.arrayToMap(
214
- ("null|Infinity|NaN|undefined").split("|")
215
- );
216
-
217
- var futureReserved = lang.arrayToMap(
218
- ("class|enum|extends|super|export|implements|private|" +
219
- "public|interface|package|protected|static").split("|")
220
- );
221
-
222
- // TODO: Unicode escape sequences
223
- var identifierRe = "[" + unicode.packages.L + "\\$_]["
224
- + unicode.packages.L
225
- + unicode.packages.Mn + unicode.packages.Mc
226
- + unicode.packages.Nd
227
- + unicode.packages.Pc + "\\$_]*\\b";
127
+ var keywordMapper = this.createKeywordMapper({
128
+ "variable.language":
129
+ "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
130
+ "Namespace|QName|XML|XMLList|" + // E4X
131
+ "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
132
+ "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
133
+ "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
134
+ "SyntaxError|TypeError|URIError|" +
135
+ "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
136
+ "isNaN|parseFloat|parseInt|" +
137
+ "JSON|Math|" + // Other
138
+ "this|arguments|prototype|window|document" , // Pseudo
139
+ "keyword":
140
+ "const|yield|import|get|set|" +
141
+ "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
142
+ "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
143
+ "__parent__|__count__|escape|unescape|with|__proto__|" +
144
+ "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
145
+ "storage.type":
146
+ "const|let|var|function",
147
+ "constant.language":
148
+ "null|Infinity|NaN|undefined",
149
+ "support.function":
150
+ "alert",
151
+ "constant.language.boolean": "true|false"
152
+ }, "identifier");
153
+ var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
154
+ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
228
155
 
229
156
  var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
230
157
  "u[0-9a-fA-F]{4}|" + // unicode
@@ -234,19 +161,16 @@ var JavaScriptHighlightRules = function() {
234
161
  "[4-7][0-7]?|" + //oct
235
162
  ".)";
236
163
 
237
- // regexp must not have capturing parentheses. Use (?:) instead.
238
- // regexps are ordered -> the first match is used
239
-
240
164
  this.$rules = {
241
- "start" : [
165
+ "no_regex" : [
242
166
  {
243
167
  token : "comment",
244
- regex : /\/\/.*$/
168
+ regex : "\\/\\/",
169
+ next : "line_comment"
245
170
  },
246
171
  DocCommentHighlightRules.getStartRule("doc-start"),
247
172
  {
248
173
  token : "comment", // multi line comment
249
- merge : true,
250
174
  regex : /\/\*/,
251
175
  next : "comment"
252
176
  }, {
@@ -263,119 +187,61 @@ var JavaScriptHighlightRules = function() {
263
187
  }, {
264
188
  token : "constant.numeric", // float
265
189
  regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
266
- }, { // match stuff like: Sound.prototype.play = function() { }
267
- token : [
268
- "storage.type",
269
- "punctuation.operator",
270
- "support.function",
271
- "punctuation.operator",
272
- "entity.name.function",
273
- "text",
274
- "keyword.operator",
275
- "text",
276
- "storage.type",
277
- "text",
278
- "paren.lparen"
279
- ],
280
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
281
- next: "function_arguments"
282
- }, { // match stuff like: Sound.prototype.play = myfunc
190
+ }, {
283
191
  token : [
284
- "storage.type",
285
- "punctuation.operator",
286
- "support.function",
287
- "punctuation.operator",
288
- "entity.name.function",
289
- "text",
290
- "keyword.operator",
291
- "text"
192
+ "storage.type", "punctuation.operator", "support.function",
193
+ "punctuation.operator", "entity.name.function", "text","keyword.operator"
292
194
  ],
293
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)",
195
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
294
196
  next: "function_arguments"
295
- }, { // match stuff like: Sound.play = function() { }
197
+ }, {
296
198
  token : [
297
- "storage.type",
298
- "punctuation.operator",
299
- "entity.name.function",
300
- "text",
301
- "keyword.operator",
302
- "text",
303
- "storage.type",
304
- "text",
305
- "paren.lparen"
199
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
200
+ "keyword.operator", "text", "storage.type", "text", "paren.lparen"
306
201
  ],
307
202
  regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
308
203
  next: "function_arguments"
309
- }, { // match stuff like: play = function() { }
204
+ }, {
310
205
  token : [
311
- "entity.name.function",
312
- "text",
313
- "keyword.operator",
314
- "text",
315
- "storage.type",
316
- "text",
317
- "paren.lparen"
206
+ "entity.name.function", "text", "keyword.operator", "text", "storage.type",
207
+ "text", "paren.lparen"
318
208
  ],
319
209
  regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
320
210
  next: "function_arguments"
321
- }, { // match stuff like: Sound.play = function play() { }
211
+ }, {
322
212
  token : [
323
- "storage.type",
324
- "punctuation.operator",
325
- "entity.name.function",
326
- "text",
327
- "keyword.operator",
328
- "text",
329
- "storage.type",
330
- "text",
331
- "entity.name.function",
332
- "text",
333
- "paren.lparen"
213
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
214
+ "keyword.operator", "text",
215
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
334
216
  ],
335
217
  regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
336
218
  next: "function_arguments"
337
- }, { // match regular function like: function myFunc(arg) { }
219
+ }, {
338
220
  token : [
339
- "storage.type",
340
- "text",
341
- "entity.name.function",
342
- "text",
343
- "paren.lparen"
221
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
344
222
  ],
345
223
  regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
346
224
  next: "function_arguments"
347
- }, { // match stuff like: foobar: function() { }
225
+ }, {
348
226
  token : [
349
- "entity.name.function",
350
- "text",
351
- "punctuation.operator",
352
- "text",
353
- "storage.type",
354
- "text",
355
- "paren.lparen"
227
+ "entity.name.function", "text", "punctuation.operator",
228
+ "text", "storage.type", "text", "paren.lparen"
356
229
  ],
357
230
  regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
358
231
  next: "function_arguments"
359
- }, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
232
+ }, {
360
233
  token : [
361
- "text",
362
- "text",
363
- "storage.type",
364
- "text",
365
- "paren.lparen"
234
+ "text", "text", "storage.type", "text", "paren.lparen"
366
235
  ],
367
236
  regex : "(:)(\\s*)(function)(\\s*)(\\()",
368
237
  next: "function_arguments"
369
- }, {
370
- token : "constant.language.boolean",
371
- regex : /(?:true|false)\b/
372
238
  }, {
373
239
  token : "keyword",
374
240
  regex : "(?:" + kwBeforeRe + ")\\b",
375
- next : "regex_allowed"
241
+ next : "start"
376
242
  }, {
377
243
  token : ["punctuation.operator", "support.function"],
378
- regex : /(\.)(s(?:h(?:ift|ow(?:Mod(?:elessDialog|alDialog)|Help))|croll(?:X|By(?:Pages|Lines)?|Y|To)?|t(?:opzzzz|rike)|i(?:n|zeToContent|debar|gnText)|ort|u(?:p|b(?:str(?:ing)?)?)|pli(?:ce|t)|e(?:nd|t(?:Re(?:sizable|questHeader)|M(?:i(?:nutes|lliseconds)|onth)|Seconds|Ho(?:tKeys|urs)|Year|Cursor|Time(?:out)?|Interval|ZOptions|Date|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Date|FullYear)|FullYear|Active)|arch)|qrt|lice|avePreferences|mall)|h(?:ome|andleEvent)|navigate|c(?:har(?:CodeAt|At)|o(?:s|n(?:cat|textual|firm)|mpile)|eil|lear(?:Timeout|Interval)?|a(?:ptureEvents|ll)|reate(?:StyleSheet|Popup|EventObject))|t(?:o(?:GMTString|S(?:tring|ource)|U(?:TCString|pperCase)|Lo(?:caleString|werCase))|est|a(?:n|int(?:Enabled)?))|i(?:s(?:NaN|Finite)|ndexOf|talics)|d(?:isableExternalCapture|ump|etachEvent)|u(?:n(?:shift|taint|escape|watch)|pdateCommands)|j(?:oin|avaEnabled)|p(?:o(?:p|w)|ush|lugins.refresh|a(?:ddings|rse(?:Int|Float)?)|r(?:int|ompt|eference))|e(?:scape|nableExternalCapture|val|lementFromPoint|x(?:p|ec(?:Script|Command)?))|valueOf|UTC|queryCommand(?:State|Indeterm|Enabled|Value)|f(?:i(?:nd|le(?:ModifiedDate|Size|CreatedDate|UpdatedDate)|xed)|o(?:nt(?:size|color)|rward)|loor|romCharCode)|watch|l(?:ink|o(?:ad|g)|astIndexOf)|a(?:sin|nchor|cos|t(?:tachEvent|ob|an(?:2)?)|pply|lert|b(?:s|ort))|r(?:ou(?:nd|teEvents)|e(?:size(?:By|To)|calc|turnValue|place|verse|l(?:oad|ease(?:Capture|Events)))|andom)|g(?:o|et(?:ResponseHeader|M(?:i(?:nutes|lliseconds)|onth)|Se(?:conds|lection)|Hours|Year|Time(?:zoneOffset)?|Da(?:y|te)|UTC(?:M(?:i(?:nutes|lliseconds)|onth)|Seconds|Hours|Da(?:y|te)|FullYear)|FullYear|A(?:ttention|llResponseHeaders)))|m(?:in|ove(?:B(?:y|elow)|To(?:Absolute)?|Above)|ergeAttributes|a(?:tch|rgins|x))|b(?:toa|ig|o(?:ld|rderWidths)|link|ack))\b(?=\()/
244
+ 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(?=\()/
379
245
  }, {
380
246
  token : ["punctuation.operator", "support.function.dom"],
381
247
  regex : /(\.)(s(?:ub(?:stringData|mit)|plitText|e(?:t(?:NamedItem|Attribute(?:Node)?)|lect))|has(?:ChildNodes|Feature)|namedItem|c(?:l(?:ick|o(?:se|neNode))|reate(?:C(?:omment|DATASection|aption)|T(?:Head|extNode|Foot)|DocumentFragment|ProcessingInstruction|E(?:ntityReference|lement)|Attribute))|tabIndex|i(?:nsert(?:Row|Before|Cell|Data)|tem)|open|delete(?:Row|C(?:ell|aption)|T(?:Head|Foot)|Data)|focus|write(?:ln)?|a(?:dd|ppend(?:Child|Data))|re(?:set|place(?:Child|Data)|move(?:NamedItem|Child|Attribute(?:Node)?)?)|get(?:NamedItem|Element(?:sBy(?:Name|TagName)|ById)|Attribute(?:Node)?)|blur)\b(?=\()/
@@ -386,78 +252,54 @@ var JavaScriptHighlightRules = function() {
386
252
  token : ["storage.type", "punctuation.operator", "support.function.firebug"],
387
253
  regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
388
254
  }, {
389
- token : function(value) {
390
- if (globals.hasOwnProperty(value))
391
- return "variable.language";
392
- else if (deprecated.hasOwnProperty(value))
393
- return "invalid.deprecated";
394
- else if (definitions.hasOwnProperty(value))
395
- return "storage.type";
396
- else if (keywords.hasOwnProperty(value))
397
- return "keyword";
398
- else if (buildinConstants.hasOwnProperty(value))
399
- return "constant.language";
400
- else if (futureReserved.hasOwnProperty(value))
401
- return "invalid.illegal";
402
- else if (value == "debugger")
403
- return "invalid.deprecated";
404
- else
405
- return "identifier";
406
- },
255
+ token : keywordMapper,
407
256
  regex : identifierRe
408
257
  }, {
409
258
  token : "keyword.operator",
410
- regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
411
- next : "regex_allowed"
259
+ regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
260
+ next : "start"
412
261
  }, {
413
262
  token : "punctuation.operator",
414
263
  regex : /\?|\:|\,|\;|\./,
415
- next : "regex_allowed"
264
+ next : "start"
416
265
  }, {
417
266
  token : "paren.lparen",
418
267
  regex : /[\[({]/,
419
- next : "regex_allowed"
268
+ next : "start"
420
269
  }, {
421
270
  token : "paren.rparen",
422
271
  regex : /[\])}]/
423
272
  }, {
424
273
  token : "keyword.operator",
425
274
  regex : /\/=?/,
426
- next : "regex_allowed"
275
+ next : "start"
427
276
  }, {
428
277
  token: "comment",
429
278
  regex: /^#!.*$/
430
- }, {
431
- token : "text",
432
- regex : /\s+/
433
279
  }
434
280
  ],
435
- // regular expressions are only allowed after certain tokens. This
436
- // makes sure we don't mix up regexps with the divison operator
437
- "regex_allowed": [
281
+ "start": [
438
282
  DocCommentHighlightRules.getStartRule("doc-start"),
439
283
  {
440
284
  token : "comment", // multi line comment
441
- merge : true,
442
285
  regex : "\\/\\*",
443
286
  next : "comment_regex_allowed"
444
287
  }, {
445
288
  token : "comment",
446
- regex : "\\/\\/.*$"
289
+ regex : "\\/\\/",
290
+ next : "line_comment_regex_allowed"
447
291
  }, {
448
292
  token: "string.regexp",
449
293
  regex: "\\/",
450
- next: "regex",
451
- merge: true
294
+ next: "regex"
452
295
  }, {
453
296
  token : "text",
454
- regex : "\\s+"
297
+ regex : "\\s+|^$",
298
+ next : "start"
455
299
  }, {
456
- // immediately return to the start mode without matching
457
- // anything
458
300
  token: "empty",
459
301
  regex: "",
460
- next: "start"
302
+ next: "no_regex"
461
303
  }
462
304
  ],
463
305
  "regex": [
@@ -465,24 +307,28 @@ var JavaScriptHighlightRules = function() {
465
307
  token: "regexp.keyword.operator",
466
308
  regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
467
309
  }, {
468
- // flag
469
310
  token: "string.regexp",
470
- regex: "/\\w*",
471
- next: "start",
472
- merge: true
311
+ regex: "/[sxngimy]*",
312
+ next: "no_regex"
473
313
  }, {
474
- token: "string.regexp",
475
- regex: "[^\\\\/\\[]+",
476
- merge: true
314
+ token : "invalid",
315
+ regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
477
316
  }, {
478
- token: "string.regexp.charachterclass",
479
- regex: "\\[",
480
- next: "regex_character_class",
481
- merge: true
317
+ token : "constant.language.escape",
318
+ regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
319
+ }, {
320
+ token : "constant.language.delimiter",
321
+ regex: /\|/
322
+ }, {
323
+ token: "constant.language.escape",
324
+ regex: /\[\^?/,
325
+ next: "regex_character_class"
482
326
  }, {
483
327
  token: "empty",
484
- regex: "",
485
- next: "start"
328
+ regex: "$",
329
+ next: "no_regex"
330
+ }, {
331
+ defaultToken: "string.regexp"
486
332
  }
487
333
  ],
488
334
  "regex_character_class": [
@@ -490,18 +336,18 @@ var JavaScriptHighlightRules = function() {
490
336
  token: "regexp.keyword.operator",
491
337
  regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
492
338
  }, {
493
- token: "string.regexp.charachterclass",
339
+ token: "constant.language.escape",
494
340
  regex: "]",
495
- next: "regex",
496
- merge: true
341
+ next: "regex"
497
342
  }, {
498
- token: "string.regexp.charachterclass",
499
- regex: "[^\\\\\\]]+",
500
- merge: true
343
+ token: "constant.language.escape",
344
+ regex: "-"
501
345
  }, {
502
346
  token: "empty",
503
- regex: "",
504
- next: "start"
347
+ regex: "$",
348
+ next: "no_regex"
349
+ }, {
350
+ defaultToken: "string.regexp.charachterclass"
505
351
  }
506
352
  ],
507
353
  "function_arguments": [
@@ -510,86 +356,68 @@ var JavaScriptHighlightRules = function() {
510
356
  regex: identifierRe
511
357
  }, {
512
358
  token: "punctuation.operator",
513
- regex: "[, ]+",
514
- merge: true
359
+ regex: "[, ]+"
515
360
  }, {
516
361
  token: "punctuation.operator",
517
- regex: "$",
518
- merge: true
362
+ regex: "$"
519
363
  }, {
520
364
  token: "empty",
521
365
  regex: "",
522
- next: "start"
366
+ next: "no_regex"
523
367
  }
524
368
  ],
525
369
  "comment_regex_allowed" : [
526
- {
527
- token : "comment", // closing comment
528
- regex : ".*?\\*\\/",
529
- merge : true,
530
- next : "regex_allowed"
531
- }, {
532
- token : "comment", // comment spanning whole line
533
- merge : true,
534
- regex : ".+"
535
- }
370
+ {token : "comment", regex : "\\*\\/", next : "start"},
371
+ {defaultToken : "comment"}
536
372
  ],
537
373
  "comment" : [
538
- {
539
- token : "comment", // closing comment
540
- regex : ".*?\\*\\/",
541
- merge : true,
542
- next : "start"
543
- }, {
544
- token : "comment", // comment spanning whole line
545
- merge : true,
546
- regex : ".+"
547
- }
374
+ {token : "comment", regex : "\\*\\/", next : "no_regex"},
375
+ {defaultToken : "comment"}
376
+ ],
377
+ "line_comment_regex_allowed" : [
378
+ {token : "comment", regex : "$|^", next : "start"},
379
+ {defaultToken : "comment"}
380
+ ],
381
+ "line_comment" : [
382
+ {token : "comment", regex : "$|^", next : "no_regex"},
383
+ {defaultToken : "comment"}
548
384
  ],
549
385
  "qqstring" : [
550
386
  {
551
387
  token : "constant.language.escape",
552
388
  regex : escapedRe
553
- }, {
554
- token : "string",
555
- regex : '[^"\\\\]+',
556
- merge : true
557
389
  }, {
558
390
  token : "string",
559
391
  regex : "\\\\$",
560
- next : "qqstring",
561
- merge : true
392
+ next : "qqstring"
562
393
  }, {
563
394
  token : "string",
564
395
  regex : '"|$',
565
- next : "start",
566
- merge : true
396
+ next : "no_regex"
397
+ }, {
398
+ defaultToken: "string"
567
399
  }
568
400
  ],
569
401
  "qstring" : [
570
402
  {
571
403
  token : "constant.language.escape",
572
404
  regex : escapedRe
573
- }, {
574
- token : "string",
575
- regex : "[^'\\\\]+",
576
- merge : true
577
405
  }, {
578
406
  token : "string",
579
407
  regex : "\\\\$",
580
- next : "qstring",
581
- merge : true
408
+ next : "qstring"
582
409
  }, {
583
410
  token : "string",
584
411
  regex : "'|$",
585
- next : "start",
586
- merge : true
412
+ next : "no_regex"
413
+ }, {
414
+ defaultToken: "string"
587
415
  }
588
416
  ]
589
417
  };
590
418
 
591
419
  this.embedRules(DocCommentHighlightRules, "doc-",
592
- [ DocCommentHighlightRules.getEndRule("start") ]);
420
+ [ DocCommentHighlightRules.getEndRule("no_regex") ]);
593
421
  };
594
422
 
595
423
  oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
@@ -610,21 +438,10 @@ var DocCommentHighlightRules = function() {
610
438
  token : "comment.doc.tag",
611
439
  regex : "@[\\w\\d_]+" // TODO: fix email addresses
612
440
  }, {
613
- token : "comment.doc",
614
- merge : true,
615
- regex : "\\s+"
616
- }, {
617
- token : "comment.doc",
618
- merge : true,
619
- regex : "TODO"
620
- }, {
621
- token : "comment.doc",
622
- merge : true,
623
- regex : "[^@\\*]+"
441
+ token : "comment.doc.tag",
442
+ regex : "\\bTODO\\b"
624
443
  }, {
625
- token : "comment.doc",
626
- merge : true,
627
- regex : "."
444
+ defaultToken : "comment.doc"
628
445
  }]
629
446
  };
630
447
  };
@@ -634,7 +451,6 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
634
451
  DocCommentHighlightRules.getStartRule = function(start) {
635
452
  return {
636
453
  token : "comment.doc", // doc comment
637
- merge : true,
638
454
  regex : "\\/\\*(?=\\*)",
639
455
  next : start
640
456
  };
@@ -643,7 +459,6 @@ DocCommentHighlightRules.getStartRule = function(start) {
643
459
  DocCommentHighlightRules.getEndRule = function (start) {
644
460
  return {
645
461
  token : "comment.doc", // closing comment
646
- merge : true,
647
462
  regex : "\\*\\/",
648
463
  next : start
649
464
  };
@@ -686,12 +501,7 @@ var MatchingBraceOutdent = function() {};
686
501
  };
687
502
 
688
503
  this.$getIndent = function(line) {
689
- var match = line.match(/^(\s+)/);
690
- if (match) {
691
- return match[1];
692
- }
693
-
694
- return "";
504
+ return line.match(/^\s*/)[0];
695
505
  };
696
506
 
697
507
  }).call(MatchingBraceOutdent.prototype);
@@ -699,59 +509,155 @@ var MatchingBraceOutdent = function() {};
699
509
  exports.MatchingBraceOutdent = MatchingBraceOutdent;
700
510
  });
701
511
 
702
- define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
512
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
703
513
 
704
514
 
705
515
  var oop = require("../../lib/oop");
706
516
  var Behaviour = require("../behaviour").Behaviour;
517
+ var TokenIterator = require("../../token_iterator").TokenIterator;
518
+ var lang = require("../../lib/lang");
519
+
520
+ var SAFE_INSERT_IN_TOKENS =
521
+ ["text", "paren.rparen", "punctuation.operator"];
522
+ var SAFE_INSERT_BEFORE_TOKENS =
523
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
524
+
525
+
526
+ var autoInsertedBrackets = 0;
527
+ var autoInsertedRow = -1;
528
+ var autoInsertedLineEnd = "";
529
+ var maybeInsertedBrackets = 0;
530
+ var maybeInsertedRow = -1;
531
+ var maybeInsertedLineStart = "";
532
+ var maybeInsertedLineEnd = "";
707
533
 
708
534
  var CstyleBehaviour = function () {
535
+
536
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
537
+ var cursor = editor.getCursorPosition();
538
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
539
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
540
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
541
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
542
+ return false;
543
+ }
544
+ iterator.stepForward();
545
+ return iterator.getCurrentTokenRow() !== cursor.row ||
546
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
547
+ };
548
+
549
+ CstyleBehaviour.$matchTokenType = function(token, types) {
550
+ return types.indexOf(token.type || token) > -1;
551
+ };
552
+
553
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
554
+ var cursor = editor.getCursorPosition();
555
+ var line = session.doc.getLine(cursor.row);
556
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
557
+ autoInsertedBrackets = 0;
558
+ autoInsertedRow = cursor.row;
559
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
560
+ autoInsertedBrackets++;
561
+ };
562
+
563
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
564
+ var cursor = editor.getCursorPosition();
565
+ var line = session.doc.getLine(cursor.row);
566
+ if (!this.isMaybeInsertedClosing(cursor, line))
567
+ maybeInsertedBrackets = 0;
568
+ maybeInsertedRow = cursor.row;
569
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
570
+ maybeInsertedLineEnd = line.substr(cursor.column);
571
+ maybeInsertedBrackets++;
572
+ };
573
+
574
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
575
+ return autoInsertedBrackets > 0 &&
576
+ cursor.row === autoInsertedRow &&
577
+ bracket === autoInsertedLineEnd[0] &&
578
+ line.substr(cursor.column) === autoInsertedLineEnd;
579
+ };
580
+
581
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
582
+ return maybeInsertedBrackets > 0 &&
583
+ cursor.row === maybeInsertedRow &&
584
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
585
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
586
+ };
587
+
588
+ CstyleBehaviour.popAutoInsertedClosing = function() {
589
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
590
+ autoInsertedBrackets--;
591
+ };
592
+
593
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
594
+ maybeInsertedBrackets = 0;
595
+ maybeInsertedRow = -1;
596
+ };
709
597
 
710
598
  this.add("braces", "insertion", function (state, action, editor, session, text) {
599
+ var cursor = editor.getCursorPosition();
600
+ var line = session.doc.getLine(cursor.row);
711
601
  if (text == '{') {
712
602
  var selection = editor.getSelectionRange();
713
603
  var selected = session.doc.getTextRange(selection);
714
- if (selected !== "") {
604
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
715
605
  return {
716
606
  text: '{' + selected + '}',
717
607
  selection: false
718
608
  };
719
- } else {
720
- return {
721
- text: '{}',
722
- selection: [1, 1]
723
- };
609
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
610
+ if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
611
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
612
+ return {
613
+ text: '{}',
614
+ selection: [1, 1]
615
+ };
616
+ } else {
617
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
618
+ return {
619
+ text: '{',
620
+ selection: [1, 1]
621
+ };
622
+ }
724
623
  }
725
624
  } else if (text == '}') {
726
- var cursor = editor.getCursorPosition();
727
- var line = session.doc.getLine(cursor.row);
728
625
  var rightChar = line.substring(cursor.column, cursor.column + 1);
729
626
  if (rightChar == '}') {
730
627
  var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
731
- if (matching !== null) {
628
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
629
+ CstyleBehaviour.popAutoInsertedClosing();
732
630
  return {
733
631
  text: '',
734
632
  selection: [1, 1]
735
633
  };
736
634
  }
737
635
  }
738
- } else if (text == "\n") {
739
- var cursor = editor.getCursorPosition();
740
- var line = session.doc.getLine(cursor.row);
636
+ } else if (text == "\n" || text == "\r\n") {
637
+ var closing = "";
638
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
639
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
640
+ CstyleBehaviour.clearMaybeInsertedClosing();
641
+ }
741
642
  var rightChar = line.substring(cursor.column, cursor.column + 1);
742
- if (rightChar == '}') {
743
- var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
643
+ if (rightChar === '}') {
644
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
744
645
  if (!openBracePos)
745
646
  return null;
746
-
747
- var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
748
- var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
749
-
750
- return {
751
- text: '\n' + indent + '\n' + next_indent,
752
- selection: [1, indent.length, 1, indent.length]
753
- };
647
+ var next_indent = this.$getIndent(session.getLine(openBracePos.row));
648
+ } else if (closing) {
649
+ var next_indent = this.$getIndent(line);
650
+ } else {
651
+ return;
754
652
  }
653
+ var indent = next_indent + session.getTabString();
654
+
655
+ return {
656
+ text: '\n' + indent + '\n' + next_indent + closing,
657
+ selection: [1, indent.length, 1, indent.length]
658
+ };
659
+ } else {
660
+ CstyleBehaviour.clearMaybeInsertedClosing();
755
661
  }
756
662
  });
757
663
 
@@ -763,6 +669,8 @@ var CstyleBehaviour = function () {
763
669
  if (rightChar == '}') {
764
670
  range.end.column++;
765
671
  return range;
672
+ } else {
673
+ maybeInsertedBrackets--;
766
674
  }
767
675
  }
768
676
  });
@@ -771,12 +679,13 @@ var CstyleBehaviour = function () {
771
679
  if (text == '(') {
772
680
  var selection = editor.getSelectionRange();
773
681
  var selected = session.doc.getTextRange(selection);
774
- if (selected !== "") {
682
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
775
683
  return {
776
684
  text: '(' + selected + ')',
777
685
  selection: false
778
686
  };
779
- } else {
687
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
688
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
780
689
  return {
781
690
  text: '()',
782
691
  selection: [1, 1]
@@ -788,7 +697,8 @@ var CstyleBehaviour = function () {
788
697
  var rightChar = line.substring(cursor.column, cursor.column + 1);
789
698
  if (rightChar == ')') {
790
699
  var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
791
- if (matching !== null) {
700
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
701
+ CstyleBehaviour.popAutoInsertedClosing();
792
702
  return {
793
703
  text: '',
794
704
  selection: [1, 1]
@@ -814,12 +724,13 @@ var CstyleBehaviour = function () {
814
724
  if (text == '[') {
815
725
  var selection = editor.getSelectionRange();
816
726
  var selected = session.doc.getTextRange(selection);
817
- if (selected !== "") {
727
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
818
728
  return {
819
729
  text: '[' + selected + ']',
820
730
  selection: false
821
731
  };
822
- } else {
732
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
733
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
823
734
  return {
824
735
  text: '[]',
825
736
  selection: [1, 1]
@@ -831,7 +742,8 @@ var CstyleBehaviour = function () {
831
742
  var rightChar = line.substring(cursor.column, cursor.column + 1);
832
743
  if (rightChar == ']') {
833
744
  var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
834
- if (matching !== null) {
745
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
746
+ CstyleBehaviour.popAutoInsertedClosing();
835
747
  return {
836
748
  text: '',
837
749
  selection: [1, 1]
@@ -858,7 +770,7 @@ var CstyleBehaviour = function () {
858
770
  var quote = text;
859
771
  var selection = editor.getSelectionRange();
860
772
  var selected = session.doc.getTextRange(selection);
861
- if (selected !== "") {
773
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
862
774
  return {
863
775
  text: quote + selected + quote,
864
776
  selection: false
@@ -867,13 +779,9 @@ var CstyleBehaviour = function () {
867
779
  var cursor = editor.getCursorPosition();
868
780
  var line = session.doc.getLine(cursor.row);
869
781
  var leftChar = line.substring(cursor.column-1, cursor.column);
870
-
871
- // We're escaped.
872
782
  if (leftChar == '\\') {
873
783
  return null;
874
784
  }
875
-
876
- // Find what token we're inside.
877
785
  var tokens = session.getTokens(selection.start.row);
878
786
  var col = 0, token;
879
787
  var quotepos = -1; // Track whether we're inside an open quote.
@@ -890,15 +798,14 @@ var CstyleBehaviour = function () {
890
798
  }
891
799
  col += tokens[x].value.length;
892
800
  }
893
-
894
- // Try and be smart about when we auto insert.
895
801
  if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
802
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
803
+ return;
896
804
  return {
897
805
  text: quote + quote,
898
806
  selection: [1,1]
899
807
  };
900
808
  } else if (token && token.type === "string") {
901
- // Ignore input and move right one if we're typing over the closing quote.
902
809
  var rightChar = line.substring(cursor.column, cursor.column + 1);
903
810
  if (rightChar == quote) {
904
811
  return {
@@ -916,7 +823,7 @@ var CstyleBehaviour = function () {
916
823
  if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
917
824
  var line = session.doc.getLine(range.start.row);
918
825
  var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
919
- if (rightChar == '"') {
826
+ if (rightChar == selected) {
920
827
  range.end.column++;
921
828
  return range;
922
829
  }
@@ -937,15 +844,24 @@ var oop = require("../../lib/oop");
937
844
  var Range = require("../../range").Range;
938
845
  var BaseFoldMode = require("./fold_mode").FoldMode;
939
846
 
940
- var FoldMode = exports.FoldMode = function() {};
847
+ var FoldMode = exports.FoldMode = function(commentRegex) {
848
+ if (commentRegex) {
849
+ this.foldingStartMarker = new RegExp(
850
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
851
+ );
852
+ this.foldingStopMarker = new RegExp(
853
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
854
+ );
855
+ }
856
+ };
941
857
  oop.inherits(FoldMode, BaseFoldMode);
942
858
 
943
859
  (function() {
944
860
 
945
861
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
946
862
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
947
-
948
- this.getFoldWidgetRange = function(session, foldStyle, row) {
863
+
864
+ this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
949
865
  var line = session.getLine(row);
950
866
  var match = line.match(this.foldingStartMarker);
951
867
  if (match) {
@@ -953,115 +869,63 @@ oop.inherits(FoldMode, BaseFoldMode);
953
869
 
954
870
  if (match[1])
955
871
  return this.openingBracketBlock(session, match[1], row, i);
956
-
957
- var range = session.getCommentFoldRange(row, i + match[0].length);
958
- range.end.column -= 2;
872
+
873
+ var range = session.getCommentFoldRange(row, i + match[0].length, 1);
874
+
875
+ if (range && !range.isMultiLine()) {
876
+ if (forceMultiline) {
877
+ range = this.getSectionRange(session, row);
878
+ } else if (foldStyle != "all")
879
+ range = null;
880
+ }
881
+
959
882
  return range;
960
883
  }
961
884
 
962
- if (foldStyle !== "markbeginend")
885
+ if (foldStyle === "markbegin")
963
886
  return;
964
-
887
+
965
888
  var match = line.match(this.foldingStopMarker);
966
889
  if (match) {
967
890
  var i = match.index + match[0].length;
968
891
 
969
- if (match[2]) {
970
- var range = session.getCommentFoldRange(row, i);
971
- range.end.column -= 2;
972
- return range;
973
- }
974
-
975
- var end = {row: row, column: i};
976
- var start = session.$findOpeningBracket(match[1], end);
977
-
978
- if (!start)
979
- return;
980
-
981
- start.column++;
982
- end.column--;
892
+ if (match[1])
893
+ return this.closingBracketBlock(session, match[1], row, i);
983
894
 
984
- return Range.fromPoints(start, end);
895
+ return session.getCommentFoldRange(row, i, -1);
985
896
  }
986
897
  };
987
898
 
988
- }).call(FoldMode.prototype);
989
-
990
- });
991
-
992
- define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
993
-
994
-
995
- var Range = require("../../range").Range;
996
-
997
- var FoldMode = exports.FoldMode = function() {};
998
-
999
- (function() {
1000
-
1001
- this.foldingStartMarker = null;
1002
- this.foldingStopMarker = null;
1003
-
1004
- // must return "" if there's no fold, to enable caching
1005
- this.getFoldWidget = function(session, foldStyle, row) {
899
+ this.getSectionRange = function(session, row) {
1006
900
  var line = session.getLine(row);
1007
- if (this.foldingStartMarker.test(line))
1008
- return "start";
1009
- if (foldStyle == "markbeginend"
1010
- && this.foldingStopMarker
1011
- && this.foldingStopMarker.test(line))
1012
- return "end";
1013
- return "";
1014
- };
1015
-
1016
- this.getFoldWidgetRange = function(session, foldStyle, row) {
1017
- return null;
1018
- };
1019
-
1020
- this.indentationBlock = function(session, row, column) {
1021
- var re = /\S/;
1022
- var line = session.getLine(row);
1023
- var startLevel = line.search(re);
1024
- if (startLevel == -1)
1025
- return;
1026
-
1027
- var startColumn = column || line.length;
1028
- var maxRow = session.getLength();
901
+ var startIndent = line.search(/\S/);
1029
902
  var startRow = row;
903
+ var startColumn = line.length;
904
+ row = row + 1;
1030
905
  var endRow = row;
1031
-
906
+ var maxRow = session.getLength();
1032
907
  while (++row < maxRow) {
1033
- var level = session.getLine(row).search(re);
1034
-
1035
- if (level == -1)
908
+ line = session.getLine(row);
909
+ var indent = line.search(/\S/);
910
+ if (indent === -1)
1036
911
  continue;
1037
-
1038
- if (level <= startLevel)
912
+ if (startIndent > indent)
1039
913
  break;
1040
-
914
+ var subRange = this.getFoldWidgetRange(session, "all", row);
915
+
916
+ if (subRange) {
917
+ if (subRange.start.row <= startRow) {
918
+ break;
919
+ } else if (subRange.isMultiLine()) {
920
+ row = subRange.end.row;
921
+ } else if (startIndent == indent) {
922
+ break;
923
+ }
924
+ }
1041
925
  endRow = row;
1042
926
  }
1043
-
1044
- if (endRow > startRow) {
1045
- var endColumn = session.getLine(endRow).length;
1046
- return new Range(startRow, startColumn, endRow, endColumn);
1047
- }
1048
- };
1049
-
1050
- this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
1051
- var start = {row: row, column: column + 1};
1052
- var end = session.$findClosingBracket(bracket, start, typeRe);
1053
- if (!end)
1054
- return;
1055
-
1056
- var fw = session.foldWidgets[end.row];
1057
- if (fw == null)
1058
- fw = this.getFoldWidget(session, end.row);
1059
-
1060
- if (fw == "start" && end.row > start.row) {
1061
- end.row --;
1062
- end.column = session.getLine(end.row).length;
1063
- }
1064
- return Range.fromPoints(start, end);
927
+
928
+ return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
1065
929
  };
1066
930
 
1067
931
  }).call(FoldMode.prototype);