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,58 +1,56 @@
1
1
  /* ***** BEGIN LICENSE BLOCK *****
2
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
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
- * Colin Gourlay <colin DOT j DOT gourlay AT gmail DOT com>
24
- * Lee Gao
25
- * Tim Starling
26
- *
27
- * Alternatively, the contents of this file may be used under the terms of
28
- * either the GNU General Public License Version 2 or later (the "GPL"), or
29
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30
- * in which case the provisions of the GPL or the LGPL are applicable instead
31
- * of those above. If you wish to allow use of your version of this file only
32
- * under the terms of either the GPL or the LGPL, and not to allow others to
33
- * use your version of this file under the terms of the MPL, indicate your
34
- * decision by deleting the provisions above and replace them with the notice
35
- * and other provisions required by the GPL or the LGPL. If you do not delete
36
- * the provisions above, a recipient may use your version of this file under
37
- * the terms of any one of the MPL, the GPL or the LGPL.
38
- *
39
- * ***** END LICENSE BLOCK ***** */
40
-
41
- define('ace/mode/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/lua_highlight_rules', 'ace/range'], function(require, exports, module) {
2
+ * Distributed under the BSD license:
3
+ *
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.
28
+ *
29
+ * ***** END LICENSE BLOCK ***** */
30
+
31
+ define('ace/mode/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/lua_highlight_rules', 'ace/mode/folding/lua', 'ace/range', 'ace/worker/worker_client'], function(require, exports, module) {
42
32
 
43
33
 
44
34
  var oop = require("../lib/oop");
45
35
  var TextMode = require("./text").Mode;
46
36
  var Tokenizer = require("../tokenizer").Tokenizer;
47
37
  var LuaHighlightRules = require("./lua_highlight_rules").LuaHighlightRules;
38
+ var LuaFoldMode = require("./folding/lua").FoldMode;
48
39
  var Range = require("../range").Range;
40
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
49
41
 
50
42
  var Mode = function() {
51
- this.$tokenizer = new Tokenizer(new LuaHighlightRules().getRules());
43
+ this.HighlightRules = LuaHighlightRules;
44
+
45
+ this.foldingRules = new LuaFoldMode();
52
46
  };
53
47
  oop.inherits(Mode, TextMode);
54
48
 
55
49
  (function() {
50
+
51
+ this.lineCommentStart = "--";
52
+ this.blockComment = {start: "--[", end: "]--"};
53
+
56
54
  var indentKeywords = {
57
55
  "function": 1,
58
56
  "then": 1,
@@ -61,7 +59,7 @@ oop.inherits(Mode, TextMode);
61
59
  "elseif": 1,
62
60
  "repeat": 1,
63
61
  "end": -1,
64
- "until": -1,
62
+ "until": -1
65
63
  };
66
64
  var outdentKeywords = [
67
65
  "else",
@@ -72,9 +70,7 @@ oop.inherits(Mode, TextMode);
72
70
 
73
71
  function getNetIndentLevel(tokens) {
74
72
  var level = 0;
75
- // Support single-line blocks by decrementing the indent level if
76
- // an ending token is found
77
- for (var i in tokens){
73
+ for (var i = 0; i < tokens.length; i++) {
78
74
  var token = tokens[i];
79
75
  if (token.type == "keyword") {
80
76
  if (token.value in indentKeywords) {
@@ -86,8 +82,6 @@ oop.inherits(Mode, TextMode);
86
82
  level --;
87
83
  }
88
84
  }
89
- // Limit the level to +/- 1 since usually users only indent one level
90
- // at a time regardless of the logical nesting level
91
85
  if (level < 0) {
92
86
  return -1;
93
87
  } else if (level > 0) {
@@ -101,7 +95,7 @@ oop.inherits(Mode, TextMode);
101
95
  var indent = this.$getIndent(line);
102
96
  var level = 0;
103
97
 
104
- var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
98
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
105
99
  var tokens = tokenizedLine.tokens;
106
100
 
107
101
  if (state == "start") {
@@ -110,7 +104,6 @@ oop.inherits(Mode, TextMode);
110
104
  if (level > 0) {
111
105
  return indent + tab;
112
106
  } else if (level < 0 && indent.substr(indent.length - tab.length) == tab) {
113
- // Don't do a next-line outdent if we're going to do a real outdent of this line
114
107
  if (!this.checkOutdent(state, line, "\n")) {
115
108
  return indent.substr(0, indent.length - tab.length);
116
109
  }
@@ -125,7 +118,7 @@ oop.inherits(Mode, TextMode);
125
118
  if (line.match(/^\s*[\)\}\]]$/))
126
119
  return true;
127
120
 
128
- var tokens = this.$tokenizer.getLineTokens(line.trim(), state).tokens;
121
+ var tokens = this.getTokenizer().getLineTokens(line.trim(), state).tokens;
129
122
 
130
123
  if (!tokens || !tokens.length)
131
124
  return false;
@@ -136,42 +129,54 @@ oop.inherits(Mode, TextMode);
136
129
  this.autoOutdent = function(state, session, row) {
137
130
  var prevLine = session.getLine(row - 1);
138
131
  var prevIndent = this.$getIndent(prevLine).length;
139
- var prevTokens = this.$tokenizer.getLineTokens(prevLine, "start").tokens;
132
+ var prevTokens = this.getTokenizer().getLineTokens(prevLine, "start").tokens;
140
133
  var tabLength = session.getTabString().length;
141
134
  var expectedIndent = prevIndent + tabLength * getNetIndentLevel(prevTokens);
142
135
  var curIndent = this.$getIndent(session.getLine(row)).length;
143
136
  if (curIndent < expectedIndent) {
144
- // User already outdented //
145
137
  return;
146
138
  }
147
139
  session.outdentRows(new Range(row, 0, row + 2, 0));
148
140
  };
149
141
 
142
+ this.createWorker = function(session) {
143
+ var worker = new WorkerClient(["ace"], "ace/mode/lua_worker", "Worker");
144
+ worker.attachToDocument(session.getDocument());
145
+
146
+ worker.on("error", function(e) {
147
+ session.setAnnotations([e.data]);
148
+ });
149
+
150
+ worker.on("ok", function(e) {
151
+ session.clearAnnotations();
152
+ });
153
+
154
+ return worker;
155
+ };
156
+
157
+ this.$id = "ace/mode/lua";
150
158
  }).call(Mode.prototype);
151
159
 
152
160
  exports.Mode = Mode;
153
161
  });
154
162
 
155
- define('ace/mode/lua_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
163
+ define('ace/mode/lua_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
156
164
 
157
165
 
158
166
  var oop = require("../lib/oop");
159
- var lang = require("../lib/lang");
160
167
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
161
168
 
162
169
  var LuaHighlightRules = function() {
163
170
 
164
- var keywords = lang.arrayToMap(
165
- ("break|do|else|elseif|end|for|function|if|in|local|repeat|"+
166
- "return|then|until|while|or|and|not").split("|")
171
+ var keywords = (
172
+ "break|do|else|elseif|end|for|function|if|in|local|repeat|"+
173
+ "return|then|until|while|or|and|not"
167
174
  );
168
175
 
169
- var builtinConstants = lang.arrayToMap(
170
- ("true|false|nil|_G|_VERSION").split("|")
171
- );
176
+ var builtinConstants = ("true|false|nil|_G|_VERSION");
172
177
 
173
- var builtinFunctions = lang.arrayToMap(
174
- ("string|xpcall|package|tostring|print|os|unpack|require|"+
178
+ var functions = (
179
+ "string|xpcall|package|tostring|print|os|unpack|require|"+
175
180
  "getfenv|setmetatable|next|assert|tonumber|io|rawequal|"+
176
181
  "collectgarbage|getmetatable|module|rawset|math|debug|"+
177
182
  "pcall|table|newproxy|type|coroutine|_G|select|gcinfo|"+
@@ -190,27 +195,26 @@ var LuaHighlightRules = function() {
190
195
  "gethook|setmetatable|setlocal|traceback|setfenv|getinfo|"+
191
196
  "setupvalue|getlocal|getregistry|getfenv|setn|insert|getn|"+
192
197
  "foreachi|maxn|foreach|concat|sort|remove|resume|yield|"+
193
- "status|wrap|create|running").split("|")
194
- );
195
-
196
- var stdLibaries = lang.arrayToMap(
197
- ("string|package|os|io|math|debug|table|coroutine").split("|")
198
- );
199
-
200
- var metatableMethods = lang.arrayToMap(
201
- ("__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+
202
- "__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber").split("|")
198
+ "status|wrap|create|running|"+
199
+ "__add|__sub|__mod|__unm|__concat|__lt|__index|__call|__gc|__metatable|"+
200
+ "__mul|__div|__pow|__len|__eq|__le|__newindex|__tostring|__mode|__tonumber"
203
201
  );
204
202
 
205
- var futureReserved = lang.arrayToMap(
206
- ("").split("|")
207
- );
208
-
209
- var deprecatedIn5152 = lang.arrayToMap(
210
- ("setn|foreach|foreachi|gcinfo|log10|maxn").split("|")
211
- );
203
+ var stdLibaries = ("string|package|os|io|math|debug|table|coroutine");
204
+
205
+ var futureReserved = "";
212
206
 
213
- var strPre = "";
207
+ var deprecatedIn5152 = ("setn|foreach|foreachi|gcinfo|log10|maxn");
208
+
209
+ var keywordMapper = this.createKeywordMapper({
210
+ "keyword": keywords,
211
+ "support.function": functions,
212
+ "invalid.deprecated": deprecatedIn5152,
213
+ "constant.library": stdLibaries,
214
+ "constant.language": builtinConstants,
215
+ "invalid.illegal": futureReserved,
216
+ "variable.language": "this"
217
+ }, "identifier");
214
218
 
215
219
  var decimalInteger = "(?:(?:[1-9]\\d*)|(?:0))";
216
220
  var hexInteger = "(?:0[xX][\\dA-Fa-f]+)";
@@ -220,151 +224,72 @@ var LuaHighlightRules = function() {
220
224
  var intPart = "(?:\\d+)";
221
225
  var pointFloat = "(?:(?:" + intPart + "?" + fraction + ")|(?:" + intPart + "\\.))";
222
226
  var floatNumber = "(?:" + pointFloat + ")";
223
-
224
- var comment_stack = [];
225
-
226
- this.$rules = {
227
- "start" :
228
227
 
229
-
230
- // bracketed comments
231
- [{
232
- token : "comment", // --[[ comment
233
- regex : strPre + '\\-\\-\\[\\[.*\\]\\]'
234
- }, {
235
- token : "comment", // --[=[ comment
236
- regex : strPre + '\\-\\-\\[\\=\\[.*\\]\\=\\]'
237
- }, {
238
- token : "comment", // --[==[ comment
239
- regex : strPre + '\\-\\-\\[\\={2}\\[.*\\]\\={2}\\]'
240
- }, {
241
- token : "comment", // --[===[ comment
242
- regex : strPre + '\\-\\-\\[\\={3}\\[.*\\]\\={3}\\]'
243
- }, {
244
- token : "comment", // --[====[ comment
245
- regex : strPre + '\\-\\-\\[\\={4}\\[.*\\]\\={4}\\]'
246
- }, {
247
- token : "comment", // --[====+[ comment
248
- regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
249
- },
250
-
251
- // multiline bracketed comments
252
- {
253
- token : "comment", // --[[ comment
254
- regex : strPre + '\\-\\-\\[\\[.*$',
255
- merge : true,
256
- next : "qcomment"
257
- }, {
258
- token : "comment", // --[=[ comment
259
- regex : strPre + '\\-\\-\\[\\=\\[.*$',
260
- merge : true,
261
- next : "qcomment1"
262
- }, {
263
- token : "comment", // --[==[ comment
264
- regex : strPre + '\\-\\-\\[\\={2}\\[.*$',
265
- merge : true,
266
- next : "qcomment2"
267
- }, {
268
- token : "comment", // --[===[ comment
269
- regex : strPre + '\\-\\-\\[\\={3}\\[.*$',
270
- merge : true,
271
- next : "qcomment3"
272
- }, {
273
- token : "comment", // --[====[ comment
274
- regex : strPre + '\\-\\-\\[\\={4}\\[.*$',
275
- merge : true,
276
- next : "qcomment4"
277
- }, {
278
- token : function(value){ // --[====+[ comment
279
- // WARNING: EXTREMELY SLOW, but this is the only way to circumvent the
280
- // limits imposed by the current automaton.
281
- // I've never personally seen any practical code where 5 or more '='s are
282
- // used for string or commenting, so this will rarely be invoked.
283
- var pattern = /\-\-\[(\=+)\[/, match;
284
- // you can never be too paranoid ;)
285
- if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
286
- comment_stack.push(match.length);
287
-
228
+ this.$rules = {
229
+ "start" : [{
230
+ stateName: "bracketedComment",
231
+ onMatch : function(value, currentState, stack){
232
+ stack.unshift(this.next, value.length - 2, currentState);
288
233
  return "comment";
289
234
  },
290
- regex : strPre + '\\-\\-\\[\\={5}\\=*\\[.*$',
291
- merge : true,
292
- next : "qcomment5"
235
+ regex : /\-\-\[=*\[/,
236
+ next : [
237
+ {
238
+ onMatch : function(value, currentState, stack) {
239
+ if (value.length == stack[1]) {
240
+ stack.shift();
241
+ stack.shift();
242
+ this.next = stack.shift();
243
+ } else {
244
+ this.next = "";
245
+ }
246
+ return "comment";
247
+ },
248
+ regex : /\]=*\]/,
249
+ next : "start"
250
+ }, {
251
+ defaultToken : "comment"
252
+ }
253
+ ]
293
254
  },
294
-
295
- // single line comments
255
+
296
256
  {
297
257
  token : "comment",
298
258
  regex : "\\-\\-.*$"
299
- },
300
-
301
- // bracketed strings
302
- {
303
- token : "string", // [[ string
304
- regex : strPre + '\\[\\[.*\\]\\]'
305
- }, {
306
- token : "string", // [=[ string
307
- regex : strPre + '\\[\\=\\[.*\\]\\=\\]'
308
- }, {
309
- token : "string", // [==[ string
310
- regex : strPre + '\\[\\={2}\\[.*\\]\\={2}\\]'
311
- }, {
312
- token : "string", // [===[ string
313
- regex : strPre + '\\[\\={3}\\[.*\\]\\={3}\\]'
314
- }, {
315
- token : "string", // [====[ string
316
- regex : strPre + '\\[\\={4}\\[.*\\]\\={4}\\]'
317
- }, {
318
- token : "string", // [====+[ string
319
- regex : strPre + '\\[\\={5}\\=*\\[.*\\]\\={5}\\=*\\]'
320
259
  },
321
-
322
- // multiline bracketed strings
323
260
  {
324
- token : "string", // [[ string
325
- regex : strPre + '\\[\\[.*$',
326
- merge : true,
327
- next : "qstring"
328
- }, {
329
- token : "string", // [=[ string
330
- regex : strPre + '\\[\\=\\[.*$',
331
- merge : true,
332
- next : "qstring1"
333
- }, {
334
- token : "string", // [==[ string
335
- regex : strPre + '\\[\\={2}\\[.*$',
336
- merge : true,
337
- next : "qstring2"
338
- }, {
339
- token : "string", // [===[ string
340
- regex : strPre + '\\[\\={3}\\[.*$',
341
- merge : true,
342
- next : "qstring3"
343
- }, {
344
- token : "string", // [====[ string
345
- regex : strPre + '\\[\\={4}\\[.*$',
346
- merge : true,
347
- next : "qstring4"
348
- }, {
349
- token : function(value){ // --[====+[ string
350
- // WARNING: EXTREMELY SLOW, see above.
351
- var pattern = /\[(\=+)\[/, match;
352
- if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined)
353
- comment_stack.push(match.length);
354
-
355
- return "string";
261
+ stateName: "bracketedString",
262
+ onMatch : function(value, currentState, stack){
263
+ stack.unshift(this.next, value.length, currentState);
264
+ return "comment";
356
265
  },
357
- regex : strPre + '\\[\\={5}\\=*\\[.*$',
358
- merge : true,
359
- next : "qstring5"
360
- },
361
-
266
+ regex : /\[=*\[/,
267
+ next : [
268
+ {
269
+ onMatch : function(value, currentState, stack) {
270
+ if (value.length == stack[1]) {
271
+ stack.shift();
272
+ stack.shift();
273
+ this.next = stack.shift();
274
+ } else {
275
+ this.next = "";
276
+ }
277
+ return "comment";
278
+ },
279
+
280
+ regex : /\]=*\]/,
281
+ next : "start"
282
+ }, {
283
+ defaultToken : "comment"
284
+ }
285
+ ]
286
+ },
362
287
  {
363
288
  token : "string", // " string
364
- regex : strPre + '"(?:[^\\\\]|\\\\.)*?"'
289
+ regex : '"(?:[^\\\\]|\\\\.)*?"'
365
290
  }, {
366
291
  token : "string", // ' string
367
- regex : strPre + "'(?:[^\\\\]|\\\\.)*?'"
292
+ regex : "'(?:[^\\\\]|\\\\.)*?'"
368
293
  }, {
369
294
  token : "constant.numeric", // float
370
295
  regex : floatNumber
@@ -372,24 +297,7 @@ var LuaHighlightRules = function() {
372
297
  token : "constant.numeric", // integer
373
298
  regex : integer + "\\b"
374
299
  }, {
375
- token : function(value) {
376
- if (keywords.hasOwnProperty(value))
377
- return "keyword";
378
- else if (builtinConstants.hasOwnProperty(value))
379
- return "constant.language";
380
- else if (futureReserved.hasOwnProperty(value))
381
- return "invalid.illegal";
382
- else if (stdLibaries.hasOwnProperty(value))
383
- return "constant.library";
384
- else if (deprecatedIn5152.hasOwnProperty(value))
385
- return "invalid.deprecated";
386
- else if (builtinFunctions.hasOwnProperty(value))
387
- return "support.function";
388
- else if (metatableMethods.hasOwnProperty(value))
389
- return "support.function";
390
- else
391
- return "identifier";
392
- },
300
+ token : keywordMapper,
393
301
  regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
394
302
  }, {
395
303
  token : "keyword.operator",
@@ -402,150 +310,148 @@ var LuaHighlightRules = function() {
402
310
  regex : "[\\]\\)\\}]"
403
311
  }, {
404
312
  token : "text",
405
- regex : "\\s+"
406
- } ],
407
-
408
- "qcomment": [ {
409
- token : "comment",
410
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
411
- next : "start"
412
- }, {
413
- token : "comment",
414
- merge : true,
415
- regex : '.+'
416
- } ],
417
- "qcomment1": [ {
418
- token : "comment",
419
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]",
420
- next : "start"
421
- }, {
422
- token : "comment",
423
- merge : true,
424
- regex : '.+'
425
- } ],
426
- "qcomment2": [ {
427
- token : "comment",
428
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",
429
- next : "start"
430
- }, {
431
- token : "comment",
432
- merge : true,
433
- regex : '.+'
434
- } ],
435
- "qcomment3": [ {
436
- token : "comment",
437
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",
438
- next : "start"
439
- }, {
440
- token : "comment",
441
- merge : true,
442
- regex : '.+'
443
- } ],
444
- "qcomment4": [ {
445
- token : "comment",
446
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",
447
- next : "start"
448
- }, {
449
- token : "comment",
450
- merge : true,
451
- regex : '.+'
452
- } ],
453
- "qcomment5": [ {
454
- token : function(value){
455
- // very hackish, mutates the qcomment5 field on the fly.
456
- var pattern = /\](\=+)\]/, rule = this.rules.qcomment5[0], match;
457
- rule.next = "start";
458
- if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){
459
- var found = match.length, expected;
460
- if ((expected = comment_stack.pop()) != found){
461
- comment_stack.push(expected);
462
- rule.next = "qcomment5";
463
- }
464
- }
465
-
466
- return "comment";
467
- },
468
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
469
- next : "start"
470
- }, {
471
- token : "comment",
472
- merge : true,
473
- regex : '.+'
474
- } ],
475
-
476
- "qstring": [ {
477
- token : "string",
478
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\]",
479
- next : "start"
480
- }, {
481
- token : "string",
482
- merge : true,
483
- regex : '.+'
484
- } ],
485
- "qstring1": [ {
486
- token : "string",
487
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\=\\]",
488
- next : "start"
489
- }, {
490
- token : "string",
491
- merge : true,
492
- regex : '.+'
493
- } ],
494
- "qstring2": [ {
495
- token : "string",
496
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={2}\\]",
497
- next : "start"
498
- }, {
499
- token : "string",
500
- merge : true,
501
- regex : '.+'
502
- } ],
503
- "qstring3": [ {
504
- token : "string",
505
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={3}\\]",
506
- next : "start"
507
- }, {
508
- token : "string",
509
- merge : true,
510
- regex : '.+'
511
- } ],
512
- "qstring4": [ {
513
- token : "string",
514
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={4}\\]",
515
- next : "start"
516
- }, {
517
- token : "string",
518
- merge : true,
519
- regex : '.+'
520
- } ],
521
- "qstring5": [ {
522
- token : function(value){
523
- // very hackish, mutates the qstring5 field on the fly.
524
- var pattern = /\](\=+)\]/, rule = this.rules.qstring5[0], match;
525
- rule.next = "start";
526
- if ((match = pattern.exec(value)) != null && (match = match[1]) != undefined){
527
- var found = match.length, expected;
528
- if ((expected = comment_stack.pop()) != found){
529
- comment_stack.push(expected);
530
- rule.next = "qstring5";
531
- }
532
- }
533
-
534
- return "string";
535
- },
536
- regex : "(?:[^\\\\]|\\\\.)*?\\]\\={5}\\=*\\]",
537
- next : "start"
538
- }, {
539
- token : "string",
540
- merge : true,
541
- regex : '.+'
313
+ regex : "\\s+|\\w+"
542
314
  } ]
543
-
544
315
  };
545
-
316
+
317
+ this.normalizeRules();
546
318
  }
547
319
 
548
320
  oop.inherits(LuaHighlightRules, TextHighlightRules);
549
321
 
550
322
  exports.LuaHighlightRules = LuaHighlightRules;
551
323
  });
324
+
325
+ define('ace/mode/folding/lua', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range', 'ace/token_iterator'], function(require, exports, module) {
326
+
327
+
328
+ var oop = require("../../lib/oop");
329
+ var BaseFoldMode = require("./fold_mode").FoldMode;
330
+ var Range = require("../../range").Range;
331
+ var TokenIterator = require("../../token_iterator").TokenIterator;
332
+
333
+
334
+ var FoldMode = exports.FoldMode = function() {};
335
+
336
+ oop.inherits(FoldMode, BaseFoldMode);
337
+
338
+ (function() {
339
+
340
+ this.foldingStartMarker = /\b(function|then|do|repeat)\b|{\s*$|(\[=*\[)/;
341
+ this.foldingStopMarker = /\bend\b|^\s*}|\]=*\]/;
342
+
343
+ this.getFoldWidget = function(session, foldStyle, row) {
344
+ var line = session.getLine(row);
345
+ var isStart = this.foldingStartMarker.test(line);
346
+ var isEnd = this.foldingStopMarker.test(line);
347
+
348
+ if (isStart && !isEnd) {
349
+ var match = line.match(this.foldingStartMarker);
350
+ if (match[1] == "then" && /\belseif\b/.test(line))
351
+ return;
352
+ if (match[1]) {
353
+ if (session.getTokenAt(row, match.index + 1).type === "keyword")
354
+ return "start";
355
+ } else if (match[2]) {
356
+ var type = session.bgTokenizer.getState(row) || "";
357
+ if (type[0] == "bracketedComment" || type[0] == "bracketedString")
358
+ return "start";
359
+ } else {
360
+ return "start";
361
+ }
362
+ }
363
+ if (foldStyle != "markbeginend" || !isEnd || isStart && isEnd)
364
+ return "";
365
+
366
+ var match = line.match(this.foldingStopMarker);
367
+ if (match[0] === "end") {
368
+ if (session.getTokenAt(row, match.index + 1).type === "keyword")
369
+ return "end";
370
+ } else if (match[0][0] === "]") {
371
+ var type = session.bgTokenizer.getState(row - 1) || "";
372
+ if (type[0] == "bracketedComment" || type[0] == "bracketedString")
373
+ return "end";
374
+ } else
375
+ return "end";
376
+ };
377
+
378
+ this.getFoldWidgetRange = function(session, foldStyle, row) {
379
+ var line = session.doc.getLine(row);
380
+ var match = this.foldingStartMarker.exec(line);
381
+ if (match) {
382
+ if (match[1])
383
+ return this.luaBlock(session, row, match.index + 1);
384
+
385
+ if (match[2])
386
+ return session.getCommentFoldRange(row, match.index + 1);
387
+
388
+ return this.openingBracketBlock(session, "{", row, match.index);
389
+ }
390
+
391
+ var match = this.foldingStopMarker.exec(line);
392
+ if (match) {
393
+ if (match[0] === "end") {
394
+ if (session.getTokenAt(row, match.index + 1).type === "keyword")
395
+ return this.luaBlock(session, row, match.index + 1);
396
+ }
397
+
398
+ if (match[0][0] === "]")
399
+ return session.getCommentFoldRange(row, match.index + 1);
400
+
401
+ return this.closingBracketBlock(session, "}", row, match.index + match[0].length);
402
+ }
403
+ };
404
+
405
+ this.luaBlock = function(session, row, column) {
406
+ var stream = new TokenIterator(session, row, column);
407
+ var indentKeywords = {
408
+ "function": 1,
409
+ "do": 1,
410
+ "then": 1,
411
+ "elseif": -1,
412
+ "end": -1,
413
+ "repeat": 1,
414
+ "until": -1
415
+ };
416
+
417
+ var token = stream.getCurrentToken();
418
+ if (!token || token.type != "keyword")
419
+ return;
420
+
421
+ var val = token.value;
422
+ var stack = [val];
423
+ var dir = indentKeywords[val];
424
+
425
+ if (!dir)
426
+ return;
427
+
428
+ var startColumn = dir === -1 ? stream.getCurrentTokenColumn() : session.getLine(row).length;
429
+ var startRow = row;
430
+
431
+ stream.step = dir === -1 ? stream.stepBackward : stream.stepForward;
432
+ while(token = stream.step()) {
433
+ if (token.type !== "keyword")
434
+ continue;
435
+ var level = dir * indentKeywords[token.value];
436
+
437
+ if (level > 0) {
438
+ stack.unshift(token.value);
439
+ } else if (level <= 0) {
440
+ stack.shift();
441
+ if (!stack.length && token.value != "elseif")
442
+ break;
443
+ if (level === 0)
444
+ stack.unshift(token.value);
445
+ }
446
+ }
447
+
448
+ var row = stream.getCurrentTokenRow();
449
+ if (dir === -1)
450
+ return new Range(row, session.getLine(row).length, startRow, startColumn);
451
+ else
452
+ return new Range(startRow, startColumn, row, stream.getCurrentTokenColumn());
453
+ };
454
+
455
+ }).call(FoldMode.prototype);
456
+
457
+ });