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,41 +1,34 @@
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/
8
- *
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.
13
- *
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.
4
+ * Copyright (c) 2010, Ajax.org B.V.
5
+ * All rights reserved.
6
+ *
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.
17
+ *
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
 
38
- define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/html', 'ace/mode/folding/html'], function(require, exports, module) {
31
+ define('ace/mode/html', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/mode/javascript', 'ace/mode/css', 'ace/tokenizer', 'ace/mode/html_highlight_rules', 'ace/mode/behaviour/html', 'ace/mode/folding/html', 'ace/mode/html_completions'], function(require, exports, module) {
39
32
 
40
33
 
41
34
  var oop = require("../lib/oop");
@@ -46,13 +39,13 @@ var Tokenizer = require("../tokenizer").Tokenizer;
46
39
  var HtmlHighlightRules = require("./html_highlight_rules").HtmlHighlightRules;
47
40
  var HtmlBehaviour = require("./behaviour/html").HtmlBehaviour;
48
41
  var HtmlFoldMode = require("./folding/html").FoldMode;
42
+ var HtmlCompletions = require("./html_completions").HtmlCompletions;
49
43
 
50
44
  var Mode = function() {
51
- var highlighter = new HtmlHighlightRules();
52
- this.$tokenizer = new Tokenizer(highlighter.getRules());
45
+ this.HighlightRules = HtmlHighlightRules;
53
46
  this.$behaviour = new HtmlBehaviour();
47
+ this.$completer = new HtmlCompletions();
54
48
 
55
- this.$embeds = highlighter.getEmbeds();
56
49
  this.createModeDelegates({
57
50
  "js-": JavaScriptMode,
58
51
  "css-": CssMode
@@ -64,10 +57,7 @@ oop.inherits(Mode, TextMode);
64
57
 
65
58
  (function() {
66
59
 
67
-
68
- this.toggleCommentLines = function(state, doc, startRow, endRow) {
69
- return 0;
70
- };
60
+ this.blockComment = {start: "<!--", end: "-->"};
71
61
 
72
62
  this.getNextLineIndent = function(state, line, tab) {
73
63
  return this.$getIndent(line);
@@ -77,6 +67,11 @@ oop.inherits(Mode, TextMode);
77
67
  return false;
78
68
  };
79
69
 
70
+ this.getCompletions = function(state, session, pos, prefix) {
71
+ return this.$completer.getCompletions(state, session, pos, prefix);
72
+ };
73
+
74
+ this.$id = "ace/mode/html";
80
75
  }).call(Mode.prototype);
81
76
 
82
77
  exports.Mode = Mode;
@@ -96,7 +91,8 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
96
91
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
97
92
 
98
93
  var Mode = function() {
99
- this.$tokenizer = new Tokenizer(new JavaScriptHighlightRules().getRules());
94
+ this.HighlightRules = JavaScriptHighlightRules;
95
+
100
96
  this.$outdent = new MatchingBraceOutdent();
101
97
  this.$behaviour = new CstyleBehaviour();
102
98
  this.foldingRules = new CStyleFoldMode();
@@ -105,53 +101,27 @@ oop.inherits(Mode, TextMode);
105
101
 
106
102
  (function() {
107
103
 
108
-
109
- this.toggleCommentLines = function(state, doc, startRow, endRow) {
110
- var outdent = true;
111
- var re = /^(\s*)\/\//;
112
-
113
- for (var i=startRow; i<= endRow; i++) {
114
- if (!re.test(doc.getLine(i))) {
115
- outdent = false;
116
- break;
117
- }
118
- }
119
-
120
- if (outdent) {
121
- var deleteRange = new Range(0, 0, 0, 0);
122
- for (var i=startRow; i<= endRow; i++)
123
- {
124
- var line = doc.getLine(i);
125
- var m = line.match(re);
126
- deleteRange.start.row = i;
127
- deleteRange.end.row = i;
128
- deleteRange.end.column = m[0].length;
129
- doc.replace(deleteRange, m[1]);
130
- }
131
- }
132
- else {
133
- doc.indentRows(startRow, endRow, "//");
134
- }
135
- };
104
+ this.lineCommentStart = "//";
105
+ this.blockComment = {start: "/*", end: "*/"};
136
106
 
137
107
  this.getNextLineIndent = function(state, line, tab) {
138
108
  var indent = this.$getIndent(line);
139
109
 
140
- var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
110
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
141
111
  var tokens = tokenizedLine.tokens;
142
112
  var endState = tokenizedLine.state;
143
113
 
144
114
  if (tokens.length && tokens[tokens.length-1].type == "comment") {
145
115
  return indent;
146
116
  }
147
-
148
- if (state == "start" || state == "regex_allowed") {
117
+
118
+ if (state == "start" || state == "no_regex") {
149
119
  var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
150
120
  if (match) {
151
121
  indent += tab;
152
122
  }
153
123
  } else if (state == "doc-start") {
154
- if (endState == "start" || state == "regex_allowed") {
124
+ if (endState == "start" || endState == "no_regex") {
155
125
  return "";
156
126
  }
157
127
  var match = line.match(/^\s*(\/?)\*/);
@@ -173,105 +143,64 @@ oop.inherits(Mode, TextMode);
173
143
  this.autoOutdent = function(state, doc, row) {
174
144
  this.$outdent.autoOutdent(doc, row);
175
145
  };
176
-
146
+
177
147
  this.createWorker = function(session) {
178
148
  var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
179
149
  worker.attachToDocument(session.getDocument());
180
-
150
+
181
151
  worker.on("jslint", function(results) {
182
- var errors = [];
183
- for (var i=0; i<results.data.length; i++) {
184
- var error = results.data[i];
185
- if (error)
186
- errors.push({
187
- row: error.line-1,
188
- column: error.character-1,
189
- text: error.reason,
190
- type: "warning",
191
- lint: error
192
- });
193
- }
194
- session.setAnnotations(errors);
195
- });
196
-
197
- worker.on("narcissus", function(e) {
198
- session.setAnnotations([e.data]);
152
+ session.setAnnotations(results.data);
199
153
  });
200
-
154
+
201
155
  worker.on("terminate", function() {
202
156
  session.clearAnnotations();
203
157
  });
204
-
158
+
205
159
  return worker;
206
160
  };
207
161
 
162
+ this.$id = "ace/mode/javascript";
208
163
  }).call(Mode.prototype);
209
164
 
210
165
  exports.Mode = Mode;
211
166
  });
212
167
 
213
- 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) {
168
+ 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) {
214
169
 
215
170
 
216
171
  var oop = require("../lib/oop");
217
- var lang = require("../lib/lang");
218
- var unicode = require("../unicode");
219
172
  var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
220
173
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
221
174
 
222
175
  var JavaScriptHighlightRules = function() {
223
-
224
- // see: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects
225
- var globals = lang.arrayToMap(
226
- // Constructors
227
- ("Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" +
228
- // E4X
229
- "Namespace|QName|XML|XMLList|" +
230
- "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
231
- "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
232
- // Errors
233
- "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" +
234
- "SyntaxError|TypeError|URIError|" +
235
- // Non-constructor functions
236
- "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" +
237
- "isNaN|parseFloat|parseInt|" +
238
- // Other
239
- "JSON|Math|" +
240
- // Pseudo
241
- "this|arguments|prototype|window|document"
242
- ).split("|")
243
- );
244
-
245
- var keywords = lang.arrayToMap(
246
- ("break|case|catch|continue|default|delete|do|else|finally|for|function|" +
247
- "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
248
- "const|yield|import|get|set").split("|")
249
- );
250
-
251
- // keywords which can be followed by regular expressions
252
- var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
253
-
254
- var deprecated = lang.arrayToMap(
255
- ("__parent__|__count__|escape|unescape|with|__proto__").split("|")
256
- );
257
-
258
- var definitions = lang.arrayToMap(("const|let|var|function").split("|"));
259
-
260
- var buildinConstants = lang.arrayToMap(
261
- ("null|Infinity|NaN|undefined").split("|")
262
- );
263
-
264
- var futureReserved = lang.arrayToMap(
265
- ("class|enum|extends|super|export|implements|private|" +
266
- "public|interface|package|protected|static").split("|")
267
- );
268
-
269
- // TODO: Unicode escape sequences
270
- var identifierRe = "[" + unicode.packages.L + "\\$_]["
271
- + unicode.packages.L
272
- + unicode.packages.Mn + unicode.packages.Mc
273
- + unicode.packages.Nd
274
- + unicode.packages.Pc + "\\$_]*\\b";
176
+ var keywordMapper = this.createKeywordMapper({
177
+ "variable.language":
178
+ "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
179
+ "Namespace|QName|XML|XMLList|" + // E4X
180
+ "ArrayBuffer|Float32Array|Float64Array|Int16Array|Int32Array|Int8Array|" +
181
+ "Uint16Array|Uint32Array|Uint8Array|Uint8ClampedArray|" +
182
+ "Error|EvalError|InternalError|RangeError|ReferenceError|StopIteration|" + // Errors
183
+ "SyntaxError|TypeError|URIError|" +
184
+ "decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|eval|isFinite|" + // Non-constructor functions
185
+ "isNaN|parseFloat|parseInt|" +
186
+ "JSON|Math|" + // Other
187
+ "this|arguments|prototype|window|document" , // Pseudo
188
+ "keyword":
189
+ "const|yield|import|get|set|" +
190
+ "break|case|catch|continue|default|delete|do|else|finally|for|function|" +
191
+ "if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|debugger|" +
192
+ "__parent__|__count__|escape|unescape|with|__proto__|" +
193
+ "class|enum|extends|super|export|implements|private|public|interface|package|protected|static",
194
+ "storage.type":
195
+ "const|let|var|function",
196
+ "constant.language":
197
+ "null|Infinity|NaN|undefined",
198
+ "support.function":
199
+ "alert",
200
+ "constant.language.boolean": "true|false"
201
+ }, "identifier");
202
+ var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield|void";
203
+ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*\\b";
275
204
 
276
205
  var escapedRe = "\\\\(?:x[0-9a-fA-F]{2}|" + // hex
277
206
  "u[0-9a-fA-F]{4}|" + // unicode
@@ -281,19 +210,16 @@ var JavaScriptHighlightRules = function() {
281
210
  "[4-7][0-7]?|" + //oct
282
211
  ".)";
283
212
 
284
- // regexp must not have capturing parentheses. Use (?:) instead.
285
- // regexps are ordered -> the first match is used
286
-
287
213
  this.$rules = {
288
- "start" : [
214
+ "no_regex" : [
289
215
  {
290
216
  token : "comment",
291
- regex : /\/\/.*$/
217
+ regex : "\\/\\/",
218
+ next : "line_comment"
292
219
  },
293
220
  DocCommentHighlightRules.getStartRule("doc-start"),
294
221
  {
295
222
  token : "comment", // multi line comment
296
- merge : true,
297
223
  regex : /\/\*/,
298
224
  next : "comment"
299
225
  }, {
@@ -310,119 +236,61 @@ var JavaScriptHighlightRules = function() {
310
236
  }, {
311
237
  token : "constant.numeric", // float
312
238
  regex : /[+-]?\d+(?:(?:\.\d*)?(?:[eE][+-]?\d+)?)?\b/
313
- }, { // match stuff like: Sound.prototype.play = function() { }
314
- token : [
315
- "storage.type",
316
- "punctuation.operator",
317
- "support.function",
318
- "punctuation.operator",
319
- "entity.name.function",
320
- "text",
321
- "keyword.operator",
322
- "text",
323
- "storage.type",
324
- "text",
325
- "paren.lparen"
326
- ],
327
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
328
- next: "function_arguments"
329
- }, { // match stuff like: Sound.prototype.play = myfunc
239
+ }, {
330
240
  token : [
331
- "storage.type",
332
- "punctuation.operator",
333
- "support.function",
334
- "punctuation.operator",
335
- "entity.name.function",
336
- "text",
337
- "keyword.operator",
338
- "text"
241
+ "storage.type", "punctuation.operator", "support.function",
242
+ "punctuation.operator", "entity.name.function", "text","keyword.operator"
339
243
  ],
340
- regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)",
244
+ regex : "(" + identifierRe + ")(\\.)(prototype)(\\.)(" + identifierRe +")(\\s*)(=)",
341
245
  next: "function_arguments"
342
- }, { // match stuff like: Sound.play = function() { }
246
+ }, {
343
247
  token : [
344
- "storage.type",
345
- "punctuation.operator",
346
- "entity.name.function",
347
- "text",
348
- "keyword.operator",
349
- "text",
350
- "storage.type",
351
- "text",
352
- "paren.lparen"
248
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
249
+ "keyword.operator", "text", "storage.type", "text", "paren.lparen"
353
250
  ],
354
251
  regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
355
252
  next: "function_arguments"
356
- }, { // match stuff like: play = function() { }
253
+ }, {
357
254
  token : [
358
- "entity.name.function",
359
- "text",
360
- "keyword.operator",
361
- "text",
362
- "storage.type",
363
- "text",
364
- "paren.lparen"
255
+ "entity.name.function", "text", "keyword.operator", "text", "storage.type",
256
+ "text", "paren.lparen"
365
257
  ],
366
258
  regex : "(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s*)(\\()",
367
259
  next: "function_arguments"
368
- }, { // match stuff like: Sound.play = function play() { }
260
+ }, {
369
261
  token : [
370
- "storage.type",
371
- "punctuation.operator",
372
- "entity.name.function",
373
- "text",
374
- "keyword.operator",
375
- "text",
376
- "storage.type",
377
- "text",
378
- "entity.name.function",
379
- "text",
380
- "paren.lparen"
262
+ "storage.type", "punctuation.operator", "entity.name.function", "text",
263
+ "keyword.operator", "text",
264
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
381
265
  ],
382
266
  regex : "(" + identifierRe + ")(\\.)(" + identifierRe +")(\\s*)(=)(\\s*)(function)(\\s+)(\\w+)(\\s*)(\\()",
383
267
  next: "function_arguments"
384
- }, { // match regular function like: function myFunc(arg) { }
268
+ }, {
385
269
  token : [
386
- "storage.type",
387
- "text",
388
- "entity.name.function",
389
- "text",
390
- "paren.lparen"
270
+ "storage.type", "text", "entity.name.function", "text", "paren.lparen"
391
271
  ],
392
272
  regex : "(function)(\\s+)(" + identifierRe + ")(\\s*)(\\()",
393
273
  next: "function_arguments"
394
- }, { // match stuff like: foobar: function() { }
274
+ }, {
395
275
  token : [
396
- "entity.name.function",
397
- "text",
398
- "punctuation.operator",
399
- "text",
400
- "storage.type",
401
- "text",
402
- "paren.lparen"
276
+ "entity.name.function", "text", "punctuation.operator",
277
+ "text", "storage.type", "text", "paren.lparen"
403
278
  ],
404
279
  regex : "(" + identifierRe + ")(\\s*)(:)(\\s*)(function)(\\s*)(\\()",
405
280
  next: "function_arguments"
406
- }, { // Attempt to match : function() { } (this is for issues with 'foo': function() { })
281
+ }, {
407
282
  token : [
408
- "text",
409
- "text",
410
- "storage.type",
411
- "text",
412
- "paren.lparen"
283
+ "text", "text", "storage.type", "text", "paren.lparen"
413
284
  ],
414
285
  regex : "(:)(\\s*)(function)(\\s*)(\\()",
415
286
  next: "function_arguments"
416
- }, {
417
- token : "constant.language.boolean",
418
- regex : /(?:true|false)\b/
419
287
  }, {
420
288
  token : "keyword",
421
289
  regex : "(?:" + kwBeforeRe + ")\\b",
422
- next : "regex_allowed"
290
+ next : "start"
423
291
  }, {
424
292
  token : ["punctuation.operator", "support.function"],
425
- 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(?=\()/
293
+ 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(?=\()/
426
294
  }, {
427
295
  token : ["punctuation.operator", "support.function.dom"],
428
296
  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(?=\()/
@@ -433,78 +301,54 @@ var JavaScriptHighlightRules = function() {
433
301
  token : ["storage.type", "punctuation.operator", "support.function.firebug"],
434
302
  regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
435
303
  }, {
436
- token : function(value) {
437
- if (globals.hasOwnProperty(value))
438
- return "variable.language";
439
- else if (deprecated.hasOwnProperty(value))
440
- return "invalid.deprecated";
441
- else if (definitions.hasOwnProperty(value))
442
- return "storage.type";
443
- else if (keywords.hasOwnProperty(value))
444
- return "keyword";
445
- else if (buildinConstants.hasOwnProperty(value))
446
- return "constant.language";
447
- else if (futureReserved.hasOwnProperty(value))
448
- return "invalid.illegal";
449
- else if (value == "debugger")
450
- return "invalid.deprecated";
451
- else
452
- return "identifier";
453
- },
304
+ token : keywordMapper,
454
305
  regex : identifierRe
455
306
  }, {
456
307
  token : "keyword.operator",
457
- regex : /!|\$|%|&|\*|\-\-|\-|\+\+|\+|~|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=|\b(?:in|instanceof|new|delete|typeof|void)/,
458
- next : "regex_allowed"
308
+ regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
309
+ next : "start"
459
310
  }, {
460
311
  token : "punctuation.operator",
461
312
  regex : /\?|\:|\,|\;|\./,
462
- next : "regex_allowed"
313
+ next : "start"
463
314
  }, {
464
315
  token : "paren.lparen",
465
316
  regex : /[\[({]/,
466
- next : "regex_allowed"
317
+ next : "start"
467
318
  }, {
468
319
  token : "paren.rparen",
469
320
  regex : /[\])}]/
470
321
  }, {
471
322
  token : "keyword.operator",
472
323
  regex : /\/=?/,
473
- next : "regex_allowed"
324
+ next : "start"
474
325
  }, {
475
326
  token: "comment",
476
327
  regex: /^#!.*$/
477
- }, {
478
- token : "text",
479
- regex : /\s+/
480
328
  }
481
329
  ],
482
- // regular expressions are only allowed after certain tokens. This
483
- // makes sure we don't mix up regexps with the divison operator
484
- "regex_allowed": [
330
+ "start": [
485
331
  DocCommentHighlightRules.getStartRule("doc-start"),
486
332
  {
487
333
  token : "comment", // multi line comment
488
- merge : true,
489
334
  regex : "\\/\\*",
490
335
  next : "comment_regex_allowed"
491
336
  }, {
492
337
  token : "comment",
493
- regex : "\\/\\/.*$"
338
+ regex : "\\/\\/",
339
+ next : "line_comment_regex_allowed"
494
340
  }, {
495
341
  token: "string.regexp",
496
342
  regex: "\\/",
497
- next: "regex",
498
- merge: true
343
+ next: "regex"
499
344
  }, {
500
345
  token : "text",
501
- regex : "\\s+"
346
+ regex : "\\s+|^$",
347
+ next : "start"
502
348
  }, {
503
- // immediately return to the start mode without matching
504
- // anything
505
349
  token: "empty",
506
350
  regex: "",
507
- next: "start"
351
+ next: "no_regex"
508
352
  }
509
353
  ],
510
354
  "regex": [
@@ -512,24 +356,28 @@ var JavaScriptHighlightRules = function() {
512
356
  token: "regexp.keyword.operator",
513
357
  regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
514
358
  }, {
515
- // flag
516
359
  token: "string.regexp",
517
- regex: "/\\w*",
518
- next: "start",
519
- merge: true
360
+ regex: "/[sxngimy]*",
361
+ next: "no_regex"
520
362
  }, {
521
- token: "string.regexp",
522
- regex: "[^\\\\/\\[]+",
523
- merge: true
363
+ token : "invalid",
364
+ regex: /\{\d+\b,?\d*\}[+*]|[+*$^?][+*]|[$^][?]|\?{3,}/
365
+ }, {
366
+ token : "constant.language.escape",
367
+ regex: /\(\?[:=!]|\)|\{\d+\b,?\d*\}|[+*]\?|[()$^+*?.]/
368
+ }, {
369
+ token : "constant.language.delimiter",
370
+ regex: /\|/
524
371
  }, {
525
- token: "string.regexp.charachterclass",
526
- regex: "\\[",
527
- next: "regex_character_class",
528
- merge: true
372
+ token: "constant.language.escape",
373
+ regex: /\[\^?/,
374
+ next: "regex_character_class"
529
375
  }, {
530
376
  token: "empty",
531
- regex: "",
532
- next: "start"
377
+ regex: "$",
378
+ next: "no_regex"
379
+ }, {
380
+ defaultToken: "string.regexp"
533
381
  }
534
382
  ],
535
383
  "regex_character_class": [
@@ -537,18 +385,18 @@ var JavaScriptHighlightRules = function() {
537
385
  token: "regexp.keyword.operator",
538
386
  regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
539
387
  }, {
540
- token: "string.regexp.charachterclass",
388
+ token: "constant.language.escape",
541
389
  regex: "]",
542
- next: "regex",
543
- merge: true
390
+ next: "regex"
544
391
  }, {
545
- token: "string.regexp.charachterclass",
546
- regex: "[^\\\\\\]]+",
547
- merge: true
392
+ token: "constant.language.escape",
393
+ regex: "-"
548
394
  }, {
549
395
  token: "empty",
550
- regex: "",
551
- next: "start"
396
+ regex: "$",
397
+ next: "no_regex"
398
+ }, {
399
+ defaultToken: "string.regexp.charachterclass"
552
400
  }
553
401
  ],
554
402
  "function_arguments": [
@@ -557,86 +405,68 @@ var JavaScriptHighlightRules = function() {
557
405
  regex: identifierRe
558
406
  }, {
559
407
  token: "punctuation.operator",
560
- regex: "[, ]+",
561
- merge: true
408
+ regex: "[, ]+"
562
409
  }, {
563
410
  token: "punctuation.operator",
564
- regex: "$",
565
- merge: true
411
+ regex: "$"
566
412
  }, {
567
413
  token: "empty",
568
414
  regex: "",
569
- next: "start"
415
+ next: "no_regex"
570
416
  }
571
417
  ],
572
418
  "comment_regex_allowed" : [
573
- {
574
- token : "comment", // closing comment
575
- regex : ".*?\\*\\/",
576
- merge : true,
577
- next : "regex_allowed"
578
- }, {
579
- token : "comment", // comment spanning whole line
580
- merge : true,
581
- regex : ".+"
582
- }
419
+ {token : "comment", regex : "\\*\\/", next : "start"},
420
+ {defaultToken : "comment"}
583
421
  ],
584
422
  "comment" : [
585
- {
586
- token : "comment", // closing comment
587
- regex : ".*?\\*\\/",
588
- merge : true,
589
- next : "start"
590
- }, {
591
- token : "comment", // comment spanning whole line
592
- merge : true,
593
- regex : ".+"
594
- }
423
+ {token : "comment", regex : "\\*\\/", next : "no_regex"},
424
+ {defaultToken : "comment"}
425
+ ],
426
+ "line_comment_regex_allowed" : [
427
+ {token : "comment", regex : "$|^", next : "start"},
428
+ {defaultToken : "comment"}
429
+ ],
430
+ "line_comment" : [
431
+ {token : "comment", regex : "$|^", next : "no_regex"},
432
+ {defaultToken : "comment"}
595
433
  ],
596
434
  "qqstring" : [
597
435
  {
598
436
  token : "constant.language.escape",
599
437
  regex : escapedRe
600
- }, {
601
- token : "string",
602
- regex : '[^"\\\\]+',
603
- merge : true
604
438
  }, {
605
439
  token : "string",
606
440
  regex : "\\\\$",
607
- next : "qqstring",
608
- merge : true
441
+ next : "qqstring"
609
442
  }, {
610
443
  token : "string",
611
444
  regex : '"|$',
612
- next : "start",
613
- merge : true
445
+ next : "no_regex"
446
+ }, {
447
+ defaultToken: "string"
614
448
  }
615
449
  ],
616
450
  "qstring" : [
617
451
  {
618
452
  token : "constant.language.escape",
619
453
  regex : escapedRe
620
- }, {
621
- token : "string",
622
- regex : "[^'\\\\]+",
623
- merge : true
624
454
  }, {
625
455
  token : "string",
626
456
  regex : "\\\\$",
627
- next : "qstring",
628
- merge : true
457
+ next : "qstring"
629
458
  }, {
630
459
  token : "string",
631
460
  regex : "'|$",
632
- next : "start",
633
- merge : true
461
+ next : "no_regex"
462
+ }, {
463
+ defaultToken: "string"
634
464
  }
635
465
  ]
636
466
  };
637
467
 
638
468
  this.embedRules(DocCommentHighlightRules, "doc-",
639
- [ DocCommentHighlightRules.getEndRule("start") ]);
469
+ [ DocCommentHighlightRules.getEndRule("no_regex") ]);
640
470
  };
641
471
 
642
472
  oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
@@ -657,21 +487,10 @@ var DocCommentHighlightRules = function() {
657
487
  token : "comment.doc.tag",
658
488
  regex : "@[\\w\\d_]+" // TODO: fix email addresses
659
489
  }, {
660
- token : "comment.doc",
661
- merge : true,
662
- regex : "\\s+"
663
- }, {
664
- token : "comment.doc",
665
- merge : true,
666
- regex : "TODO"
667
- }, {
668
- token : "comment.doc",
669
- merge : true,
670
- regex : "[^@\\*]+"
490
+ token : "comment.doc.tag",
491
+ regex : "\\bTODO\\b"
671
492
  }, {
672
- token : "comment.doc",
673
- merge : true,
674
- regex : "."
493
+ defaultToken : "comment.doc"
675
494
  }]
676
495
  };
677
496
  };
@@ -681,7 +500,6 @@ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
681
500
  DocCommentHighlightRules.getStartRule = function(start) {
682
501
  return {
683
502
  token : "comment.doc", // doc comment
684
- merge : true,
685
503
  regex : "\\/\\*(?=\\*)",
686
504
  next : start
687
505
  };
@@ -690,7 +508,6 @@ DocCommentHighlightRules.getStartRule = function(start) {
690
508
  DocCommentHighlightRules.getEndRule = function (start) {
691
509
  return {
692
510
  token : "comment.doc", // closing comment
693
- merge : true,
694
511
  regex : "\\*\\/",
695
512
  next : start
696
513
  };
@@ -733,12 +550,7 @@ var MatchingBraceOutdent = function() {};
733
550
  };
734
551
 
735
552
  this.$getIndent = function(line) {
736
- var match = line.match(/^(\s+)/);
737
- if (match) {
738
- return match[1];
739
- }
740
-
741
- return "";
553
+ return line.match(/^\s*/)[0];
742
554
  };
743
555
 
744
556
  }).call(MatchingBraceOutdent.prototype);
@@ -746,59 +558,155 @@ var MatchingBraceOutdent = function() {};
746
558
  exports.MatchingBraceOutdent = MatchingBraceOutdent;
747
559
  });
748
560
 
749
- define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour'], function(require, exports, module) {
561
+ define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
750
562
 
751
563
 
752
564
  var oop = require("../../lib/oop");
753
565
  var Behaviour = require("../behaviour").Behaviour;
566
+ var TokenIterator = require("../../token_iterator").TokenIterator;
567
+ var lang = require("../../lib/lang");
568
+
569
+ var SAFE_INSERT_IN_TOKENS =
570
+ ["text", "paren.rparen", "punctuation.operator"];
571
+ var SAFE_INSERT_BEFORE_TOKENS =
572
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
573
+
574
+
575
+ var autoInsertedBrackets = 0;
576
+ var autoInsertedRow = -1;
577
+ var autoInsertedLineEnd = "";
578
+ var maybeInsertedBrackets = 0;
579
+ var maybeInsertedRow = -1;
580
+ var maybeInsertedLineStart = "";
581
+ var maybeInsertedLineEnd = "";
754
582
 
755
583
  var CstyleBehaviour = function () {
584
+
585
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
586
+ var cursor = editor.getCursorPosition();
587
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
588
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
589
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
590
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
591
+ return false;
592
+ }
593
+ iterator.stepForward();
594
+ return iterator.getCurrentTokenRow() !== cursor.row ||
595
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
596
+ };
597
+
598
+ CstyleBehaviour.$matchTokenType = function(token, types) {
599
+ return types.indexOf(token.type || token) > -1;
600
+ };
601
+
602
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
603
+ var cursor = editor.getCursorPosition();
604
+ var line = session.doc.getLine(cursor.row);
605
+ if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
606
+ autoInsertedBrackets = 0;
607
+ autoInsertedRow = cursor.row;
608
+ autoInsertedLineEnd = bracket + line.substr(cursor.column);
609
+ autoInsertedBrackets++;
610
+ };
611
+
612
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
613
+ var cursor = editor.getCursorPosition();
614
+ var line = session.doc.getLine(cursor.row);
615
+ if (!this.isMaybeInsertedClosing(cursor, line))
616
+ maybeInsertedBrackets = 0;
617
+ maybeInsertedRow = cursor.row;
618
+ maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
619
+ maybeInsertedLineEnd = line.substr(cursor.column);
620
+ maybeInsertedBrackets++;
621
+ };
622
+
623
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
624
+ return autoInsertedBrackets > 0 &&
625
+ cursor.row === autoInsertedRow &&
626
+ bracket === autoInsertedLineEnd[0] &&
627
+ line.substr(cursor.column) === autoInsertedLineEnd;
628
+ };
629
+
630
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
631
+ return maybeInsertedBrackets > 0 &&
632
+ cursor.row === maybeInsertedRow &&
633
+ line.substr(cursor.column) === maybeInsertedLineEnd &&
634
+ line.substr(0, cursor.column) == maybeInsertedLineStart;
635
+ };
636
+
637
+ CstyleBehaviour.popAutoInsertedClosing = function() {
638
+ autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
639
+ autoInsertedBrackets--;
640
+ };
641
+
642
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
643
+ maybeInsertedBrackets = 0;
644
+ maybeInsertedRow = -1;
645
+ };
756
646
 
757
647
  this.add("braces", "insertion", function (state, action, editor, session, text) {
648
+ var cursor = editor.getCursorPosition();
649
+ var line = session.doc.getLine(cursor.row);
758
650
  if (text == '{') {
759
651
  var selection = editor.getSelectionRange();
760
652
  var selected = session.doc.getTextRange(selection);
761
- if (selected !== "") {
653
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
762
654
  return {
763
655
  text: '{' + selected + '}',
764
656
  selection: false
765
657
  };
766
- } else {
767
- return {
768
- text: '{}',
769
- selection: [1, 1]
770
- };
658
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
659
+ if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
660
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
661
+ return {
662
+ text: '{}',
663
+ selection: [1, 1]
664
+ };
665
+ } else {
666
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
667
+ return {
668
+ text: '{',
669
+ selection: [1, 1]
670
+ };
671
+ }
771
672
  }
772
673
  } else if (text == '}') {
773
- var cursor = editor.getCursorPosition();
774
- var line = session.doc.getLine(cursor.row);
775
674
  var rightChar = line.substring(cursor.column, cursor.column + 1);
776
675
  if (rightChar == '}') {
777
676
  var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
778
- if (matching !== null) {
677
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
678
+ CstyleBehaviour.popAutoInsertedClosing();
779
679
  return {
780
680
  text: '',
781
681
  selection: [1, 1]
782
682
  };
783
683
  }
784
684
  }
785
- } else if (text == "\n") {
786
- var cursor = editor.getCursorPosition();
787
- var line = session.doc.getLine(cursor.row);
685
+ } else if (text == "\n" || text == "\r\n") {
686
+ var closing = "";
687
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
688
+ closing = lang.stringRepeat("}", maybeInsertedBrackets);
689
+ CstyleBehaviour.clearMaybeInsertedClosing();
690
+ }
788
691
  var rightChar = line.substring(cursor.column, cursor.column + 1);
789
- if (rightChar == '}') {
790
- var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column + 1});
692
+ if (rightChar === '}') {
693
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
791
694
  if (!openBracePos)
792
695
  return null;
793
-
794
- var indent = this.getNextLineIndent(state, line.substring(0, line.length - 1), session.getTabString());
795
- var next_indent = this.$getIndent(session.doc.getLine(openBracePos.row));
796
-
797
- return {
798
- text: '\n' + indent + '\n' + next_indent,
799
- selection: [1, indent.length, 1, indent.length]
800
- };
696
+ var next_indent = this.$getIndent(session.getLine(openBracePos.row));
697
+ } else if (closing) {
698
+ var next_indent = this.$getIndent(line);
699
+ } else {
700
+ return;
801
701
  }
702
+ var indent = next_indent + session.getTabString();
703
+
704
+ return {
705
+ text: '\n' + indent + '\n' + next_indent + closing,
706
+ selection: [1, indent.length, 1, indent.length]
707
+ };
708
+ } else {
709
+ CstyleBehaviour.clearMaybeInsertedClosing();
802
710
  }
803
711
  });
804
712
 
@@ -810,6 +718,8 @@ var CstyleBehaviour = function () {
810
718
  if (rightChar == '}') {
811
719
  range.end.column++;
812
720
  return range;
721
+ } else {
722
+ maybeInsertedBrackets--;
813
723
  }
814
724
  }
815
725
  });
@@ -818,12 +728,13 @@ var CstyleBehaviour = function () {
818
728
  if (text == '(') {
819
729
  var selection = editor.getSelectionRange();
820
730
  var selected = session.doc.getTextRange(selection);
821
- if (selected !== "") {
731
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
822
732
  return {
823
733
  text: '(' + selected + ')',
824
734
  selection: false
825
735
  };
826
- } else {
736
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
737
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
827
738
  return {
828
739
  text: '()',
829
740
  selection: [1, 1]
@@ -835,7 +746,8 @@ var CstyleBehaviour = function () {
835
746
  var rightChar = line.substring(cursor.column, cursor.column + 1);
836
747
  if (rightChar == ')') {
837
748
  var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
838
- if (matching !== null) {
749
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
750
+ CstyleBehaviour.popAutoInsertedClosing();
839
751
  return {
840
752
  text: '',
841
753
  selection: [1, 1]
@@ -861,12 +773,13 @@ var CstyleBehaviour = function () {
861
773
  if (text == '[') {
862
774
  var selection = editor.getSelectionRange();
863
775
  var selected = session.doc.getTextRange(selection);
864
- if (selected !== "") {
776
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
865
777
  return {
866
778
  text: '[' + selected + ']',
867
779
  selection: false
868
780
  };
869
- } else {
781
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
782
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
870
783
  return {
871
784
  text: '[]',
872
785
  selection: [1, 1]
@@ -878,7 +791,8 @@ var CstyleBehaviour = function () {
878
791
  var rightChar = line.substring(cursor.column, cursor.column + 1);
879
792
  if (rightChar == ']') {
880
793
  var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
881
- if (matching !== null) {
794
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
795
+ CstyleBehaviour.popAutoInsertedClosing();
882
796
  return {
883
797
  text: '',
884
798
  selection: [1, 1]
@@ -905,7 +819,7 @@ var CstyleBehaviour = function () {
905
819
  var quote = text;
906
820
  var selection = editor.getSelectionRange();
907
821
  var selected = session.doc.getTextRange(selection);
908
- if (selected !== "") {
822
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
909
823
  return {
910
824
  text: quote + selected + quote,
911
825
  selection: false
@@ -914,13 +828,9 @@ var CstyleBehaviour = function () {
914
828
  var cursor = editor.getCursorPosition();
915
829
  var line = session.doc.getLine(cursor.row);
916
830
  var leftChar = line.substring(cursor.column-1, cursor.column);
917
-
918
- // We're escaped.
919
831
  if (leftChar == '\\') {
920
832
  return null;
921
833
  }
922
-
923
- // Find what token we're inside.
924
834
  var tokens = session.getTokens(selection.start.row);
925
835
  var col = 0, token;
926
836
  var quotepos = -1; // Track whether we're inside an open quote.
@@ -937,15 +847,14 @@ var CstyleBehaviour = function () {
937
847
  }
938
848
  col += tokens[x].value.length;
939
849
  }
940
-
941
- // Try and be smart about when we auto insert.
942
850
  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)))) {
851
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
852
+ return;
943
853
  return {
944
854
  text: quote + quote,
945
855
  selection: [1,1]
946
856
  };
947
857
  } else if (token && token.type === "string") {
948
- // Ignore input and move right one if we're typing over the closing quote.
949
858
  var rightChar = line.substring(cursor.column, cursor.column + 1);
950
859
  if (rightChar == quote) {
951
860
  return {
@@ -963,7 +872,7 @@ var CstyleBehaviour = function () {
963
872
  if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
964
873
  var line = session.doc.getLine(range.start.row);
965
874
  var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
966
- if (rightChar == '"') {
875
+ if (rightChar == selected) {
967
876
  range.end.column++;
968
877
  return range;
969
878
  }
@@ -984,15 +893,24 @@ var oop = require("../../lib/oop");
984
893
  var Range = require("../../range").Range;
985
894
  var BaseFoldMode = require("./fold_mode").FoldMode;
986
895
 
987
- var FoldMode = exports.FoldMode = function() {};
896
+ var FoldMode = exports.FoldMode = function(commentRegex) {
897
+ if (commentRegex) {
898
+ this.foldingStartMarker = new RegExp(
899
+ this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
900
+ );
901
+ this.foldingStopMarker = new RegExp(
902
+ this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
903
+ );
904
+ }
905
+ };
988
906
  oop.inherits(FoldMode, BaseFoldMode);
989
907
 
990
908
  (function() {
991
909
 
992
910
  this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
993
911
  this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
994
-
995
- this.getFoldWidgetRange = function(session, foldStyle, row) {
912
+
913
+ this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
996
914
  var line = session.getLine(row);
997
915
  var match = line.match(this.foldingStartMarker);
998
916
  if (match) {
@@ -1000,122 +918,70 @@ oop.inherits(FoldMode, BaseFoldMode);
1000
918
 
1001
919
  if (match[1])
1002
920
  return this.openingBracketBlock(session, match[1], row, i);
1003
-
1004
- var range = session.getCommentFoldRange(row, i + match[0].length);
1005
- range.end.column -= 2;
921
+
922
+ var range = session.getCommentFoldRange(row, i + match[0].length, 1);
923
+
924
+ if (range && !range.isMultiLine()) {
925
+ if (forceMultiline) {
926
+ range = this.getSectionRange(session, row);
927
+ } else if (foldStyle != "all")
928
+ range = null;
929
+ }
930
+
1006
931
  return range;
1007
932
  }
1008
933
 
1009
- if (foldStyle !== "markbeginend")
934
+ if (foldStyle === "markbegin")
1010
935
  return;
1011
-
936
+
1012
937
  var match = line.match(this.foldingStopMarker);
1013
938
  if (match) {
1014
939
  var i = match.index + match[0].length;
1015
940
 
1016
- if (match[2]) {
1017
- var range = session.getCommentFoldRange(row, i);
1018
- range.end.column -= 2;
1019
- return range;
1020
- }
1021
-
1022
- var end = {row: row, column: i};
1023
- var start = session.$findOpeningBracket(match[1], end);
1024
-
1025
- if (!start)
1026
- return;
1027
-
1028
- start.column++;
1029
- end.column--;
941
+ if (match[1])
942
+ return this.closingBracketBlock(session, match[1], row, i);
1030
943
 
1031
- return Range.fromPoints(start, end);
944
+ return session.getCommentFoldRange(row, i, -1);
1032
945
  }
1033
946
  };
1034
947
 
1035
- }).call(FoldMode.prototype);
1036
-
1037
- });
1038
-
1039
- define('ace/mode/folding/fold_mode', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
1040
-
1041
-
1042
- var Range = require("../../range").Range;
1043
-
1044
- var FoldMode = exports.FoldMode = function() {};
1045
-
1046
- (function() {
1047
-
1048
- this.foldingStartMarker = null;
1049
- this.foldingStopMarker = null;
1050
-
1051
- // must return "" if there's no fold, to enable caching
1052
- this.getFoldWidget = function(session, foldStyle, row) {
1053
- var line = session.getLine(row);
1054
- if (this.foldingStartMarker.test(line))
1055
- return "start";
1056
- if (foldStyle == "markbeginend"
1057
- && this.foldingStopMarker
1058
- && this.foldingStopMarker.test(line))
1059
- return "end";
1060
- return "";
1061
- };
1062
-
1063
- this.getFoldWidgetRange = function(session, foldStyle, row) {
1064
- return null;
1065
- };
1066
-
1067
- this.indentationBlock = function(session, row, column) {
1068
- var re = /\S/;
948
+ this.getSectionRange = function(session, row) {
1069
949
  var line = session.getLine(row);
1070
- var startLevel = line.search(re);
1071
- if (startLevel == -1)
1072
- return;
1073
-
1074
- var startColumn = column || line.length;
1075
- var maxRow = session.getLength();
950
+ var startIndent = line.search(/\S/);
1076
951
  var startRow = row;
952
+ var startColumn = line.length;
953
+ row = row + 1;
1077
954
  var endRow = row;
1078
-
955
+ var maxRow = session.getLength();
1079
956
  while (++row < maxRow) {
1080
- var level = session.getLine(row).search(re);
1081
-
1082
- if (level == -1)
957
+ line = session.getLine(row);
958
+ var indent = line.search(/\S/);
959
+ if (indent === -1)
1083
960
  continue;
1084
-
1085
- if (level <= startLevel)
961
+ if (startIndent > indent)
1086
962
  break;
1087
-
963
+ var subRange = this.getFoldWidgetRange(session, "all", row);
964
+
965
+ if (subRange) {
966
+ if (subRange.start.row <= startRow) {
967
+ break;
968
+ } else if (subRange.isMultiLine()) {
969
+ row = subRange.end.row;
970
+ } else if (startIndent == indent) {
971
+ break;
972
+ }
973
+ }
1088
974
  endRow = row;
1089
975
  }
1090
-
1091
- if (endRow > startRow) {
1092
- var endColumn = session.getLine(endRow).length;
1093
- return new Range(startRow, startColumn, endRow, endColumn);
1094
- }
1095
- };
1096
-
1097
- this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
1098
- var start = {row: row, column: column + 1};
1099
- var end = session.$findClosingBracket(bracket, start, typeRe);
1100
- if (!end)
1101
- return;
1102
-
1103
- var fw = session.foldWidgets[end.row];
1104
- if (fw == null)
1105
- fw = this.getFoldWidget(session, end.row);
1106
-
1107
- if (fw == "start" && end.row > start.row) {
1108
- end.row --;
1109
- end.column = session.getLine(end.row).length;
1110
- }
1111
- return Range.fromPoints(start, end);
976
+
977
+ return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
1112
978
  };
1113
979
 
1114
980
  }).call(FoldMode.prototype);
1115
981
 
1116
982
  });
1117
983
 
1118
- define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/folding/cstyle'], function(require, exports, module) {
984
+ define('ace/mode/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/css_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/worker/worker_client', 'ace/mode/behaviour/css', 'ace/mode/folding/cstyle'], function(require, exports, module) {
1119
985
 
1120
986
 
1121
987
  var oop = require("../lib/oop");
@@ -1124,11 +990,13 @@ var Tokenizer = require("../tokenizer").Tokenizer;
1124
990
  var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1125
991
  var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1126
992
  var WorkerClient = require("../worker/worker_client").WorkerClient;
993
+ var CssBehaviour = require("./behaviour/css").CssBehaviour;
1127
994
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1128
995
 
1129
996
  var Mode = function() {
1130
- this.$tokenizer = new Tokenizer(new CssHighlightRules().getRules(), "i");
997
+ this.HighlightRules = CssHighlightRules;
1131
998
  this.$outdent = new MatchingBraceOutdent();
999
+ this.$behaviour = new CssBehaviour();
1132
1000
  this.foldingRules = new CStyleFoldMode();
1133
1001
  };
1134
1002
  oop.inherits(Mode, TextMode);
@@ -1136,12 +1004,11 @@ oop.inherits(Mode, TextMode);
1136
1004
  (function() {
1137
1005
 
1138
1006
  this.foldingRules = "cStyle";
1007
+ this.blockComment = {start: "/*", end: "*/"};
1139
1008
 
1140
1009
  this.getNextLineIndent = function(state, line, tab) {
1141
1010
  var indent = this.$getIndent(line);
1142
-
1143
- // ignore braces in comments
1144
- var tokens = this.$tokenizer.getLineTokens(line, state).tokens;
1011
+ var tokens = this.getTokenizer().getLineTokens(line, state).tokens;
1145
1012
  if (tokens.length && tokens[tokens.length-1].type == "comment") {
1146
1013
  return indent;
1147
1014
  }
@@ -1161,28 +1028,23 @@ oop.inherits(Mode, TextMode);
1161
1028
  this.autoOutdent = function(state, doc, row) {
1162
1029
  this.$outdent.autoOutdent(doc, row);
1163
1030
  };
1164
-
1031
+
1165
1032
  this.createWorker = function(session) {
1166
1033
  var worker = new WorkerClient(["ace"], "ace/mode/css_worker", "Worker");
1167
1034
  worker.attachToDocument(session.getDocument());
1168
-
1035
+
1169
1036
  worker.on("csslint", function(e) {
1170
- var errors = [];
1171
- e.data.forEach(function(message) {
1172
- errors.push({
1173
- row: message.line - 1,
1174
- column: message.col - 1,
1175
- text: message.message,
1176
- type: message.type,
1177
- lint: message
1178
- });
1179
- });
1180
-
1181
- session.setAnnotations(errors);
1037
+ session.setAnnotations(e.data);
1038
+ });
1039
+
1040
+ worker.on("terminate", function() {
1041
+ session.clearAnnotations();
1182
1042
  });
1043
+
1183
1044
  return worker;
1184
1045
  };
1185
1046
 
1047
+ this.$id = "ace/mode/css";
1186
1048
  }).call(Mode.prototype);
1187
1049
 
1188
1050
  exports.Mode = Mode;
@@ -1195,198 +1057,136 @@ define('ace/mode/css_highlight_rules', ['require', 'exports', 'module' , 'ace/li
1195
1057
  var oop = require("../lib/oop");
1196
1058
  var lang = require("../lib/lang");
1197
1059
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1060
+ var supportType = exports.supportType = "animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|pointer-events|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index";
1061
+ var supportFunction = exports.supportFunction = "rgb|rgba|url|attr|counter|counters";
1062
+ var supportConstant = exports.supportConstant = "absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero";
1063
+ var supportConstantColor = exports.supportConstantColor = "aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow";
1064
+ var supportConstantFonts = exports.supportConstantFonts = "arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace";
1198
1065
 
1199
- var CssHighlightRules = function() {
1200
-
1201
- var properties = lang.arrayToMap(
1202
- ("animation-fill-mode|alignment-adjust|alignment-baseline|animation-delay|animation-direction|animation-duration|animation-iteration-count|animation-name|animation-play-state|animation-timing-function|animation|appearance|azimuth|backface-visibility|background-attachment|background-break|background-clip|background-color|background-image|background-origin|background-position|background-repeat|background-size|background|baseline-shift|binding|bleed|bookmark-label|bookmark-level|bookmark-state|bookmark-target|border-bottom|border-bottom-color|border-bottom-left-radius|border-bottom-right-radius|border-bottom-style|border-bottom-width|border-collapse|border-color|border-image|border-image-outset|border-image-repeat|border-image-slice|border-image-source|border-image-width|border-left|border-left-color|border-left-style|border-left-width|border-radius|border-right|border-right-color|border-right-style|border-right-width|border-spacing|border-style|border-top|border-top-color|border-top-left-radius|border-top-right-radius|border-top-style|border-top-width|border-width|border|bottom|box-align|box-decoration-break|box-direction|box-flex-group|box-flex|box-lines|box-ordinal-group|box-orient|box-pack|box-shadow|box-sizing|break-after|break-before|break-inside|caption-side|clear|clip|color-profile|color|column-count|column-fill|column-gap|column-rule|column-rule-color|column-rule-style|column-rule-width|column-span|column-width|columns|content|counter-increment|counter-reset|crop|cue-after|cue-before|cue|cursor|direction|display|dominant-baseline|drop-initial-after-adjust|drop-initial-after-align|drop-initial-before-adjust|drop-initial-before-align|drop-initial-size|drop-initial-value|elevation|empty-cells|fit|fit-position|float-offset|float|font-family|font-size|font-size-adjust|font-stretch|font-style|font-variant|font-weight|font|grid-columns|grid-rows|hanging-punctuation|height|hyphenate-after|hyphenate-before|hyphenate-character|hyphenate-lines|hyphenate-resource|hyphens|icon|image-orientation|image-rendering|image-resolution|inline-box-align|left|letter-spacing|line-height|line-stacking-ruby|line-stacking-shift|line-stacking-strategy|line-stacking|list-style-image|list-style-position|list-style-type|list-style|margin-bottom|margin-left|margin-right|margin-top|margin|mark-after|mark-before|mark|marks|marquee-direction|marquee-play-count|marquee-speed|marquee-style|max-height|max-width|min-height|min-width|move-to|nav-down|nav-index|nav-left|nav-right|nav-up|opacity|orphans|outline-color|outline-offset|outline-style|outline-width|outline|overflow-style|overflow-x|overflow-y|overflow|padding-bottom|padding-left|padding-right|padding-top|padding|page-break-after|page-break-before|page-break-inside|page-policy|page|pause-after|pause-before|pause|perspective-origin|perspective|phonemes|pitch-range|pitch|play-during|position|presentation-level|punctuation-trim|quotes|rendering-intent|resize|rest-after|rest-before|rest|richness|right|rotation-point|rotation|ruby-align|ruby-overhang|ruby-position|ruby-span|size|speak-header|speak-numeral|speak-punctuation|speak|speech-rate|stress|string-set|table-layout|target-name|target-new|target-position|target|text-align-last|text-align|text-decoration|text-emphasis|text-height|text-indent|text-justify|text-outline|text-shadow|text-transform|text-wrap|top|transform-origin|transform-style|transform|transition-delay|transition-duration|transition-property|transition-timing-function|transition|unicode-bidi|vertical-align|visibility|voice-balance|voice-duration|voice-family|voice-pitch-range|voice-pitch|voice-rate|voice-stress|voice-volume|volume|white-space-collapse|white-space|widows|width|word-break|word-spacing|word-wrap|z-index").split("|")
1203
- );
1204
-
1205
- var functions = lang.arrayToMap(
1206
- ("rgb|rgba|url|attr|counter|counters").split("|")
1207
- );
1066
+ var numRe = exports.numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
1067
+ var pseudoElements = exports.pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
1068
+ var pseudoClasses = exports.pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
1208
1069
 
1209
- var constants = lang.arrayToMap(
1210
- ("absolute|after-edge|after|all-scroll|all|alphabetic|always|antialiased|armenian|auto|avoid-column|avoid-page|avoid|balance|baseline|before-edge|before|below|bidi-override|block-line-height|block|bold|bolder|border-box|both|bottom|box|break-all|break-word|capitalize|caps-height|caption|center|central|char|circle|cjk-ideographic|clone|close-quote|col-resize|collapse|column|consider-shifts|contain|content-box|cover|crosshair|cubic-bezier|dashed|decimal-leading-zero|decimal|default|disabled|disc|disregard-shifts|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|e-resize|ease-in|ease-in-out|ease-out|ease|ellipsis|end|exclude-ruby|fill|fixed|font-size|font|georgian|glyphs|grid-height|groove|hand|hanging|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|icon|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|ideographic|inactive|include-ruby|inherit|initial|inline-block|inline-box|inline-line-height|inline-table|inline|inset|inside|inter-ideograph|inter-word|invert|italic|justify|katakana-iroha|katakana|keep-all|last|left|lighter|line-edge|line-through|line|linear|list-item|local|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|mathematical|max-height|max-size|medium|menu|message-box|middle|move|n-resize|ne-resize|newspaper|no-change|no-close-quote|no-drop|no-open-quote|no-repeat|none|normal|not-allowed|nowrap|nw-resize|oblique|open-quote|outset|outside|overline|padding-box|page|pointer|pre-line|pre-wrap|pre|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|replaced|reset-size|ridge|right|round|row-resize|rtl|s-resize|scroll|se-resize|separate|slice|small-caps|small-caption|solid|space|square|start|static|status-bar|step-end|step-start|steps|stretch|strict|sub|super|sw-resize|table-caption|table-cell|table-column-group|table-column|table-footer-group|table-header-group|table-row-group|table-row|table|tb-rl|text-after-edge|text-before-edge|text-bottom|text-size|text-top|text|thick|thin|top|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|use-script|vertical-ideographic|vertical-text|visible|w-resize|wait|whitespace|z-index|zero").split("|")
1211
- );
1212
-
1213
- var colors = lang.arrayToMap(
1214
- ("aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|" +
1215
- "purple|red|silver|teal|white|yellow").split("|")
1216
- );
1070
+ var CssHighlightRules = function() {
1217
1071
 
1218
- var fonts = lang.arrayToMap(
1219
- ("arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|" +
1220
- "symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|" +
1221
- "serif|monospace").split("|")
1222
- );
1223
-
1224
- // regexp must not have capturing parentheses. Use (?:) instead.
1225
- // regexps are ordered -> the first match is used
1072
+ var keywordMapper = this.createKeywordMapper({
1073
+ "support.function": supportFunction,
1074
+ "support.constant": supportConstant,
1075
+ "support.type": supportType,
1076
+ "support.constant.color": supportConstantColor,
1077
+ "support.constant.fonts": supportConstantFonts
1078
+ }, "text", true);
1226
1079
 
1227
- var numRe = "\\-?(?:(?:[0-9]+)|(?:[0-9]*\\.[0-9]+))";
1228
- var pseudoElements = "(\\:+)\\b(after|before|first-letter|first-line|moz-selection|selection)\\b";
1229
- var pseudoClasses = "(:)\\b(active|checked|disabled|empty|enabled|first-child|first-of-type|focus|hover|indeterminate|invalid|last-child|last-of-type|link|not|nth-child|nth-last-child|nth-last-of-type|nth-of-type|only-child|only-of-type|required|root|target|valid|visited)\\b";
1230
-
1231
- var base_ruleset = [
1232
- {
1080
+ this.$rules = {
1081
+ "start" : [{
1233
1082
  token : "comment", // multi line comment
1234
- merge : true,
1235
1083
  regex : "\\/\\*",
1236
- next : "ruleset_comment"
1237
- }, {
1238
- token : "string", // single line
1239
- regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
1084
+ push : "comment"
1240
1085
  }, {
1241
- token : "string", // single line
1242
- regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
1086
+ token: "paren.lparen",
1087
+ regex: "\\{",
1088
+ push: "ruleset"
1243
1089
  }, {
1244
- token : ["constant.numeric", "keyword"],
1245
- regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
1090
+ token: "string",
1091
+ regex: "@.*?{",
1092
+ push: "media"
1246
1093
  }, {
1247
- token : ["constant.numeric"],
1248
- regex : "([0-9]+)"
1094
+ token: "keyword",
1095
+ regex: "#[a-z0-9-_]+"
1249
1096
  }, {
1250
- token : "constant.numeric", // hex6 color
1251
- regex : "#[a-f0-9]{6}"
1097
+ token: "variable",
1098
+ regex: "\\.[a-z0-9-_]+"
1252
1099
  }, {
1253
- token : "constant.numeric", // hex3 color
1254
- regex : "#[a-f0-9]{3}"
1100
+ token: "string",
1101
+ regex: ":[a-z0-9-_]+"
1255
1102
  }, {
1256
- token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
1257
- regex : pseudoElements
1103
+ token: "constant",
1104
+ regex: "[a-z0-9-_]+"
1258
1105
  }, {
1259
- token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
1260
- regex : pseudoClasses
1261
- }, {
1262
- token : function(value) {
1263
- if (properties.hasOwnProperty(value.toLowerCase())) {
1264
- return "support.type";
1265
- }
1266
- else if (functions.hasOwnProperty(value.toLowerCase())) {
1267
- return "support.function";
1268
- }
1269
- else if (constants.hasOwnProperty(value.toLowerCase())) {
1270
- return "support.constant";
1271
- }
1272
- else if (colors.hasOwnProperty(value.toLowerCase())) {
1273
- return "support.constant.color";
1274
- }
1275
- else if (fonts.hasOwnProperty(value.toLowerCase())) {
1276
- return "support.constant.fonts";
1277
- }
1278
- else {
1279
- return "text";
1280
- }
1281
- },
1282
- regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
1283
- }
1284
- ];
1285
-
1286
- var ruleset = lang.copyArray(base_ruleset);
1287
- ruleset.unshift({
1288
- token : "paren.rparen",
1289
- regex : "\\}",
1290
- next: "start"
1291
- });
1292
-
1293
- var media_ruleset = lang.copyArray( base_ruleset );
1294
- media_ruleset.unshift({
1295
- token : "paren.rparen",
1296
- regex : "\\}",
1297
- next: "media"
1298
- });
1299
-
1300
- var base_comment = [{
1301
- token : "comment", // comment spanning whole line
1302
- merge : true,
1303
- regex : ".+"
1304
- }];
1305
-
1306
- var comment = lang.copyArray(base_comment);
1307
- comment.unshift({
1308
- token : "comment", // closing comment
1309
- regex : ".*?\\*\\/",
1310
- next : "start"
1311
- });
1312
-
1313
- var media_comment = lang.copyArray(base_comment);
1314
- media_comment.unshift({
1315
- token : "comment", // closing comment
1316
- regex : ".*?\\*\\/",
1317
- next : "media"
1318
- });
1319
-
1320
- var ruleset_comment = lang.copyArray(base_comment);
1321
- ruleset_comment.unshift({
1322
- token : "comment", // closing comment
1323
- regex : ".*?\\*\\/",
1324
- next : "ruleset"
1325
- });
1326
-
1327
- this.$rules = {
1328
- "start" : [{
1329
- token : "comment", // multi line comment
1330
- merge : true,
1331
- regex : "\\/\\*",
1332
- next : "comment"
1106
+ caseInsensitive: true
1107
+ }],
1108
+
1109
+ "media" : [{
1110
+ token : "comment", // multi line comment
1111
+ regex : "\\/\\*",
1112
+ push : "comment"
1333
1113
  }, {
1334
1114
  token: "paren.lparen",
1335
1115
  regex: "\\{",
1336
- next: "ruleset"
1116
+ push: "ruleset"
1337
1117
  }, {
1338
1118
  token: "string",
1339
- regex: "@.*?{",
1340
- next: "media"
1341
- },{
1119
+ regex: "\\}",
1120
+ next: "pop"
1121
+ }, {
1342
1122
  token: "keyword",
1343
1123
  regex: "#[a-z0-9-_]+"
1344
- },{
1124
+ }, {
1345
1125
  token: "variable",
1346
1126
  regex: "\\.[a-z0-9-_]+"
1347
- },{
1127
+ }, {
1348
1128
  token: "string",
1349
1129
  regex: ":[a-z0-9-_]+"
1350
- },{
1130
+ }, {
1351
1131
  token: "constant",
1352
1132
  regex: "[a-z0-9-_]+"
1133
+ }, {
1134
+ caseInsensitive: true
1353
1135
  }],
1354
1136
 
1355
- "media" : [ {
1356
- token : "comment", // multi line comment
1357
- merge : true,
1358
- regex : "\\/\\*",
1359
- next : "media_comment"
1137
+ "comment" : [{
1138
+ token : "comment",
1139
+ regex : "\\*\\/",
1140
+ next : "pop"
1360
1141
  }, {
1361
- token: "paren.lparen",
1362
- regex: "\\{",
1363
- next: "media_ruleset"
1364
- },{
1365
- token: "string",
1366
- regex: "\\}",
1367
- next: "start"
1368
- },{
1369
- token: "keyword",
1370
- regex: "#[a-z0-9-_]+"
1371
- },{
1372
- token: "variable",
1373
- regex: "\\.[a-z0-9-_]+"
1374
- },{
1375
- token: "string",
1376
- regex: ":[a-z0-9-_]+"
1377
- },{
1378
- token: "constant",
1379
- regex: "[a-z0-9-_]+"
1142
+ defaultToken : "comment"
1380
1143
  }],
1381
1144
 
1382
- "comment" : comment,
1383
-
1384
- "ruleset" : ruleset,
1385
- "ruleset_comment" : ruleset_comment,
1386
-
1387
- "media_ruleset" : media_ruleset,
1388
- "media_comment" : media_comment
1145
+ "ruleset" : [
1146
+ {
1147
+ token : "paren.rparen",
1148
+ regex : "\\}",
1149
+ next: "pop"
1150
+ }, {
1151
+ token : "comment", // multi line comment
1152
+ regex : "\\/\\*",
1153
+ push : "comment"
1154
+ }, {
1155
+ token : "string", // single line
1156
+ regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
1157
+ }, {
1158
+ token : "string", // single line
1159
+ regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
1160
+ }, {
1161
+ token : ["constant.numeric", "keyword"],
1162
+ regex : "(" + numRe + ")(ch|cm|deg|em|ex|fr|gd|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vm|vw|%)"
1163
+ }, {
1164
+ token : "constant.numeric",
1165
+ regex : numRe
1166
+ }, {
1167
+ token : "constant.numeric", // hex6 color
1168
+ regex : "#[a-f0-9]{6}"
1169
+ }, {
1170
+ token : "constant.numeric", // hex3 color
1171
+ regex : "#[a-f0-9]{3}"
1172
+ }, {
1173
+ token : ["punctuation", "entity.other.attribute-name.pseudo-element.css"],
1174
+ regex : pseudoElements
1175
+ }, {
1176
+ token : ["punctuation", "entity.other.attribute-name.pseudo-class.css"],
1177
+ regex : pseudoClasses
1178
+ }, {
1179
+ token : ["support.function", "string", "support.function"],
1180
+ regex : "(url\\()(.*)(\\))"
1181
+ }, {
1182
+ token : keywordMapper,
1183
+ regex : "\\-?[a-zA-Z_][a-zA-Z0-9_\\-]*"
1184
+ }, {
1185
+ caseInsensitive: true
1186
+ }]
1389
1187
  };
1188
+
1189
+ this.normalizeRules();
1390
1190
  };
1391
1191
 
1392
1192
  oop.inherits(CssHighlightRules, TextHighlightRules);
@@ -1395,15 +1195,93 @@ exports.CssHighlightRules = CssHighlightRules;
1395
1195
 
1396
1196
  });
1397
1197
 
1398
- define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1198
+ define('ace/mode/behaviour/css', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
1199
+
1200
+
1201
+ var oop = require("../../lib/oop");
1202
+ var Behaviour = require("../behaviour").Behaviour;
1203
+ var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1204
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1205
+
1206
+ var CssBehaviour = function () {
1207
+
1208
+ this.inherit(CstyleBehaviour);
1209
+
1210
+ this.add("colon", "insertion", function (state, action, editor, session, text) {
1211
+ if (text === ':') {
1212
+ var cursor = editor.getCursorPosition();
1213
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1214
+ var token = iterator.getCurrentToken();
1215
+ if (token && token.value.match(/\s+/)) {
1216
+ token = iterator.stepBackward();
1217
+ }
1218
+ if (token && token.type === 'support.type') {
1219
+ var line = session.doc.getLine(cursor.row);
1220
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1221
+ if (rightChar === ':') {
1222
+ return {
1223
+ text: '',
1224
+ selection: [1, 1]
1225
+ }
1226
+ }
1227
+ if (!line.substring(cursor.column).match(/^\s*;/)) {
1228
+ return {
1229
+ text: ':;',
1230
+ selection: [1, 1]
1231
+ }
1232
+ }
1233
+ }
1234
+ }
1235
+ });
1236
+
1237
+ this.add("colon", "deletion", function (state, action, editor, session, range) {
1238
+ var selected = session.doc.getTextRange(range);
1239
+ if (!range.isMultiLine() && selected === ':') {
1240
+ var cursor = editor.getCursorPosition();
1241
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1242
+ var token = iterator.getCurrentToken();
1243
+ if (token && token.value.match(/\s+/)) {
1244
+ token = iterator.stepBackward();
1245
+ }
1246
+ if (token && token.type === 'support.type') {
1247
+ var line = session.doc.getLine(range.start.row);
1248
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
1249
+ if (rightChar === ';') {
1250
+ range.end.column ++;
1251
+ return range;
1252
+ }
1253
+ }
1254
+ }
1255
+ });
1256
+
1257
+ this.add("semicolon", "insertion", function (state, action, editor, session, text) {
1258
+ if (text === ';') {
1259
+ var cursor = editor.getCursorPosition();
1260
+ var line = session.doc.getLine(cursor.row);
1261
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1262
+ if (rightChar === ';') {
1263
+ return {
1264
+ text: '',
1265
+ selection: [1, 1]
1266
+ }
1267
+ }
1268
+ }
1269
+ });
1270
+
1271
+ }
1272
+ oop.inherits(CssBehaviour, CstyleBehaviour);
1273
+
1274
+ exports.CssBehaviour = CssBehaviour;
1275
+ });
1276
+
1277
+ define('ace/mode/html_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/css_highlight_rules', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules'], function(require, exports, module) {
1399
1278
 
1400
1279
 
1401
1280
  var oop = require("../lib/oop");
1402
1281
  var lang = require("../lib/lang");
1403
1282
  var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules;
1404
1283
  var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1405
- var xmlUtil = require("./xml_util");
1406
- var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1284
+ var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
1407
1285
 
1408
1286
  var tagMap = lang.createMap({
1409
1287
  a : 'anchor',
@@ -1412,6 +1290,7 @@ var tagMap = lang.createMap({
1412
1290
  img : 'image',
1413
1291
  input : 'form',
1414
1292
  label : 'form',
1293
+ option : 'form',
1415
1294
  script : 'script',
1416
1295
  select : 'form',
1417
1296
  textarea : 'form',
@@ -1425,98 +1304,255 @@ var tagMap = lang.createMap({
1425
1304
  });
1426
1305
 
1427
1306
  var HtmlHighlightRules = function() {
1307
+ XmlHighlightRules.call(this);
1428
1308
 
1429
- // regexp must not have capturing parentheses
1430
- // regexps are ordered -> the first match is used
1431
- this.$rules = {
1432
- start : [{
1433
- token : "text",
1434
- merge : true,
1435
- regex : "<\\!\\[CDATA\\[",
1436
- next : "cdata"
1309
+ this.addRules({
1310
+ attributes: [{
1311
+ include : "space"
1437
1312
  }, {
1438
- token : "xml_pe",
1439
- regex : "<\\?.*?\\?>"
1440
- }, {
1441
- token : "comment",
1442
- merge : true,
1443
- regex : "<\\!--",
1444
- next : "comment"
1313
+ token : "entity.other.attribute-name",
1314
+ regex : "[-_a-zA-Z0-9:]+"
1445
1315
  }, {
1446
- token : "xml_pe",
1447
- regex : "<\\!.*?>"
1448
- }, {
1449
- token : "meta.tag",
1450
- regex : "<(?=\s*script\\b)",
1451
- next : "script"
1452
- }, {
1453
- token : "meta.tag",
1454
- regex : "<(?=\s*style\\b)",
1455
- next : "style"
1316
+ token : "keyword.operator.separator",
1317
+ regex : "=",
1318
+ push : [{
1319
+ include: "space"
1320
+ }, {
1321
+ token : "string",
1322
+ regex : "[^<>='\"`\\s]+",
1323
+ next : "pop"
1324
+ }, {
1325
+ token : "empty",
1326
+ regex : "",
1327
+ next : "pop"
1328
+ }]
1456
1329
  }, {
1457
- token : "meta.tag", // opening tag
1458
- regex : "<\\/?",
1459
- next : "tag"
1330
+ include : "string"
1331
+ }],
1332
+ tag: [{
1333
+ token : function(start, tag) {
1334
+ var group = tagMap[tag];
1335
+ return ["meta.tag.punctuation.begin",
1336
+ "meta.tag.name" + (group ? "." + group : "")];
1337
+ },
1338
+ regex : "(<)([-_a-zA-Z0-9:]+)",
1339
+ next: "start_tag_stuff"
1460
1340
  }, {
1341
+ token : function(start, tag) {
1342
+ var group = tagMap[tag];
1343
+ return ["meta.tag.punctuation.begin",
1344
+ "meta.tag.name" + (group ? "." + group : "")];
1345
+ },
1346
+ regex : "(</)([-_a-zA-Z0-9:]+)",
1347
+ next: "end_tag_stuff"
1348
+ }],
1349
+ start_tag_stuff: [
1350
+ {include : "attributes"},
1351
+ {token : "meta.tag.punctuation.end", regex : "/?>", next : "start"}
1352
+ ],
1353
+ end_tag_stuff: [
1354
+ {include : "space"},
1355
+ {token : "meta.tag.punctuation.end", regex : ">", next : "start"}
1356
+ ]
1357
+ });
1358
+
1359
+ this.embedTagRules(CssHighlightRules, "css-", "style");
1360
+ this.embedTagRules(JavaScriptHighlightRules, "js-", "script");
1361
+
1362
+ if (this.constructor === HtmlHighlightRules)
1363
+ this.normalizeRules();
1364
+ };
1365
+
1366
+ oop.inherits(HtmlHighlightRules, XmlHighlightRules);
1367
+
1368
+ exports.HtmlHighlightRules = HtmlHighlightRules;
1369
+ });
1370
+
1371
+ define('ace/mode/xml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml_util', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1372
+
1373
+
1374
+ var oop = require("../lib/oop");
1375
+ var xmlUtil = require("./xml_util");
1376
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1377
+
1378
+ var XmlHighlightRules = function(normalize) {
1379
+ this.$rules = {
1380
+ start : [
1381
+ {token : "punctuation.string.begin", regex : "<\\!\\[CDATA\\[", next : "cdata"},
1382
+ {
1383
+ token : ["punctuation.instruction.begin", "keyword.instruction"],
1384
+ regex : "(<\\?)(xml)(?=[\\s])", next : "xml_declaration"
1385
+ },
1386
+ {
1387
+ token : ["punctuation.instruction.begin", "keyword.instruction"],
1388
+ regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "instruction"
1389
+ },
1390
+ {token : "comment", regex : "<\\!--", next : "comment"},
1391
+ {
1392
+ token : ["punctuation.doctype.begin", "meta.tag.doctype"],
1393
+ regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype"
1394
+ },
1395
+ {include : "tag"},
1396
+ {include : "reference"}
1397
+ ],
1398
+
1399
+ xml_declaration : [
1400
+ {include : "attributes"},
1401
+ {include : "instruction"}
1402
+ ],
1403
+
1404
+ instruction : [
1405
+ {token : "punctuation.instruction.end", regex : "\\?>", next : "start"}
1406
+ ],
1407
+
1408
+ doctype : [
1409
+ {include : "space"},
1410
+ {include : "string"},
1411
+ {token : "punctuation.doctype.end", regex : ">", next : "start"},
1412
+ {token : "xml-pe", regex : "[-_a-zA-Z0-9:]+"},
1413
+ {token : "punctuation.begin", regex : "\\[", push : "declarations"}
1414
+ ],
1415
+
1416
+ declarations : [{
1461
1417
  token : "text",
1462
1418
  regex : "\\s+"
1463
1419
  }, {
1464
- token : "constant.character.entity",
1465
- regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1420
+ token: "punctuation.end",
1421
+ regex: "]",
1422
+ next: "pop"
1466
1423
  }, {
1467
- token : "text",
1468
- regex : "[^<]+"
1469
- } ],
1470
-
1471
- cdata : [ {
1472
- token : "text",
1473
- regex : "\\]\\]>",
1474
- next : "start"
1424
+ token : ["punctuation.begin", "keyword"],
1425
+ regex : "(<\\!)([-_a-zA-Z0-9]+)",
1426
+ push : [{
1427
+ token : "text",
1428
+ regex : "\\s+"
1429
+ },
1430
+ {
1431
+ token : "punctuation.end",
1432
+ regex : ">",
1433
+ next : "pop"
1434
+ },
1435
+ {include : "string"}]
1436
+ }],
1437
+
1438
+ cdata : [
1439
+ {token : "string.end", regex : "\\]\\]>", next : "start"},
1440
+ {token : "text", regex : "\\s+"},
1441
+ {token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
1442
+ ],
1443
+
1444
+ comment : [
1445
+ {token : "comment", regex : "-->", next : "start"},
1446
+ {defaultToken : "comment"}
1447
+ ],
1448
+
1449
+ tag : [{
1450
+ token : ["meta.tag.punctuation.begin", "meta.tag.name"],
1451
+ regex : "(<)((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
1452
+ next: [
1453
+ {include : "attributes"},
1454
+ {token : "meta.tag.punctuation.end", regex : "/?>", next : "start"}
1455
+ ]
1475
1456
  }, {
1476
- token : "text",
1477
- merge : true,
1478
- regex : "\\s+"
1457
+ token : ["meta.tag.punctuation.begin", "meta.tag.name"],
1458
+ regex : "(</)((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
1459
+ next: [
1460
+ {include : "space"},
1461
+ {token : "meta.tag.punctuation.end", regex : ">", next : "start"}
1462
+ ]
1463
+ }],
1464
+
1465
+ space : [
1466
+ {token : "text", regex : "\\s+"}
1467
+ ],
1468
+
1469
+ reference : [{
1470
+ token : "constant.language.escape",
1471
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1479
1472
  }, {
1480
- token : "text",
1481
- merge : true,
1482
- regex : ".+"
1483
- } ],
1473
+ token : "text", regex : "&"
1474
+ }],
1484
1475
 
1485
- comment : [ {
1486
- token : "comment",
1487
- regex : ".*?-->",
1488
- next : "start"
1476
+ string: [{
1477
+ token : "string",
1478
+ regex : "'",
1479
+ push : "qstring_inner"
1489
1480
  }, {
1490
- token : "comment",
1491
- merge : true,
1492
- regex : ".+"
1493
- } ]
1481
+ token : "string",
1482
+ regex : '"',
1483
+ push : "qqstring_inner"
1484
+ }],
1485
+
1486
+ qstring_inner: [
1487
+ {token : "string", regex: "'", next: "pop"},
1488
+ {include : "reference"},
1489
+ {defaultToken : "string"}
1490
+ ],
1491
+
1492
+ qqstring_inner: [
1493
+ {token : "string", regex: '"', next: "pop"},
1494
+ {include : "reference"},
1495
+ {defaultToken : "string"}
1496
+ ],
1497
+
1498
+ attributes: [{
1499
+ token : "entity.other.attribute-name",
1500
+ regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
1501
+ }, {
1502
+ token : "keyword.operator.separator",
1503
+ regex : "="
1504
+ }, {
1505
+ include : "space"
1506
+ }, {
1507
+ include : "string"
1508
+ }]
1494
1509
  };
1495
-
1496
- xmlUtil.tag(this.$rules, "tag", "start", tagMap);
1497
- xmlUtil.tag(this.$rules, "style", "css-start", tagMap);
1498
- xmlUtil.tag(this.$rules, "script", "js-start", tagMap);
1499
-
1500
- this.embedRules(JavaScriptHighlightRules, "js-", [{
1501
- token: "comment",
1502
- regex: "\\/\\/.*(?=<\\/script>)",
1503
- next: "tag"
1504
- }, {
1505
- token: "meta.tag",
1506
- regex: "<\\/(?=script)",
1507
- next: "tag"
1508
- }]);
1509
-
1510
- this.embedRules(CssHighlightRules, "css-", [{
1511
- token: "meta.tag",
1512
- regex: "<\\/(?=style)",
1513
- next: "tag"
1514
- }]);
1510
+
1511
+ if (this.constructor === XmlHighlightRules)
1512
+ this.normalizeRules();
1515
1513
  };
1516
1514
 
1517
- oop.inherits(HtmlHighlightRules, TextHighlightRules);
1518
1515
 
1519
- exports.HtmlHighlightRules = HtmlHighlightRules;
1516
+ (function() {
1517
+
1518
+ this.embedTagRules = function(HighlightRules, prefix, tag){
1519
+ this.$rules.tag.unshift({
1520
+ token : ["meta.tag.punctuation.begin", "meta.tag.name." + tag],
1521
+ regex : "(<)(" + tag + ")",
1522
+ next: [
1523
+ {include : "space"},
1524
+ {include : "attributes"},
1525
+ {token : "meta.tag.punctuation.end", regex : "/?>", next : prefix + "start"}
1526
+ ]
1527
+ });
1528
+
1529
+ this.$rules[tag + "-end"] = [
1530
+ {include : "space"},
1531
+ {token : "meta.tag.punctuation.end", regex : ">", next: "start",
1532
+ onMatch : function(value, currentState, stack) {
1533
+ stack.splice(0);
1534
+ return this.token;
1535
+ }}
1536
+ ]
1537
+
1538
+ this.embedRules(HighlightRules, prefix, [{
1539
+ token: ["meta.tag.punctuation.begin", "meta.tag.name." + tag],
1540
+ regex : "(</)(" + tag + ")",
1541
+ next: tag + "-end"
1542
+ }, {
1543
+ token: "string.begin",
1544
+ regex : "<\\!\\[CDATA\\["
1545
+ }, {
1546
+ token: "string.end",
1547
+ regex : "\\]\\]>"
1548
+ }]);
1549
+ };
1550
+
1551
+ }).call(TextHighlightRules.prototype);
1552
+
1553
+ oop.inherits(XmlHighlightRules, TextHighlightRules);
1554
+
1555
+ exports.XmlHighlightRules = XmlHighlightRules;
1520
1556
  });
1521
1557
 
1522
1558
  define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
@@ -1525,34 +1561,24 @@ define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require,
1525
1561
  function string(state) {
1526
1562
  return [{
1527
1563
  token : "string",
1528
- regex : '".*?"'
1529
- }, {
1530
- token : "string", // multi line string start
1531
- merge : true,
1532
- regex : '["].*',
1564
+ regex : '"',
1533
1565
  next : state + "_qqstring"
1534
1566
  }, {
1535
1567
  token : "string",
1536
- regex : "'.*?'"
1537
- }, {
1538
- token : "string", // multi line string start
1539
- merge : true,
1540
- regex : "['].*",
1568
+ regex : "'",
1541
1569
  next : state + "_qstring"
1542
1570
  }];
1543
1571
  }
1544
1572
 
1545
1573
  function multiLineString(quote, state) {
1546
- return [{
1547
- token : "string",
1548
- merge : true,
1549
- regex : ".*?" + quote,
1550
- next : state
1551
- }, {
1552
- token : "string",
1553
- merge : true,
1554
- regex : '.+'
1555
- }];
1574
+ return [
1575
+ {token : "string", regex : quote, next : state},
1576
+ {
1577
+ token : "constant.language.escape",
1578
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
1579
+ },
1580
+ {defaultToken : "string"}
1581
+ ];
1556
1582
  }
1557
1583
 
1558
1584
  exports.tag = function(states, name, nextState, tagMap) {
@@ -1560,7 +1586,6 @@ exports.tag = function(states, name, nextState, tagMap) {
1560
1586
  token : "text",
1561
1587
  regex : "\\s+"
1562
1588
  }, {
1563
- //token : "meta.tag",
1564
1589
 
1565
1590
  token : !tagMap ? "meta.tag.tag-name" : function(value) {
1566
1591
  if (tagMap[value])
@@ -1568,7 +1593,6 @@ exports.tag = function(states, name, nextState, tagMap) {
1568
1593
  else
1569
1594
  return "meta.tag.tag-name";
1570
1595
  },
1571
- merge : true,
1572
1596
  regex : "[-_a-zA-Z0-9:]+",
1573
1597
  next : name + "_embed_attribute_list"
1574
1598
  }, {
@@ -1581,9 +1605,8 @@ exports.tag = function(states, name, nextState, tagMap) {
1581
1605
  states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
1582
1606
 
1583
1607
  states[name + "_embed_attribute_list"] = [{
1584
- token : "meta.tag",
1585
- merge : true,
1586
- regex : "\/?>",
1608
+ token : "meta.tag.r",
1609
+ regex : "/?>",
1587
1610
  next : nextState
1588
1611
  }, {
1589
1612
  token : "keyword.operator",
@@ -1612,14 +1635,9 @@ var TokenIterator = require("../../token_iterator").TokenIterator;
1612
1635
  var voidElements = ['area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
1613
1636
 
1614
1637
  function hasType(token, type) {
1615
- var hasType = true;
1616
- var typeList = token.type.split('.');
1617
- var needleList = type.split('.');
1618
- needleList.forEach(function(needle){
1619
- if (typeList.indexOf(needle) == -1) {
1620
- hasType = false;
1621
- return false;
1622
- }
1638
+ var tokenTypes = token.type.split('.');
1639
+ return type.split('.').every(function(type){
1640
+ return (tokenTypes.indexOf(type) !== -1);
1623
1641
  });
1624
1642
  return hasType;
1625
1643
  }
@@ -1633,6 +1651,9 @@ var HtmlBehaviour = function () {
1633
1651
  var position = editor.getCursorPosition();
1634
1652
  var iterator = new TokenIterator(session, position.row, position.column);
1635
1653
  var token = iterator.getCurrentToken();
1654
+
1655
+ if (token && hasType(token, 'string') && iterator.getCurrentTokenColumn() + token.value.length > position.column)
1656
+ return;
1636
1657
  var atCursor = false;
1637
1658
  if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1638
1659
  do {
@@ -1641,8 +1662,8 @@ var HtmlBehaviour = function () {
1641
1662
  } else {
1642
1663
  atCursor = true;
1643
1664
  }
1644
- if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1645
- return
1665
+ if (!token || !hasType(token, 'meta.tag.name') || iterator.stepBackward().value.match('/')) {
1666
+ return;
1646
1667
  }
1647
1668
  var element = token.value;
1648
1669
  if (atCursor){
@@ -1672,14 +1693,9 @@ var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
1672
1693
  var TokenIterator = require("../../token_iterator").TokenIterator;
1673
1694
 
1674
1695
  function hasType(token, type) {
1675
- var hasType = true;
1676
- var typeList = token.type.split('.');
1677
- var needleList = type.split('.');
1678
- needleList.forEach(function(needle){
1679
- if (typeList.indexOf(needle) == -1) {
1680
- hasType = false;
1681
- return false;
1682
- }
1696
+ var tokenTypes = token.type.split('.');
1697
+ return type.split('.').every(function(type){
1698
+ return (tokenTypes.indexOf(type) !== -1);
1683
1699
  });
1684
1700
  return hasType;
1685
1701
  }
@@ -1693,6 +1709,9 @@ var XmlBehaviour = function () {
1693
1709
  var position = editor.getCursorPosition();
1694
1710
  var iterator = new TokenIterator(session, position.row, position.column);
1695
1711
  var token = iterator.getCurrentToken();
1712
+
1713
+ if (token && hasType(token, 'string') && iterator.getCurrentTokenColumn() + token.value.length > position.column)
1714
+ return;
1696
1715
  var atCursor = false;
1697
1716
  if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
1698
1717
  do {
@@ -1701,8 +1720,8 @@ var XmlBehaviour = function () {
1701
1720
  } else {
1702
1721
  atCursor = true;
1703
1722
  }
1704
- if (!token || !hasType(token, 'meta.tag-name') || iterator.stepBackward().value.match('/')) {
1705
- return
1723
+ if (!token || !hasType(token, 'meta.tag.name') || iterator.stepBackward().value.match('/')) {
1724
+ return;
1706
1725
  }
1707
1726
  var tag = token.value;
1708
1727
  if (atCursor){
@@ -1719,11 +1738,11 @@ var XmlBehaviour = function () {
1719
1738
  this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
1720
1739
  if (text == "\n") {
1721
1740
  var cursor = editor.getCursorPosition();
1722
- var line = session.doc.getLine(cursor.row);
1741
+ var line = session.getLine(cursor.row);
1723
1742
  var rightChars = line.substring(cursor.column, cursor.column + 2);
1724
1743
  if (rightChars == '</') {
1725
- var indent = this.$getIndent(session.doc.getLine(cursor.row)) + session.getTabString();
1726
- var next_indent = this.$getIndent(session.doc.getLine(cursor.row));
1744
+ var next_indent = this.$getIndent(line);
1745
+ var indent = next_indent + session.getTabString();
1727
1746
 
1728
1747
  return {
1729
1748
  text: '\n' + indent + '\n' + next_indent,
@@ -1749,7 +1768,6 @@ var CStyleFoldMode = require("./cstyle").FoldMode;
1749
1768
 
1750
1769
  var FoldMode = exports.FoldMode = function() {
1751
1770
  MixedFoldMode.call(this, new XmlFoldMode({
1752
- // void elements
1753
1771
  "area": 1,
1754
1772
  "base": 1,
1755
1773
  "br": 1,
@@ -1766,8 +1784,6 @@ var FoldMode = exports.FoldMode = function() {
1766
1784
  "source": 1,
1767
1785
  "track": 1,
1768
1786
  "wbr": 1,
1769
-
1770
- // optional tags
1771
1787
  "li": 1,
1772
1788
  "dt": 1,
1773
1789
  "dd": 1,
@@ -1805,6 +1821,8 @@ oop.inherits(FoldMode, BaseFoldMode);
1805
1821
 
1806
1822
 
1807
1823
  this.$getMode = function(state) {
1824
+ if (typeof state != "string")
1825
+ state = state[0];
1808
1826
  for (var key in this.subModes) {
1809
1827
  if (state.indexOf(key) === 0)
1810
1828
  return this.subModes[key];
@@ -1881,7 +1899,7 @@ oop.inherits(FoldMode, BaseFoldMode);
1881
1899
  var value = "";
1882
1900
  for (var i = 0; i < tokens.length; i++) {
1883
1901
  var token = tokens[i];
1884
- if (token.type.indexOf("meta.tag") === 0)
1902
+ if (token.type.lastIndexOf("meta.tag", 0) === 0)
1885
1903
  value += token.value;
1886
1904
  else
1887
1905
  value += lang.stringRepeat(" ", token.value.length);
@@ -1893,9 +1911,8 @@ oop.inherits(FoldMode, BaseFoldMode);
1893
1911
  this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
1894
1912
  this._parseTag = function(tag) {
1895
1913
 
1896
- var match = this.tagRe.exec(tag);
1897
- var column = this.tagRe.lastIndex || 0;
1898
- this.tagRe.lastIndex = 0;
1914
+ var match = tag.match(this.tagRe);
1915
+ var column = 0;
1899
1916
 
1900
1917
  return {
1901
1918
  value: tag,
@@ -1915,7 +1932,7 @@ oop.inherits(FoldMode, BaseFoldMode);
1915
1932
  var start;
1916
1933
 
1917
1934
  do {
1918
- if (token.type.indexOf("meta.tag") === 0) {
1935
+ if (token.type.lastIndexOf("meta.tag", 0) === 0) {
1919
1936
  if (!start) {
1920
1937
  var start = {
1921
1938
  row: iterator.getCurrentTokenRow(),
@@ -1948,7 +1965,7 @@ oop.inherits(FoldMode, BaseFoldMode);
1948
1965
  var end;
1949
1966
 
1950
1967
  do {
1951
- if (token.type.indexOf("meta.tag") === 0) {
1968
+ if (token.type.lastIndexOf("meta.tag", 0) === 0) {
1952
1969
  if (!end) {
1953
1970
  end = {
1954
1971
  row: iterator.getCurrentTokenRow(),
@@ -2062,3 +2079,283 @@ oop.inherits(FoldMode, BaseFoldMode);
2062
2079
  }).call(FoldMode.prototype);
2063
2080
 
2064
2081
  });
2082
+
2083
+ define('ace/mode/html_completions', ['require', 'exports', 'module' , 'ace/token_iterator'], function(require, exports, module) {
2084
+
2085
+
2086
+ var TokenIterator = require("../token_iterator").TokenIterator;
2087
+
2088
+ var commonAttributes = [
2089
+ "accesskey",
2090
+ "class",
2091
+ "contenteditable",
2092
+ "contextmenu",
2093
+ "dir",
2094
+ "draggable",
2095
+ "dropzone",
2096
+ "hidden",
2097
+ "id",
2098
+ "lang",
2099
+ "spellcheck",
2100
+ "style",
2101
+ "tabindex",
2102
+ "title",
2103
+ "translate"
2104
+ ];
2105
+
2106
+ var eventAttributes = [
2107
+ "onabort",
2108
+ "onblur",
2109
+ "oncancel",
2110
+ "oncanplay",
2111
+ "oncanplaythrough",
2112
+ "onchange",
2113
+ "onclick",
2114
+ "onclose",
2115
+ "oncontextmenu",
2116
+ "oncuechange",
2117
+ "ondblclick",
2118
+ "ondrag",
2119
+ "ondragend",
2120
+ "ondragenter",
2121
+ "ondragleave",
2122
+ "ondragover",
2123
+ "ondragstart",
2124
+ "ondrop",
2125
+ "ondurationchange",
2126
+ "onemptied",
2127
+ "onended",
2128
+ "onerror",
2129
+ "onfocus",
2130
+ "oninput",
2131
+ "oninvalid",
2132
+ "onkeydown",
2133
+ "onkeypress",
2134
+ "onkeyup",
2135
+ "onload",
2136
+ "onloadeddata",
2137
+ "onloadedmetadata",
2138
+ "onloadstart",
2139
+ "onmousedown",
2140
+ "onmousemove",
2141
+ "onmouseout",
2142
+ "onmouseover",
2143
+ "onmouseup",
2144
+ "onmousewheel",
2145
+ "onpause",
2146
+ "onplay",
2147
+ "onplaying",
2148
+ "onprogress",
2149
+ "onratechange",
2150
+ "onreset",
2151
+ "onscroll",
2152
+ "onseeked",
2153
+ "onseeking",
2154
+ "onselect",
2155
+ "onshow",
2156
+ "onstalled",
2157
+ "onsubmit",
2158
+ "onsuspend",
2159
+ "ontimeupdate",
2160
+ "onvolumechange",
2161
+ "onwaiting"
2162
+ ];
2163
+
2164
+ var globalAttributes = commonAttributes.concat(eventAttributes);
2165
+
2166
+ var attributeMap = {
2167
+ "html": ["manifest"],
2168
+ "head": [],
2169
+ "title": [],
2170
+ "base": ["href", "target"],
2171
+ "link": ["href", "hreflang", "rel", "media", "type", "sizes"],
2172
+ "meta": ["http-equiv", "name", "content", "charset"],
2173
+ "style": ["type", "media", "scoped"],
2174
+ "script": ["charset", "type", "src", "defer", "async"],
2175
+ "noscript": ["href"],
2176
+ "body": ["onafterprint", "onbeforeprint", "onbeforeunload", "onhashchange", "onmessage", "onoffline", "onpopstate", "onredo", "onresize", "onstorage", "onundo", "onunload"],
2177
+ "section": [],
2178
+ "nav": [],
2179
+ "article": ["pubdate"],
2180
+ "aside": [],
2181
+ "h1": [],
2182
+ "h2": [],
2183
+ "h3": [],
2184
+ "h4": [],
2185
+ "h5": [],
2186
+ "h6": [],
2187
+ "header": [],
2188
+ "footer": [],
2189
+ "address": [],
2190
+ "main": [],
2191
+ "p": [],
2192
+ "hr": [],
2193
+ "pre": [],
2194
+ "blockquote": ["cite"],
2195
+ "ol": ["start", "reversed"],
2196
+ "ul": [],
2197
+ "li": ["value"],
2198
+ "dl": [],
2199
+ "dt": [],
2200
+ "dd": [],
2201
+ "figure": [],
2202
+ "figcaption": [],
2203
+ "div": [],
2204
+ "a": ["href", "target", "ping", "rel", "media", "hreflang", "type"],
2205
+ "em": [],
2206
+ "strong": [],
2207
+ "small": [],
2208
+ "s": [],
2209
+ "cite": [],
2210
+ "q": ["cite"],
2211
+ "dfn": [],
2212
+ "abbr": [],
2213
+ "data": [],
2214
+ "time": ["datetime"],
2215
+ "code": [],
2216
+ "var": [],
2217
+ "samp": [],
2218
+ "kbd": [],
2219
+ "sub": [],
2220
+ "sup": [],
2221
+ "i": [],
2222
+ "b": [],
2223
+ "u": [],
2224
+ "mark": [],
2225
+ "ruby": [],
2226
+ "rt": [],
2227
+ "rp": [],
2228
+ "bdi": [],
2229
+ "bdo": [],
2230
+ "span": [],
2231
+ "br": [],
2232
+ "wbr": [],
2233
+ "ins": ["cite", "datetime"],
2234
+ "del": ["cite", "datetime"],
2235
+ "img": ["alt", "src", "height", "width", "usemap", "ismap"],
2236
+ "iframe": ["name", "src", "height", "width", "sandbox", "seamless"],
2237
+ "embed": ["src", "height", "width", "type"],
2238
+ "object": ["param", "data", "type", "height" , "width", "usemap", "name", "form", "classid"],
2239
+ "param": ["name", "value"],
2240
+ "video": ["src", "autobuffer", "autoplay", "loop", "controls", "width", "height", "poster"],
2241
+ "audio": ["src", "autobuffer", "autoplay", "loop", "controls"],
2242
+ "source": ["src", "type", "media"],
2243
+ "track": ["kind", "src", "srclang", "label", "default"],
2244
+ "canvas": ["width", "height"],
2245
+ "map": ["name"],
2246
+ "area": ["shape", "coords", "href", "hreflang", "alt", "target", "media", "rel", "ping", "type"],
2247
+ "svg": [],
2248
+ "math": [],
2249
+ "table": ["summary"],
2250
+ "caption": [],
2251
+ "colgroup": ["span"],
2252
+ "col": ["span"],
2253
+ "tbody": [],
2254
+ "thead": [],
2255
+ "tfoot": [],
2256
+ "tr": [],
2257
+ "td": ["headers", "rowspan", "colspan"],
2258
+ "th": ["headers", "rowspan", "colspan", "scope"],
2259
+ "form": ["accept-charset", "action", "autocomplete", "enctype", "method", "name", "novalidate", "target"],
2260
+ "fieldset": ["disabled", "form", "name"],
2261
+ "legend": [],
2262
+ "label": ["form", "for"],
2263
+ "input": ["type", "accept", "alt", "autocomplete", "checked", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "height", "list", "max", "maxlength", "min", "multiple", "pattern", "placeholder", "readonly", "required", "size", "src", "step", "width", "files", "value"],
2264
+ "button": ["autofocus", "disabled", "form", "formaction", "formenctype", "formmethod", "formnovalidate", "formtarget", "name", "value", "type"],
2265
+ "select": ["autofocus", "disabled", "form", "multiple", "name", "size"],
2266
+ "datalist": [],
2267
+ "optgroup": ["disabled", "label"],
2268
+ "option": ["disabled", "selected", "label", "value"],
2269
+ "textarea": ["autofocus", "disabled", "form", "maxlength", "name", "placeholder", "readonly", "required", "rows", "cols", "wrap"],
2270
+ "keygen": ["autofocus", "challenge", "disabled", "form", "keytype", "name"],
2271
+ "output": ["for", "form", "name"],
2272
+ "progress": ["value", "max"],
2273
+ "meter": ["value", "min", "max", "low", "high", "optimum"],
2274
+ "details": ["open"],
2275
+ "summary": [],
2276
+ "command": ["type", "label", "icon", "disabled", "checked", "radiogroup", "command"],
2277
+ "menu": ["type", "label"],
2278
+ "dialog": ["open"]
2279
+ };
2280
+
2281
+ var allElements = Object.keys(attributeMap);
2282
+
2283
+ function hasType(token, type) {
2284
+ var tokenTypes = token.type.split('.');
2285
+ return type.split('.').every(function(type){
2286
+ return (tokenTypes.indexOf(type) !== -1);
2287
+ });
2288
+ }
2289
+
2290
+ function findTagName(session, pos) {
2291
+ var iterator = new TokenIterator(session, pos.row, pos.column);
2292
+ var token = iterator.getCurrentToken();
2293
+ if (!token || !hasType(token, 'tag') && !(hasType(token, 'text') && token.value.match('/'))){
2294
+ do {
2295
+ token = iterator.stepBackward();
2296
+ } while (token && (hasType(token, 'string') || hasType(token, 'operator') || hasType(token, 'attribute-name') || hasType(token, 'text')));
2297
+ }
2298
+ if (token && hasType(token, 'tag-name') && !iterator.stepBackward().value.match('/'))
2299
+ return token.value;
2300
+ }
2301
+
2302
+ var HtmlCompletions = function() {
2303
+
2304
+ };
2305
+
2306
+ (function() {
2307
+
2308
+ this.getCompletions = function(state, session, pos, prefix) {
2309
+ var token = session.getTokenAt(pos.row, pos.column);
2310
+
2311
+ if (!token)
2312
+ return [];
2313
+ if (hasType(token, "tag-name") || (token.value == '<' && hasType(token, "text")))
2314
+ return this.getTagCompletions(state, session, pos, prefix);
2315
+ if (hasType(token, 'text') || hasType(token, 'attribute-name'))
2316
+ return this.getAttributeCompetions(state, session, pos, prefix);
2317
+
2318
+ return [];
2319
+ };
2320
+
2321
+ this.getTagCompletions = function(state, session, pos, prefix) {
2322
+ var elements = allElements;
2323
+ if (prefix) {
2324
+ elements = elements.filter(function(element){
2325
+ return element.indexOf(prefix) === 0;
2326
+ });
2327
+ }
2328
+ return elements.map(function(element){
2329
+ return {
2330
+ value: element,
2331
+ meta: "tag"
2332
+ };
2333
+ });
2334
+ };
2335
+
2336
+ this.getAttributeCompetions = function(state, session, pos, prefix) {
2337
+ var tagName = findTagName(session, pos);
2338
+ if (!tagName)
2339
+ return [];
2340
+ var attributes = globalAttributes;
2341
+ if (tagName in attributeMap) {
2342
+ attributes = attributes.concat(attributeMap[tagName]);
2343
+ }
2344
+ if (prefix) {
2345
+ attributes = attributes.filter(function(attribute){
2346
+ return attribute.indexOf(prefix) === 0;
2347
+ });
2348
+ }
2349
+ return attributes.map(function(attribute){
2350
+ return {
2351
+ caption: attribute,
2352
+ snippet: attribute + '="$0"',
2353
+ meta: "attribute"
2354
+ };
2355
+ });
2356
+ };
2357
+
2358
+ }).call(HtmlCompletions.prototype);
2359
+
2360
+ exports.HtmlCompletions = HtmlCompletions;
2361
+ });