ace-rails-ap 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (301) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -4
  3. data/lib/ace/rails/version.rb +1 -1
  4. data/vendor/assets/javascripts/ace/ace.js +14194 -13349
  5. data/vendor/assets/javascripts/ace/ext-beautify.js +335 -0
  6. data/vendor/assets/javascripts/ace/ext-chromevox.js +6 -1
  7. data/vendor/assets/javascripts/ace/ext-elastic_tabstops_lite.js +8 -33
  8. data/vendor/assets/javascripts/ace/ext-emmet.js +487 -424
  9. data/vendor/assets/javascripts/ace/ext-error_marker.js +6 -0
  10. data/vendor/assets/javascripts/ace/ext-keybinding_menu.js +45 -72
  11. data/vendor/assets/javascripts/ace/ext-language_tools.js +734 -578
  12. data/vendor/assets/javascripts/ace/ext-linking.js +53 -0
  13. data/vendor/assets/javascripts/ace/ext-modelist.js +25 -10
  14. data/vendor/assets/javascripts/ace/ext-old_ie.js +93 -120
  15. data/vendor/assets/javascripts/ace/ext-searchbox.js +8 -41
  16. data/vendor/assets/javascripts/ace/ext-settings_menu.js +229 -234
  17. data/vendor/assets/javascripts/ace/ext-spellcheck.js +7 -3
  18. data/vendor/assets/javascripts/ace/ext-split.js +13 -37
  19. data/vendor/assets/javascripts/ace/ext-static_highlight.js +16 -39
  20. data/vendor/assets/javascripts/ace/ext-statusbar.js +8 -2
  21. data/vendor/assets/javascripts/ace/ext-textarea.js +254 -99
  22. data/vendor/assets/javascripts/ace/ext-themelist.js +13 -40
  23. data/vendor/assets/javascripts/ace/ext-whitespace.js +17 -41
  24. data/vendor/assets/javascripts/ace/keybinding-emacs.js +803 -788
  25. data/vendor/assets/javascripts/ace/keybinding-vim.js +1559 -1560
  26. data/vendor/assets/javascripts/ace/mode-abap.js +52 -83
  27. data/vendor/assets/javascripts/ace/mode-actionscript.js +27 -63
  28. data/vendor/assets/javascripts/ace/mode-ada.js +27 -58
  29. data/vendor/assets/javascripts/ace/mode-apache_conf.js +310 -0
  30. data/vendor/assets/javascripts/ace/mode-applescript.js +226 -0
  31. data/vendor/assets/javascripts/ace/mode-asciidoc.js +39 -70
  32. data/vendor/assets/javascripts/ace/mode-assembly_x86.js +26 -58
  33. data/vendor/assets/javascripts/ace/mode-autohotkey.js +27 -63
  34. data/vendor/assets/javascripts/ace/mode-batchfile.js +27 -63
  35. data/vendor/assets/javascripts/ace/mode-c9search.js +92 -112
  36. data/vendor/assets/javascripts/ace/mode-c_cpp.js +224 -223
  37. data/vendor/assets/javascripts/ace/mode-cirru.js +202 -0
  38. data/vendor/assets/javascripts/ace/mode-clojure.js +98 -92
  39. data/vendor/assets/javascripts/ace/mode-cobol.js +27 -58
  40. data/vendor/assets/javascripts/ace/mode-coffee.js +90 -122
  41. data/vendor/assets/javascripts/ace/mode-coldfusion.js +1908 -1464
  42. data/vendor/assets/javascripts/ace/mode-csharp.js +291 -264
  43. data/vendor/assets/javascripts/ace/mode-css.js +266 -267
  44. data/vendor/assets/javascripts/ace/mode-curly.js +796 -815
  45. data/vendor/assets/javascripts/ace/mode-d.js +64 -95
  46. data/vendor/assets/javascripts/ace/mode-dart.js +254 -256
  47. data/vendor/assets/javascripts/ace/mode-diff.js +27 -58
  48. data/vendor/assets/javascripts/ace/mode-django.js +856 -866
  49. data/vendor/assets/javascripts/ace/mode-dockerfile.js +759 -0
  50. data/vendor/assets/javascripts/ace/mode-dot.js +106 -106
  51. data/vendor/assets/javascripts/ace/mode-eiffel.js +135 -0
  52. data/vendor/assets/javascripts/ace/mode-ejs.js +931 -938
  53. data/vendor/assets/javascripts/ace/mode-erlang.js +27 -58
  54. data/vendor/assets/javascripts/ace/mode-forth.js +27 -63
  55. data/vendor/assets/javascripts/ace/mode-ftl.js +457 -508
  56. data/vendor/assets/javascripts/ace/mode-gcode.js +85 -0
  57. data/vendor/assets/javascripts/ace/mode-gherkin.js +129 -0
  58. data/vendor/assets/javascripts/ace/mode-gitignore.js +50 -0
  59. data/vendor/assets/javascripts/ace/mode-glsl.js +252 -248
  60. data/vendor/assets/javascripts/ace/mode-golang.js +206 -179
  61. data/vendor/assets/javascripts/ace/mode-groovy.js +310 -242
  62. data/vendor/assets/javascripts/ace/mode-haml.js +156 -190
  63. data/vendor/assets/javascripts/ace/mode-handlebars.js +815 -784
  64. data/vendor/assets/javascripts/ace/mode-haskell.js +27 -63
  65. data/vendor/assets/javascripts/ace/mode-haxe.js +206 -176
  66. data/vendor/assets/javascripts/ace/mode-html.js +779 -792
  67. data/vendor/assets/javascripts/ace/mode-html_ruby.js +916 -923
  68. data/vendor/assets/javascripts/ace/mode-ini.js +27 -58
  69. data/vendor/assets/javascripts/ace/mode-io.js +201 -0
  70. data/vendor/assets/javascripts/ace/mode-jack.js +169 -170
  71. data/vendor/assets/javascripts/ace/mode-jade.js +722 -774
  72. data/vendor/assets/javascripts/ace/mode-java.js +310 -245
  73. data/vendor/assets/javascripts/ace/mode-javascript.js +285 -247
  74. data/vendor/assets/javascripts/ace/mode-json.js +183 -184
  75. data/vendor/assets/javascripts/ace/mode-jsoniq.js +3211 -1274
  76. data/vendor/assets/javascripts/ace/mode-jsp.js +481 -504
  77. data/vendor/assets/javascripts/ace/mode-jsx.js +206 -176
  78. data/vendor/assets/javascripts/ace/mode-julia.js +33 -69
  79. data/vendor/assets/javascripts/ace/mode-latex.js +74 -41
  80. data/vendor/assets/javascripts/ace/mode-less.js +250 -251
  81. data/vendor/assets/javascripts/ace/mode-liquid.js +424 -475
  82. data/vendor/assets/javascripts/ace/mode-lisp.js +24 -57
  83. data/vendor/assets/javascripts/ace/mode-livescript.js +42 -41
  84. data/vendor/assets/javascripts/ace/mode-logiql.js +229 -230
  85. data/vendor/assets/javascripts/ace/mode-lsl.js +200 -441
  86. data/vendor/assets/javascripts/ace/mode-lua.js +136 -167
  87. data/vendor/assets/javascripts/ace/mode-luapage.js +904 -884
  88. data/vendor/assets/javascripts/ace/mode-lucene.js +22 -17
  89. data/vendor/assets/javascripts/ace/mode-makefile.js +162 -137
  90. data/vendor/assets/javascripts/ace/mode-markdown.js +846 -854
  91. data/vendor/assets/javascripts/ace/mode-matlab.js +98 -72
  92. data/vendor/assets/javascripts/ace/mode-mel.js +569 -0
  93. data/vendor/assets/javascripts/ace/mode-mushcode.js +84 -115
  94. data/vendor/assets/javascripts/ace/mode-mysql.js +49 -80
  95. data/vendor/assets/javascripts/ace/mode-nix.js +252 -256
  96. data/vendor/assets/javascripts/ace/mode-objectivec.js +242 -274
  97. data/vendor/assets/javascripts/ace/mode-ocaml.js +71 -102
  98. data/vendor/assets/javascripts/ace/mode-pascal.js +32 -68
  99. data/vendor/assets/javascripts/ace/mode-perl.js +67 -98
  100. data/vendor/assets/javascripts/ace/mode-pgsql.js +990 -982
  101. data/vendor/assets/javascripts/ace/mode-php.js +1878 -1900
  102. data/vendor/assets/javascripts/ace/mode-plain_text.js +3 -34
  103. data/vendor/assets/javascripts/ace/mode-powershell.js +181 -151
  104. data/vendor/assets/javascripts/ace/mode-praat.js +418 -0
  105. data/vendor/assets/javascripts/ace/mode-prolog.js +27 -63
  106. data/vendor/assets/javascripts/ace/mode-properties.js +20 -48
  107. data/vendor/assets/javascripts/ace/mode-protobuf.js +252 -259
  108. data/vendor/assets/javascripts/ace/mode-python.js +84 -115
  109. data/vendor/assets/javascripts/ace/mode-r.js +105 -140
  110. data/vendor/assets/javascripts/ace/mode-rdoc.js +84 -89
  111. data/vendor/assets/javascripts/ace/mode-rhtml.js +892 -908
  112. data/vendor/assets/javascripts/ace/mode-ruby.js +434 -98
  113. data/vendor/assets/javascripts/ace/mode-rust.js +27 -63
  114. data/vendor/assets/javascripts/ace/mode-sass.js +75 -106
  115. data/vendor/assets/javascripts/ace/mode-scad.js +219 -220
  116. data/vendor/assets/javascripts/ace/mode-scala.js +311 -243
  117. data/vendor/assets/javascripts/ace/mode-scheme.js +24 -60
  118. data/vendor/assets/javascripts/ace/mode-scss.js +250 -251
  119. data/vendor/assets/javascripts/ace/mode-sh.js +506 -118
  120. data/vendor/assets/javascripts/ace/mode-sjs.js +314 -280
  121. data/vendor/assets/javascripts/ace/mode-smarty.js +2474 -0
  122. data/vendor/assets/javascripts/ace/mode-snippets.js +89 -89
  123. data/vendor/assets/javascripts/ace/mode-soy_template.js +792 -811
  124. data/vendor/assets/javascripts/ace/mode-space.js +22 -23
  125. data/vendor/assets/javascripts/ace/mode-sql.js +31 -58
  126. data/vendor/assets/javascripts/ace/mode-stylus.js +161 -197
  127. data/vendor/assets/javascripts/ace/mode-svg.js +906 -836
  128. data/vendor/assets/javascripts/ace/mode-tcl.js +61 -92
  129. data/vendor/assets/javascripts/ace/mode-tex.js +36 -73
  130. data/vendor/assets/javascripts/ace/mode-text.js +1 -0
  131. data/vendor/assets/javascripts/ace/mode-textile.js +41 -72
  132. data/vendor/assets/javascripts/ace/mode-toml.js +26 -62
  133. data/vendor/assets/javascripts/ace/mode-twig.js +1196 -892
  134. data/vendor/assets/javascripts/ace/mode-typescript.js +313 -277
  135. data/vendor/assets/javascripts/ace/mode-vala.js +982 -0
  136. data/vendor/assets/javascripts/ace/mode-vbscript.js +25 -62
  137. data/vendor/assets/javascripts/ace/mode-velocity.js +2251 -1242
  138. data/vendor/assets/javascripts/ace/mode-verilog.js +27 -59
  139. data/vendor/assets/javascripts/ace/mode-vhdl.js +26 -55
  140. data/vendor/assets/javascripts/ace/mode-xml.js +319 -644
  141. data/vendor/assets/javascripts/ace/mode-xquery.js +2503 -588
  142. data/vendor/assets/javascripts/ace/mode-yaml.js +56 -90
  143. data/vendor/assets/javascripts/ace/snippets/abap.js +7 -0
  144. data/vendor/assets/javascripts/ace/snippets/actionscript.js +159 -0
  145. data/vendor/assets/javascripts/ace/snippets/ada.js +7 -0
  146. data/vendor/assets/javascripts/ace/snippets/apache_conf.js +7 -0
  147. data/vendor/assets/javascripts/ace/snippets/applescript.js +7 -0
  148. data/vendor/assets/javascripts/ace/snippets/asciidoc.js +7 -0
  149. data/vendor/assets/javascripts/ace/snippets/assembly_x86.js +7 -0
  150. data/vendor/assets/javascripts/ace/snippets/autohotkey.js +7 -0
  151. data/vendor/assets/javascripts/ace/snippets/batchfile.js +7 -0
  152. data/vendor/assets/javascripts/ace/snippets/c9search.js +7 -0
  153. data/vendor/assets/javascripts/ace/snippets/c_cpp.js +138 -0
  154. data/vendor/assets/javascripts/ace/snippets/cirru.js +7 -0
  155. data/vendor/assets/javascripts/ace/snippets/clojure.js +97 -0
  156. data/vendor/assets/javascripts/ace/snippets/cobol.js +7 -0
  157. data/vendor/assets/javascripts/ace/snippets/coffee.js +102 -0
  158. data/vendor/assets/javascripts/ace/snippets/coldfusion.js +7 -0
  159. data/vendor/assets/javascripts/ace/snippets/csharp.js +7 -0
  160. data/vendor/assets/javascripts/ace/snippets/css.js +974 -0
  161. data/vendor/assets/javascripts/ace/snippets/curly.js +7 -0
  162. data/vendor/assets/javascripts/ace/snippets/d.js +7 -0
  163. data/vendor/assets/javascripts/ace/snippets/dart.js +90 -0
  164. data/vendor/assets/javascripts/ace/snippets/diff.js +18 -0
  165. data/vendor/assets/javascripts/ace/snippets/django.js +115 -0
  166. data/vendor/assets/javascripts/ace/snippets/dockerfile.js +7 -0
  167. data/vendor/assets/javascripts/ace/snippets/dot.js +7 -0
  168. data/vendor/assets/javascripts/ace/snippets/eiffel.js +7 -0
  169. data/vendor/assets/javascripts/ace/snippets/ejs.js +7 -0
  170. data/vendor/assets/javascripts/ace/snippets/erlang.js +167 -0
  171. data/vendor/assets/javascripts/ace/snippets/forth.js +7 -0
  172. data/vendor/assets/javascripts/ace/snippets/ftl.js +7 -0
  173. data/vendor/assets/javascripts/ace/snippets/gcode.js +7 -0
  174. data/vendor/assets/javascripts/ace/snippets/gherkin.js +7 -0
  175. data/vendor/assets/javascripts/ace/snippets/gitignore.js +7 -0
  176. data/vendor/assets/javascripts/ace/snippets/glsl.js +7 -0
  177. data/vendor/assets/javascripts/ace/snippets/golang.js +7 -0
  178. data/vendor/assets/javascripts/ace/snippets/groovy.js +7 -0
  179. data/vendor/assets/javascripts/ace/snippets/haml.js +27 -0
  180. data/vendor/assets/javascripts/ace/snippets/handlebars.js +7 -0
  181. data/vendor/assets/javascripts/ace/snippets/haskell.js +89 -0
  182. data/vendor/assets/javascripts/ace/snippets/haxe.js +7 -0
  183. data/vendor/assets/javascripts/ace/snippets/html.js +835 -0
  184. data/vendor/assets/javascripts/ace/snippets/html_ruby.js +7 -0
  185. data/vendor/assets/javascripts/ace/snippets/ini.js +7 -0
  186. data/vendor/assets/javascripts/ace/snippets/io.js +69 -0
  187. data/vendor/assets/javascripts/ace/snippets/jack.js +7 -0
  188. data/vendor/assets/javascripts/ace/snippets/jade.js +7 -0
  189. data/vendor/assets/javascripts/ace/snippets/java.js +241 -0
  190. data/vendor/assets/javascripts/ace/snippets/javascript.js +189 -0
  191. data/vendor/assets/javascripts/ace/snippets/json.js +7 -0
  192. data/vendor/assets/javascripts/ace/snippets/jsoniq.js +68 -0
  193. data/vendor/assets/javascripts/ace/snippets/jsp.js +106 -0
  194. data/vendor/assets/javascripts/ace/snippets/jsx.js +7 -0
  195. data/vendor/assets/javascripts/ace/snippets/julia.js +7 -0
  196. data/vendor/assets/javascripts/ace/snippets/latex.js +7 -0
  197. data/vendor/assets/javascripts/ace/snippets/less.js +7 -0
  198. data/vendor/assets/javascripts/ace/snippets/liquid.js +7 -0
  199. data/vendor/assets/javascripts/ace/snippets/lisp.js +7 -0
  200. data/vendor/assets/javascripts/ace/snippets/livescript.js +7 -0
  201. data/vendor/assets/javascripts/ace/snippets/logiql.js +7 -0
  202. data/vendor/assets/javascripts/ace/snippets/lsl.js +1073 -0
  203. data/vendor/assets/javascripts/ace/snippets/lua.js +28 -0
  204. data/vendor/assets/javascripts/ace/snippets/luapage.js +7 -0
  205. data/vendor/assets/javascripts/ace/snippets/lucene.js +7 -0
  206. data/vendor/assets/javascripts/ace/snippets/makefile.js +11 -0
  207. data/vendor/assets/javascripts/ace/snippets/markdown.js +95 -0
  208. data/vendor/assets/javascripts/ace/snippets/matlab.js +7 -0
  209. data/vendor/assets/javascripts/ace/snippets/mel.js +7 -0
  210. data/vendor/assets/javascripts/ace/snippets/mushcode.js +7 -0
  211. data/vendor/assets/javascripts/ace/snippets/mysql.js +7 -0
  212. data/vendor/assets/javascripts/ace/snippets/nix.js +7 -0
  213. data/vendor/assets/javascripts/ace/snippets/objectivec.js +7 -0
  214. data/vendor/assets/javascripts/ace/snippets/ocaml.js +7 -0
  215. data/vendor/assets/javascripts/ace/snippets/pascal.js +7 -0
  216. data/vendor/assets/javascripts/ace/snippets/perl.js +354 -0
  217. data/vendor/assets/javascripts/ace/snippets/pgsql.js +7 -0
  218. data/vendor/assets/javascripts/ace/snippets/php.js +283 -0
  219. data/vendor/assets/javascripts/ace/snippets/plain_text.js +7 -0
  220. data/vendor/assets/javascripts/ace/snippets/powershell.js +7 -0
  221. data/vendor/assets/javascripts/ace/snippets/praat.js +7 -0
  222. data/vendor/assets/javascripts/ace/snippets/prolog.js +7 -0
  223. data/vendor/assets/javascripts/ace/snippets/properties.js +7 -0
  224. data/vendor/assets/javascripts/ace/snippets/protobuf.js +7 -0
  225. data/vendor/assets/javascripts/ace/snippets/python.js +165 -0
  226. data/vendor/assets/javascripts/ace/snippets/r.js +128 -0
  227. data/vendor/assets/javascripts/ace/snippets/rdoc.js +7 -0
  228. data/vendor/assets/javascripts/ace/snippets/rhtml.js +7 -0
  229. data/vendor/assets/javascripts/ace/snippets/ruby.js +935 -0
  230. data/vendor/assets/javascripts/ace/snippets/rust.js +7 -0
  231. data/vendor/assets/javascripts/ace/snippets/sass.js +7 -0
  232. data/vendor/assets/javascripts/ace/snippets/scad.js +7 -0
  233. data/vendor/assets/javascripts/ace/snippets/scala.js +7 -0
  234. data/vendor/assets/javascripts/ace/snippets/scheme.js +7 -0
  235. data/vendor/assets/javascripts/ace/snippets/scss.js +7 -0
  236. data/vendor/assets/javascripts/ace/snippets/sh.js +90 -0
  237. data/vendor/assets/javascripts/ace/snippets/sjs.js +7 -0
  238. data/vendor/assets/javascripts/ace/snippets/smarty.js +7 -0
  239. data/vendor/assets/javascripts/ace/snippets/snippets.js +16 -0
  240. data/vendor/assets/javascripts/ace/snippets/soy_template.js +7 -0
  241. data/vendor/assets/javascripts/ace/snippets/space.js +7 -0
  242. data/vendor/assets/javascripts/ace/snippets/sql.js +33 -0
  243. data/vendor/assets/javascripts/ace/snippets/stylus.js +7 -0
  244. data/vendor/assets/javascripts/ace/snippets/svg.js +7 -0
  245. data/vendor/assets/javascripts/ace/snippets/tcl.js +99 -0
  246. data/vendor/assets/javascripts/ace/snippets/tex.js +197 -0
  247. data/vendor/assets/javascripts/ace/snippets/text.js +7 -0
  248. data/vendor/assets/javascripts/ace/snippets/textile.js +37 -0
  249. data/vendor/assets/javascripts/ace/snippets/toml.js +7 -0
  250. data/vendor/assets/javascripts/ace/snippets/twig.js +7 -0
  251. data/vendor/assets/javascripts/ace/snippets/typescript.js +7 -0
  252. data/vendor/assets/javascripts/ace/snippets/vala.js +193 -0
  253. data/vendor/assets/javascripts/ace/snippets/vbscript.js +7 -0
  254. data/vendor/assets/javascripts/ace/snippets/velocity.js +36 -0
  255. data/vendor/assets/javascripts/ace/snippets/verilog.js +7 -0
  256. data/vendor/assets/javascripts/ace/snippets/vhdl.js +7 -0
  257. data/vendor/assets/javascripts/ace/snippets/xml.js +7 -0
  258. data/vendor/assets/javascripts/ace/snippets/xquery.js +68 -0
  259. data/vendor/assets/javascripts/ace/snippets/yaml.js +7 -0
  260. data/vendor/assets/javascripts/ace/theme-ambiance.js +4 -24
  261. data/vendor/assets/javascripts/ace/theme-chaos.js +2 -25
  262. data/vendor/assets/javascripts/ace/theme-chrome.js +2 -31
  263. data/vendor/assets/javascripts/ace/theme-clouds.js +1 -31
  264. data/vendor/assets/javascripts/ace/theme-clouds_midnight.js +1 -31
  265. data/vendor/assets/javascripts/ace/theme-cobalt.js +1 -31
  266. data/vendor/assets/javascripts/ace/theme-crimson_editor.js +1 -31
  267. data/vendor/assets/javascripts/ace/theme-dawn.js +1 -31
  268. data/vendor/assets/javascripts/ace/theme-dreamweaver.js +5 -31
  269. data/vendor/assets/javascripts/ace/theme-eclipse.js +7 -33
  270. data/vendor/assets/javascripts/ace/theme-github.js +2 -35
  271. data/vendor/assets/javascripts/ace/theme-idle_fingers.js +1 -31
  272. data/vendor/assets/javascripts/ace/theme-katzenmilch.js +119 -0
  273. data/vendor/assets/javascripts/ace/theme-kr.js +1 -31
  274. data/vendor/assets/javascripts/ace/theme-kr_theme.js +57 -141
  275. data/vendor/assets/javascripts/ace/theme-kuroir.js +59 -0
  276. data/vendor/assets/javascripts/ace/theme-merbivore.js +1 -31
  277. data/vendor/assets/javascripts/ace/theme-merbivore_soft.js +1 -31
  278. data/vendor/assets/javascripts/ace/theme-mono_industrial.js +1 -31
  279. data/vendor/assets/javascripts/ace/theme-monokai.js +1 -31
  280. data/vendor/assets/javascripts/ace/theme-pastel_on_dark.js +1 -31
  281. data/vendor/assets/javascripts/ace/theme-solarized_dark.js +1 -31
  282. data/vendor/assets/javascripts/ace/theme-solarized_light.js +1 -31
  283. data/vendor/assets/javascripts/ace/theme-terminal.js +1 -31
  284. data/vendor/assets/javascripts/ace/theme-textmate.js +3 -32
  285. data/vendor/assets/javascripts/ace/theme-tomorrow.js +1 -31
  286. data/vendor/assets/javascripts/ace/theme-tomorrow_night.js +1 -31
  287. data/vendor/assets/javascripts/ace/theme-tomorrow_night_blue.js +1 -31
  288. data/vendor/assets/javascripts/ace/theme-tomorrow_night_bright.js +1 -31
  289. data/vendor/assets/javascripts/ace/theme-tomorrow_night_eighties.js +1 -31
  290. data/vendor/assets/javascripts/ace/theme-twilight.js +1 -31
  291. data/vendor/assets/javascripts/ace/theme-vibrant_ink.js +1 -31
  292. data/vendor/assets/javascripts/ace/theme-xcode.js +2 -33
  293. data/vendor/assets/javascripts/ace/worker-coffee.js +5026 -5008
  294. data/vendor/assets/javascripts/ace/worker-css.js +5489 -5134
  295. data/vendor/assets/javascripts/ace/worker-html.js +11517 -0
  296. data/vendor/assets/javascripts/ace/worker-javascript.js +9810 -9501
  297. data/vendor/assets/javascripts/ace/worker-json.js +1583 -1564
  298. data/vendor/assets/javascripts/ace/worker-lua.js +2631 -2612
  299. data/vendor/assets/javascripts/ace/worker-php.js +2385 -2341
  300. data/vendor/assets/javascripts/ace/worker-xquery.js +31643 -3993
  301. metadata +147 -11
@@ -1,163 +1,78 @@
1
- /* ***** BEGIN LICENSE BLOCK *****
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/svg', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/xml', 'ace/mode/javascript', 'ace/tokenizer', 'ace/mode/svg_highlight_rules', 'ace/mode/folding/mixed', 'ace/mode/folding/xml', 'ace/mode/folding/cstyle'], function(require, exports, module) {
32
-
33
-
34
- var oop = require("../lib/oop");
35
- var XmlMode = require("./xml").Mode;
36
- var JavaScriptMode = require("./javascript").Mode;
37
- var Tokenizer = require("../tokenizer").Tokenizer;
38
- var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
39
- var MixedFoldMode = require("./folding/mixed").FoldMode;
40
- var XmlFoldMode = require("./folding/xml").FoldMode;
41
- var CStyleFoldMode = require("./folding/cstyle").FoldMode;
42
-
43
- var Mode = function() {
44
- XmlMode.call(this);
45
-
46
- this.HighlightRules = SvgHighlightRules;
47
-
48
- this.createModeDelegates({
49
- "js-": JavaScriptMode
50
- });
51
-
52
- this.foldingRules = new MixedFoldMode(new XmlFoldMode({}), {
53
- "js-": new CStyleFoldMode()
54
- });
55
- };
56
-
57
- oop.inherits(Mode, XmlMode);
58
-
59
- (function() {
60
-
61
- this.getNextLineIndent = function(state, line, tab) {
62
- return this.$getIndent(line);
63
- };
64
-
65
-
66
- this.$id = "ace/mode/svg";
67
- }).call(Mode.prototype);
68
-
69
- exports.Mode = Mode;
70
- });
71
-
72
- define('ace/mode/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/xml_highlight_rules', 'ace/mode/behaviour/xml', 'ace/mode/folding/xml'], function(require, exports, module) {
73
-
74
-
75
- var oop = require("../lib/oop");
76
- var TextMode = require("./text").Mode;
77
- var Tokenizer = require("../tokenizer").Tokenizer;
78
- var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
79
- var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
80
- var XmlFoldMode = require("./folding/xml").FoldMode;
81
-
82
- var Mode = function() {
83
- this.HighlightRules = XmlHighlightRules;
84
- this.$behaviour = new XmlBehaviour();
85
- this.foldingRules = new XmlFoldMode();
86
- };
87
-
88
- oop.inherits(Mode, TextMode);
89
-
90
- (function() {
91
-
92
- this.blockComment = {start: "<!--", end: "-->"};
93
-
94
- this.$id = "ace/mode/xml";
95
- }).call(Mode.prototype);
96
-
97
- exports.Mode = Mode;
98
- });
99
-
100
- 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) {
101
-
1
+ define("ace/mode/xml_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
2
+ "use strict";
102
3
 
103
4
  var oop = require("../lib/oop");
104
- var xmlUtil = require("./xml_util");
105
5
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
106
6
 
107
7
  var XmlHighlightRules = function(normalize) {
108
8
  this.$rules = {
109
9
  start : [
110
- {token : "punctuation.string.begin", regex : "<\\!\\[CDATA\\[", next : "cdata"},
10
+ {token : "string.cdata.xml", regex : "<\\!\\[CDATA\\[", next : "cdata"},
111
11
  {
112
- token : ["punctuation.instruction.begin", "keyword.instruction"],
113
- regex : "(<\\?)(xml)(?=[\\s])", next : "xml_declaration"
12
+ token : ["punctuation.xml-decl.xml", "keyword.xml-decl.xml"],
13
+ regex : "(<\\?)(xml)(?=[\\s])", next : "xml_decl", caseInsensitive: true
114
14
  },
115
15
  {
116
- token : ["punctuation.instruction.begin", "keyword.instruction"],
117
- regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "instruction"
16
+ token : ["punctuation.instruction.xml", "keyword.instruction.xml"],
17
+ regex : "(<\\?)([-_a-zA-Z0-9]+)", next : "processing_instruction",
118
18
  },
119
- {token : "comment", regex : "<\\!--", next : "comment"},
19
+ {token : "comment.xml", regex : "<\\!--", next : "comment"},
120
20
  {
121
- token : ["punctuation.doctype.begin", "meta.tag.doctype"],
122
- regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype"
21
+ token : ["xml-pe.doctype.xml", "xml-pe.doctype.xml"],
22
+ regex : "(<\\!)(DOCTYPE)(?=[\\s])", next : "doctype", caseInsensitive: true
123
23
  },
124
24
  {include : "tag"},
125
- {include : "reference"}
25
+ {token : "text.end-tag-open.xml", regex: "</"},
26
+ {token : "text.tag-open.xml", regex: "<"},
27
+ {include : "reference"},
28
+ {defaultToken : "text.xml"}
126
29
  ],
127
30
 
128
- xml_declaration : [
129
- {include : "attributes"},
130
- {include : "instruction"}
131
- ],
31
+ xml_decl : [{
32
+ token : "entity.other.attribute-name.decl-attribute-name.xml",
33
+ regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
34
+ }, {
35
+ token : "keyword.operator.decl-attribute-equals.xml",
36
+ regex : "="
37
+ }, {
38
+ include: "whitespace"
39
+ }, {
40
+ include: "string"
41
+ }, {
42
+ token : "punctuation.xml-decl.xml",
43
+ regex : "\\?>",
44
+ next : "start"
45
+ }],
132
46
 
133
- instruction : [
134
- {token : "punctuation.instruction.end", regex : "\\?>", next : "start"}
47
+ processing_instruction : [
48
+ {token : "punctuation.instruction.xml", regex : "\\?>", next : "start"},
49
+ {defaultToken : "instruction.xml"}
135
50
  ],
136
51
 
137
52
  doctype : [
138
- {include : "space"},
53
+ {include : "whitespace"},
139
54
  {include : "string"},
140
- {token : "punctuation.doctype.end", regex : ">", next : "start"},
141
- {token : "xml-pe", regex : "[-_a-zA-Z0-9:]+"},
142
- {token : "punctuation.begin", regex : "\\[", push : "declarations"}
55
+ {token : "xml-pe.doctype.xml", regex : ">", next : "start"},
56
+ {token : "xml-pe.xml", regex : "[-_a-zA-Z0-9:]+"},
57
+ {token : "punctuation.int-subset", regex : "\\[", push : "int_subset"}
143
58
  ],
144
59
 
145
- declarations : [{
146
- token : "text",
60
+ int_subset : [{
61
+ token : "text.xml",
147
62
  regex : "\\s+"
148
63
  }, {
149
- token: "punctuation.end",
64
+ token: "punctuation.int-subset.xml",
150
65
  regex: "]",
151
66
  next: "pop"
152
67
  }, {
153
- token : ["punctuation.begin", "keyword"],
68
+ token : ["punctuation.markup-decl.xml", "keyword.markup-decl.xml"],
154
69
  regex : "(<\\!)([-_a-zA-Z0-9]+)",
155
70
  push : [{
156
71
  token : "text",
157
72
  regex : "\\s+"
158
73
  },
159
74
  {
160
- token : "punctuation.end",
75
+ token : "punctuation.markup-decl.xml",
161
76
  regex : ">",
162
77
  next : "pop"
163
78
  },
@@ -165,75 +80,85 @@ var XmlHighlightRules = function(normalize) {
165
80
  }],
166
81
 
167
82
  cdata : [
168
- {token : "string.end", regex : "\\]\\]>", next : "start"},
169
- {token : "text", regex : "\\s+"},
170
- {token : "text", regex : "(?:[^\\]]|\\](?!\\]>))+"}
83
+ {token : "string.cdata.xml", regex : "\\]\\]>", next : "start"},
84
+ {token : "text.xml", regex : "\\s+"},
85
+ {token : "text.xml", regex : "(?:[^\\]]|\\](?!\\]>))+"}
171
86
  ],
172
87
 
173
88
  comment : [
174
- {token : "comment", regex : "-->", next : "start"},
175
- {defaultToken : "comment"}
89
+ {token : "comment.xml", regex : "-->", next : "start"},
90
+ {defaultToken : "comment.xml"}
176
91
  ],
177
92
 
93
+ reference : [{
94
+ token : "constant.language.escape.reference.xml",
95
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
96
+ }],
97
+
98
+ attr_reference : [{
99
+ token : "constant.language.escape.reference.attribute-value.xml",
100
+ regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
101
+ }],
102
+
178
103
  tag : [{
179
- token : ["meta.tag.punctuation.begin", "meta.tag.name"],
180
- regex : "(<)((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
104
+ token : ["meta.tag.punctuation.tag-open.xml", "meta.tag.punctuation.end-tag-open.xml", "meta.tag.tag-name.xml"],
105
+ regex : "(?:(<)|(</))((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
181
106
  next: [
182
107
  {include : "attributes"},
183
- {token : "meta.tag.punctuation.end", regex : "/?>", next : "start"}
184
- ]
185
- }, {
186
- token : ["meta.tag.punctuation.begin", "meta.tag.name"],
187
- regex : "(</)((?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+)",
188
- next: [
189
- {include : "space"},
190
- {token : "meta.tag.punctuation.end", regex : ">", next : "start"}
108
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : "start"}
191
109
  ]
192
110
  }],
193
111
 
194
- space : [
195
- {token : "text", regex : "\\s+"}
112
+ tag_whitespace : [
113
+ {token : "text.tag-whitespace.xml", regex : "\\s+"}
114
+ ],
115
+ whitespace : [
116
+ {token : "text.whitespace.xml", regex : "\\s+"}
196
117
  ],
197
-
198
- reference : [{
199
- token : "constant.language.escape",
200
- regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
201
- }, {
202
- token : "text", regex : "&"
203
- }],
204
-
205
118
  string: [{
206
- token : "string",
119
+ token : "string.xml",
207
120
  regex : "'",
208
- push : "qstring_inner"
121
+ push : [
122
+ {token : "string.xml", regex: "'", next: "pop"},
123
+ {defaultToken : "string.xml"}
124
+ ]
209
125
  }, {
210
- token : "string",
126
+ token : "string.xml",
211
127
  regex : '"',
212
- push : "qqstring_inner"
128
+ push : [
129
+ {token : "string.xml", regex: '"', next: "pop"},
130
+ {defaultToken : "string.xml"}
131
+ ]
213
132
  }],
214
133
 
215
- qstring_inner: [
216
- {token : "string", regex: "'", next: "pop"},
217
- {include : "reference"},
218
- {defaultToken : "string"}
219
- ],
220
-
221
- qqstring_inner: [
222
- {token : "string", regex: '"', next: "pop"},
223
- {include : "reference"},
224
- {defaultToken : "string"}
225
- ],
226
-
227
134
  attributes: [{
228
- token : "entity.other.attribute-name",
135
+ token : "entity.other.attribute-name.xml",
229
136
  regex : "(?:[-_a-zA-Z0-9]+:)?[-_a-zA-Z0-9]+"
230
137
  }, {
231
- token : "keyword.operator.separator",
138
+ token : "keyword.operator.attribute-equals.xml",
232
139
  regex : "="
233
140
  }, {
234
- include : "space"
141
+ include: "tag_whitespace"
235
142
  }, {
236
- include : "string"
143
+ include: "attribute_value"
144
+ }],
145
+
146
+ attribute_value: [{
147
+ token : "string.attribute-value.xml",
148
+ regex : "'",
149
+ push : [
150
+ {token : "string.attribute-value.xml", regex: "'", next: "pop"},
151
+ {include : "attr_reference"},
152
+ {defaultToken : "string.attribute-value.xml"}
153
+ ]
154
+ }, {
155
+ token : "string.attribute-value.xml",
156
+ regex : '"',
157
+ push : [
158
+ {token : "string.attribute-value.xml", regex: '"', next: "pop"},
159
+ {include : "attr_reference"},
160
+ {defaultToken : "string.attribute-value.xml"}
161
+ ]
237
162
  }]
238
163
  };
239
164
 
@@ -246,18 +171,17 @@ var XmlHighlightRules = function(normalize) {
246
171
 
247
172
  this.embedTagRules = function(HighlightRules, prefix, tag){
248
173
  this.$rules.tag.unshift({
249
- token : ["meta.tag.punctuation.begin", "meta.tag.name." + tag],
250
- regex : "(<)(" + tag + ")",
174
+ token : ["meta.tag.punctuation.tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
175
+ regex : "(<)(" + tag + "(?=\\s|>|$))",
251
176
  next: [
252
- {include : "space"},
253
177
  {include : "attributes"},
254
- {token : "meta.tag.punctuation.end", regex : "/?>", next : prefix + "start"}
178
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next : prefix + "start"}
255
179
  ]
256
180
  });
257
181
 
258
182
  this.$rules[tag + "-end"] = [
259
- {include : "space"},
260
- {token : "meta.tag.punctuation.end", regex : ">", next: "start",
183
+ {include : "attributes"},
184
+ {token : "meta.tag.punctuation.tag-close.xml", regex : "/?>", next: "start",
261
185
  onMatch : function(value, currentState, stack) {
262
186
  stack.splice(0);
263
187
  return this.token;
@@ -265,14 +189,14 @@ var XmlHighlightRules = function(normalize) {
265
189
  ]
266
190
 
267
191
  this.embedRules(HighlightRules, prefix, [{
268
- token: ["meta.tag.punctuation.begin", "meta.tag.name." + tag],
269
- regex : "(</)(" + tag + ")",
192
+ token: ["meta.tag.punctuation.end-tag-open.xml", "meta.tag." + tag + ".tag-name.xml"],
193
+ regex : "(</)(" + tag + "(?=\\s|>|$))",
270
194
  next: tag + "-end"
271
195
  }, {
272
- token: "string.begin",
196
+ token: "string.cdata.xml",
273
197
  regex : "<\\!\\[CDATA\\["
274
198
  }, {
275
- token: "string.end",
199
+ token: "string.cdata.xml",
276
200
  regex : "\\]\\]>"
277
201
  }]);
278
202
  };
@@ -284,480 +208,141 @@ oop.inherits(XmlHighlightRules, TextHighlightRules);
284
208
  exports.XmlHighlightRules = XmlHighlightRules;
285
209
  });
286
210
 
287
- define('ace/mode/xml_util', ['require', 'exports', 'module' ], function(require, exports, module) {
288
-
289
-
290
- function string(state) {
291
- return [{
292
- token : "string",
293
- regex : '"',
294
- next : state + "_qqstring"
295
- }, {
296
- token : "string",
297
- regex : "'",
298
- next : state + "_qstring"
299
- }];
300
- }
301
-
302
- function multiLineString(quote, state) {
303
- return [
304
- {token : "string", regex : quote, next : state},
305
- {
306
- token : "constant.language.escape",
307
- regex : "(?:&#[0-9]+;)|(?:&#x[0-9a-fA-F]+;)|(?:&[a-zA-Z0-9_:\\.-]+;)"
308
- },
309
- {defaultToken : "string"}
310
- ];
311
- }
312
-
313
- exports.tag = function(states, name, nextState, tagMap) {
314
- states[name] = [{
315
- token : "text",
316
- regex : "\\s+"
317
- }, {
318
-
319
- token : !tagMap ? "meta.tag.tag-name" : function(value) {
320
- if (tagMap[value])
321
- return "meta.tag.tag-name." + tagMap[value];
322
- else
323
- return "meta.tag.tag-name";
324
- },
325
- regex : "[-_a-zA-Z0-9:]+",
326
- next : name + "_embed_attribute_list"
327
- }, {
328
- token: "empty",
329
- regex: "",
330
- next : name + "_embed_attribute_list"
331
- }];
332
-
333
- states[name + "_qstring"] = multiLineString("'", name + "_embed_attribute_list");
334
- states[name + "_qqstring"] = multiLineString("\"", name + "_embed_attribute_list");
335
-
336
- states[name + "_embed_attribute_list"] = [{
337
- token : "meta.tag.r",
338
- regex : "/?>",
339
- next : nextState
340
- }, {
341
- token : "keyword.operator",
342
- regex : "="
343
- }, {
344
- token : "entity.other.attribute-name",
345
- regex : "[-_a-zA-Z0-9:]+"
346
- }, {
347
- token : "constant.numeric", // float
348
- regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
349
- }, {
350
- token : "text",
351
- regex : "\\s+"
352
- }].concat(string(name));
353
- };
354
-
355
- });
356
-
357
- define('ace/mode/behaviour/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/mode/behaviour/cstyle', 'ace/token_iterator'], function(require, exports, module) {
358
-
211
+ define("ace/mode/behaviour/xml",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator"], function(require, exports, module) {
212
+ "use strict";
359
213
 
360
214
  var oop = require("../../lib/oop");
361
215
  var Behaviour = require("../behaviour").Behaviour;
362
- var CstyleBehaviour = require("./cstyle").CstyleBehaviour;
363
216
  var TokenIterator = require("../../token_iterator").TokenIterator;
364
217
 
365
- function hasType(token, type) {
366
- var tokenTypes = token.type.split('.');
367
- return type.split('.').every(function(type){
368
- return (tokenTypes.indexOf(type) !== -1);
369
- });
370
- return hasType;
218
+ function is(token, type) {
219
+ return token.type.lastIndexOf(type + ".xml") > -1;
371
220
  }
372
221
 
373
222
  var XmlBehaviour = function () {
374
-
375
- this.inherit(CstyleBehaviour, ["string_dquotes"]); // Get string behaviour
376
-
377
- this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
378
- if (text == '>') {
379
- var position = editor.getCursorPosition();
380
- var iterator = new TokenIterator(session, position.row, position.column);
381
- var token = iterator.getCurrentToken();
382
223
 
383
- if (token && hasType(token, 'string') && iterator.getCurrentTokenColumn() + token.value.length > position.column)
384
- return;
385
- var atCursor = false;
386
- if (!token || !hasType(token, 'meta.tag') && !(hasType(token, 'text') && token.value.match('/'))){
387
- do {
388
- token = iterator.stepBackward();
389
- } while (token && (hasType(token, 'string') || hasType(token, 'keyword.operator') || hasType(token, 'entity.attribute-name') || hasType(token, 'text')));
390
- } else {
391
- atCursor = true;
392
- }
393
- if (!token || !hasType(token, 'meta.tag.name') || iterator.stepBackward().value.match('/')) {
394
- return;
395
- }
396
- var tag = token.value;
397
- if (atCursor){
398
- var tag = tag.substring(0, position.column - token.start);
399
- }
400
-
401
- return {
402
- text: '>' + '</' + tag + '>',
403
- selection: [1, 1]
404
- }
405
- }
406
- });
407
-
408
- this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
409
- if (text == "\n") {
410
- var cursor = editor.getCursorPosition();
411
- var line = session.getLine(cursor.row);
412
- var rightChars = line.substring(cursor.column, cursor.column + 2);
413
- if (rightChars == '</') {
414
- var next_indent = this.$getIndent(line);
415
- var indent = next_indent + session.getTabString();
416
-
417
- return {
418
- text: '\n' + indent + '\n' + next_indent,
419
- selection: [1, indent.length, 1, indent.length]
420
- }
421
- }
422
- }
423
- });
424
-
425
- }
426
- oop.inherits(XmlBehaviour, Behaviour);
427
-
428
- exports.XmlBehaviour = XmlBehaviour;
429
- });
430
-
431
- define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
432
-
433
-
434
- var oop = require("../../lib/oop");
435
- var Behaviour = require("../behaviour").Behaviour;
436
- var TokenIterator = require("../../token_iterator").TokenIterator;
437
- var lang = require("../../lib/lang");
438
-
439
- var SAFE_INSERT_IN_TOKENS =
440
- ["text", "paren.rparen", "punctuation.operator"];
441
- var SAFE_INSERT_BEFORE_TOKENS =
442
- ["text", "paren.rparen", "punctuation.operator", "comment"];
443
-
444
-
445
- var autoInsertedBrackets = 0;
446
- var autoInsertedRow = -1;
447
- var autoInsertedLineEnd = "";
448
- var maybeInsertedBrackets = 0;
449
- var maybeInsertedRow = -1;
450
- var maybeInsertedLineStart = "";
451
- var maybeInsertedLineEnd = "";
452
-
453
- var CstyleBehaviour = function () {
454
-
455
- CstyleBehaviour.isSaneInsertion = function(editor, session) {
456
- var cursor = editor.getCursorPosition();
457
- var iterator = new TokenIterator(session, cursor.row, cursor.column);
458
- if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
459
- var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
460
- if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
461
- return false;
462
- }
463
- iterator.stepForward();
464
- return iterator.getCurrentTokenRow() !== cursor.row ||
465
- this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
466
- };
467
-
468
- CstyleBehaviour.$matchTokenType = function(token, types) {
469
- return types.indexOf(token.type || token) > -1;
470
- };
471
-
472
- CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
473
- var cursor = editor.getCursorPosition();
474
- var line = session.doc.getLine(cursor.row);
475
- if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
476
- autoInsertedBrackets = 0;
477
- autoInsertedRow = cursor.row;
478
- autoInsertedLineEnd = bracket + line.substr(cursor.column);
479
- autoInsertedBrackets++;
480
- };
481
-
482
- CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
483
- var cursor = editor.getCursorPosition();
484
- var line = session.doc.getLine(cursor.row);
485
- if (!this.isMaybeInsertedClosing(cursor, line))
486
- maybeInsertedBrackets = 0;
487
- maybeInsertedRow = cursor.row;
488
- maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
489
- maybeInsertedLineEnd = line.substr(cursor.column);
490
- maybeInsertedBrackets++;
491
- };
492
-
493
- CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
494
- return autoInsertedBrackets > 0 &&
495
- cursor.row === autoInsertedRow &&
496
- bracket === autoInsertedLineEnd[0] &&
497
- line.substr(cursor.column) === autoInsertedLineEnd;
498
- };
499
-
500
- CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
501
- return maybeInsertedBrackets > 0 &&
502
- cursor.row === maybeInsertedRow &&
503
- line.substr(cursor.column) === maybeInsertedLineEnd &&
504
- line.substr(0, cursor.column) == maybeInsertedLineStart;
505
- };
506
-
507
- CstyleBehaviour.popAutoInsertedClosing = function() {
508
- autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
509
- autoInsertedBrackets--;
510
- };
511
-
512
- CstyleBehaviour.clearMaybeInsertedClosing = function() {
513
- maybeInsertedBrackets = 0;
514
- maybeInsertedRow = -1;
515
- };
516
-
517
- this.add("braces", "insertion", function (state, action, editor, session, text) {
518
- var cursor = editor.getCursorPosition();
519
- var line = session.doc.getLine(cursor.row);
520
- if (text == '{') {
521
- var selection = editor.getSelectionRange();
522
- var selected = session.doc.getTextRange(selection);
523
- if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
524
- return {
525
- text: '{' + selected + '}',
526
- selection: false
527
- };
528
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
529
- if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
530
- CstyleBehaviour.recordAutoInsert(editor, session, "}");
531
- return {
532
- text: '{}',
533
- selection: [1, 1]
534
- };
535
- } else {
536
- CstyleBehaviour.recordMaybeInsert(editor, session, "{");
537
- return {
538
- text: '{',
539
- selection: [1, 1]
540
- };
541
- }
542
- }
543
- } else if (text == '}') {
544
- var rightChar = line.substring(cursor.column, cursor.column + 1);
545
- if (rightChar == '}') {
546
- var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
547
- if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
548
- CstyleBehaviour.popAutoInsertedClosing();
549
- return {
550
- text: '',
551
- selection: [1, 1]
552
- };
553
- }
554
- }
555
- } else if (text == "\n" || text == "\r\n") {
556
- var closing = "";
557
- if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
558
- closing = lang.stringRepeat("}", maybeInsertedBrackets);
559
- CstyleBehaviour.clearMaybeInsertedClosing();
560
- }
561
- var rightChar = line.substring(cursor.column, cursor.column + 1);
562
- if (rightChar === '}') {
563
- var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
564
- if (!openBracePos)
565
- return null;
566
- var next_indent = this.$getIndent(session.getLine(openBracePos.row));
567
- } else if (closing) {
568
- var next_indent = this.$getIndent(line);
569
- } else {
570
- return;
571
- }
572
- var indent = next_indent + session.getTabString();
573
-
574
- return {
575
- text: '\n' + indent + '\n' + next_indent + closing,
576
- selection: [1, indent.length, 1, indent.length]
577
- };
578
- } else {
579
- CstyleBehaviour.clearMaybeInsertedClosing();
580
- }
581
- });
582
-
583
- this.add("braces", "deletion", function (state, action, editor, session, range) {
584
- var selected = session.doc.getTextRange(range);
585
- if (!range.isMultiLine() && selected == '{') {
586
- var line = session.doc.getLine(range.start.row);
587
- var rightChar = line.substring(range.end.column, range.end.column + 1);
588
- if (rightChar == '}') {
589
- range.end.column++;
590
- return range;
591
- } else {
592
- maybeInsertedBrackets--;
593
- }
594
- }
595
- });
596
-
597
- this.add("parens", "insertion", function (state, action, editor, session, text) {
598
- if (text == '(') {
599
- var selection = editor.getSelectionRange();
600
- var selected = session.doc.getTextRange(selection);
601
- if (selected !== "" && editor.getWrapBehavioursEnabled()) {
602
- return {
603
- text: '(' + selected + ')',
604
- selection: false
605
- };
606
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
607
- CstyleBehaviour.recordAutoInsert(editor, session, ")");
608
- return {
609
- text: '()',
610
- selection: [1, 1]
611
- };
612
- }
613
- } else if (text == ')') {
614
- var cursor = editor.getCursorPosition();
615
- var line = session.doc.getLine(cursor.row);
616
- var rightChar = line.substring(cursor.column, cursor.column + 1);
617
- if (rightChar == ')') {
618
- var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
619
- if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
620
- CstyleBehaviour.popAutoInsertedClosing();
621
- return {
622
- text: '',
623
- selection: [1, 1]
624
- };
625
- }
626
- }
627
- }
628
- });
629
-
630
- this.add("parens", "deletion", function (state, action, editor, session, range) {
631
- var selected = session.doc.getTextRange(range);
632
- if (!range.isMultiLine() && selected == '(') {
633
- var line = session.doc.getLine(range.start.row);
634
- var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
635
- if (rightChar == ')') {
636
- range.end.column++;
637
- return range;
638
- }
639
- }
640
- });
641
-
642
- this.add("brackets", "insertion", function (state, action, editor, session, text) {
643
- if (text == '[') {
644
- var selection = editor.getSelectionRange();
645
- var selected = session.doc.getTextRange(selection);
646
- if (selected !== "" && editor.getWrapBehavioursEnabled()) {
224
+ this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
225
+ if (text == '"' || text == "'") {
226
+ var quote = text;
227
+ var selected = session.doc.getTextRange(editor.getSelectionRange());
228
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
647
229
  return {
648
- text: '[' + selected + ']',
230
+ text: quote + selected + quote,
649
231
  selection: false
650
232
  };
651
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
652
- CstyleBehaviour.recordAutoInsert(editor, session, "]");
653
- return {
654
- text: '[]',
655
- selection: [1, 1]
656
- };
657
233
  }
658
- } else if (text == ']') {
234
+
659
235
  var cursor = editor.getCursorPosition();
660
236
  var line = session.doc.getLine(cursor.row);
661
237
  var rightChar = line.substring(cursor.column, cursor.column + 1);
662
- if (rightChar == ']') {
663
- var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
664
- if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
665
- CstyleBehaviour.popAutoInsertedClosing();
666
- return {
667
- text: '',
668
- selection: [1, 1]
669
- };
670
- }
238
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
239
+ var token = iterator.getCurrentToken();
240
+
241
+ if (rightChar == quote && (is(token, "attribute-value") || is(token, "string"))) {
242
+ return {
243
+ text: "",
244
+ selection: [1, 1]
245
+ };
246
+ }
247
+
248
+ if (!token)
249
+ token = iterator.stepBackward();
250
+
251
+ if (!token)
252
+ return;
253
+
254
+ while (is(token, "tag-whitespace") || is(token, "whitespace")) {
255
+ token = iterator.stepBackward();
256
+ }
257
+ var rightSpace = !rightChar || rightChar.match(/\s/);
258
+ if (is(token, "attribute-equals") && (rightSpace || rightChar == '>') || (is(token, "decl-attribute-equals") && (rightSpace || rightChar == '?'))) {
259
+ return {
260
+ text: quote + quote,
261
+ selection: [1, 1]
262
+ };
671
263
  }
672
264
  }
673
265
  });
674
266
 
675
- this.add("brackets", "deletion", function (state, action, editor, session, range) {
267
+ this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
676
268
  var selected = session.doc.getTextRange(range);
677
- if (!range.isMultiLine() && selected == '[') {
269
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
678
270
  var line = session.doc.getLine(range.start.row);
679
271
  var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
680
- if (rightChar == ']') {
272
+ if (rightChar == selected) {
681
273
  range.end.column++;
682
274
  return range;
683
275
  }
684
276
  }
685
277
  });
686
278
 
687
- this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
688
- if (text == '"' || text == "'") {
689
- var quote = text;
690
- var selection = editor.getSelectionRange();
691
- var selected = session.doc.getTextRange(selection);
692
- if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
693
- return {
694
- text: quote + selected + quote,
695
- selection: false
696
- };
697
- } else {
698
- var cursor = editor.getCursorPosition();
699
- var line = session.doc.getLine(cursor.row);
700
- var leftChar = line.substring(cursor.column-1, cursor.column);
701
- if (leftChar == '\\') {
702
- return null;
703
- }
704
- var tokens = session.getTokens(selection.start.row);
705
- var col = 0, token;
706
- var quotepos = -1; // Track whether we're inside an open quote.
707
-
708
- for (var x = 0; x < tokens.length; x++) {
709
- token = tokens[x];
710
- if (token.type == "string") {
711
- quotepos = -1;
712
- } else if (quotepos < 0) {
713
- quotepos = token.value.indexOf(quote);
714
- }
715
- if ((token.value.length + col) > selection.start.column) {
716
- break;
717
- }
718
- col += tokens[x].value.length;
719
- }
720
- 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)))) {
721
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
279
+ this.add("autoclosing", "insertion", function (state, action, editor, session, text) {
280
+ if (text == '>') {
281
+ var position = editor.getCursorPosition();
282
+ var iterator = new TokenIterator(session, position.row, position.column);
283
+ var token = iterator.getCurrentToken() || iterator.stepBackward();
284
+ if (!token || !(is(token, "tag-name") || is(token, "tag-whitespace") || is(token, "attribute-name") || is(token, "attribute-equals") || is(token, "attribute-value")))
285
+ return;
286
+ if (is(token, "reference.attribute-value"))
287
+ return;
288
+ if (is(token, "attribute-value")) {
289
+ var firstChar = token.value.charAt(0);
290
+ if (firstChar == '"' || firstChar == "'") {
291
+ var lastChar = token.value.charAt(token.value.length - 1);
292
+ var tokenEnd = iterator.getCurrentTokenColumn() + token.value.length;
293
+ if (tokenEnd > position.column || tokenEnd == position.column && firstChar != lastChar)
722
294
  return;
723
- return {
724
- text: quote + quote,
725
- selection: [1,1]
726
- };
727
- } else if (token && token.type === "string") {
728
- var rightChar = line.substring(cursor.column, cursor.column + 1);
729
- if (rightChar == quote) {
730
- return {
731
- text: '',
732
- selection: [1, 1]
733
- };
734
- }
735
295
  }
736
296
  }
297
+ while (!is(token, "tag-name")) {
298
+ token = iterator.stepBackward();
299
+ }
300
+
301
+ var tokenRow = iterator.getCurrentTokenRow();
302
+ var tokenColumn = iterator.getCurrentTokenColumn();
303
+ if (is(iterator.stepBackward(), "end-tag-open"))
304
+ return;
305
+
306
+ var element = token.value;
307
+ if (tokenRow == position.row)
308
+ element = element.substring(0, position.column - tokenColumn);
309
+
310
+ if (this.voidElements.hasOwnProperty(element.toLowerCase()))
311
+ return;
312
+
313
+ return {
314
+ text: '>' + '</' + element + '>',
315
+ selection: [1, 1]
316
+ };
737
317
  }
738
318
  });
739
319
 
740
- this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
741
- var selected = session.doc.getTextRange(range);
742
- if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
743
- var line = session.doc.getLine(range.start.row);
744
- var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
745
- if (rightChar == selected) {
746
- range.end.column++;
747
- return range;
320
+ this.add('autoindent', 'insertion', function (state, action, editor, session, text) {
321
+ if (text == "\n") {
322
+ var cursor = editor.getCursorPosition();
323
+ var line = session.getLine(cursor.row);
324
+ var rightChars = line.substring(cursor.column, cursor.column + 2);
325
+ if (rightChars == '</') {
326
+ var next_indent = this.$getIndent(line);
327
+ var indent = next_indent + session.getTabString();
328
+
329
+ return {
330
+ text: '\n' + indent + '\n' + next_indent,
331
+ selection: [1, indent.length, 1, indent.length]
332
+ };
748
333
  }
749
334
  }
750
335
  });
751
-
336
+
752
337
  };
753
338
 
754
- oop.inherits(CstyleBehaviour, Behaviour);
339
+ oop.inherits(XmlBehaviour, Behaviour);
755
340
 
756
- exports.CstyleBehaviour = CstyleBehaviour;
341
+ exports.XmlBehaviour = XmlBehaviour;
757
342
  });
758
343
 
759
- define('ace/mode/folding/xml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/range', 'ace/mode/folding/fold_mode', 'ace/token_iterator'], function(require, exports, module) {
760
-
344
+ define("ace/mode/folding/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/range","ace/mode/folding/fold_mode","ace/token_iterator"], function(require, exports, module) {
345
+ "use strict";
761
346
 
762
347
  var oop = require("../../lib/oop");
763
348
  var lang = require("../../lib/lang");
@@ -765,91 +350,118 @@ var Range = require("../../range").Range;
765
350
  var BaseFoldMode = require("./fold_mode").FoldMode;
766
351
  var TokenIterator = require("../../token_iterator").TokenIterator;
767
352
 
768
- var FoldMode = exports.FoldMode = function(voidElements) {
353
+ var FoldMode = exports.FoldMode = function(voidElements, optionalEndTags) {
769
354
  BaseFoldMode.call(this);
770
355
  this.voidElements = voidElements || {};
356
+ this.optionalEndTags = oop.mixin({}, this.voidElements);
357
+ if (optionalEndTags)
358
+ oop.mixin(this.optionalEndTags, optionalEndTags);
359
+
771
360
  };
772
361
  oop.inherits(FoldMode, BaseFoldMode);
773
362
 
363
+ var Tag = function() {
364
+ this.tagName = "";
365
+ this.closing = false;
366
+ this.selfClosing = false;
367
+ this.start = {row: 0, column: 0};
368
+ this.end = {row: 0, column: 0};
369
+ };
370
+
371
+ function is(token, type) {
372
+ return token.type.lastIndexOf(type + ".xml") > -1;
373
+ }
374
+
774
375
  (function() {
775
376
 
776
377
  this.getFoldWidget = function(session, foldStyle, row) {
777
378
  var tag = this._getFirstTagInLine(session, row);
778
379
 
779
- if (tag.closing)
780
- return foldStyle == "markbeginend" ? "end" : "";
781
-
782
- if (!tag.tagName || this.voidElements[tag.tagName.toLowerCase()])
380
+ if (!tag)
783
381
  return "";
784
382
 
785
- if (tag.selfClosing)
383
+ if (tag.closing || (!tag.tagName && tag.selfClosing))
384
+ return foldStyle == "markbeginend" ? "end" : "";
385
+
386
+ if (!tag.tagName || tag.selfClosing || this.voidElements.hasOwnProperty(tag.tagName.toLowerCase()))
786
387
  return "";
787
388
 
788
- if (tag.value.indexOf("/" + tag.tagName) !== -1)
389
+ if (this._findEndTagInLine(session, row, tag.tagName, tag.end.column))
789
390
  return "";
790
391
 
791
392
  return "start";
792
393
  };
793
-
794
394
  this._getFirstTagInLine = function(session, row) {
795
395
  var tokens = session.getTokens(row);
796
- var value = "";
396
+ var tag = new Tag();
397
+
797
398
  for (var i = 0; i < tokens.length; i++) {
798
399
  var token = tokens[i];
799
- if (token.type.lastIndexOf("meta.tag", 0) === 0)
800
- value += token.value;
801
- else
802
- value += lang.stringRepeat(" ", token.value.length);
400
+ if (is(token, "tag-open")) {
401
+ tag.end.column = tag.start.column + token.value.length;
402
+ tag.closing = is(token, "end-tag-open");
403
+ token = tokens[++i];
404
+ if (!token)
405
+ return null;
406
+ tag.tagName = token.value;
407
+ tag.end.column += token.value.length;
408
+ for (i++; i < tokens.length; i++) {
409
+ token = tokens[i];
410
+ tag.end.column += token.value.length;
411
+ if (is(token, "tag-close")) {
412
+ tag.selfClosing = token.value == '/>';
413
+ break;
414
+ }
415
+ }
416
+ return tag;
417
+ } else if (is(token, "tag-close")) {
418
+ tag.selfClosing = token.value == '/>';
419
+ return tag;
420
+ }
421
+ tag.start.column += token.value.length;
803
422
  }
804
-
805
- return this._parseTag(value);
423
+
424
+ return null;
806
425
  };
807
426
 
808
- this.tagRe = /^(\s*)(<?(\/?)([-_a-zA-Z0-9:!]*)\s*(\/?)>?)/;
809
- this._parseTag = function(tag) {
810
-
811
- var match = tag.match(this.tagRe);
427
+ this._findEndTagInLine = function(session, row, tagName, startColumn) {
428
+ var tokens = session.getTokens(row);
812
429
  var column = 0;
813
-
814
- return {
815
- value: tag,
816
- match: match ? match[2] : "",
817
- closing: match ? !!match[3] : false,
818
- selfClosing: match ? !!match[5] || match[2] == "/>" : false,
819
- tagName: match ? match[4] : "",
820
- column: match[1] ? column + match[1].length : column
821
- };
430
+ for (var i = 0; i < tokens.length; i++) {
431
+ var token = tokens[i];
432
+ column += token.value.length;
433
+ if (column < startColumn)
434
+ continue;
435
+ if (is(token, "end-tag-open")) {
436
+ token = tokens[i + 1];
437
+ if (token && token.value == tagName)
438
+ return true;
439
+ }
440
+ }
441
+ return false;
822
442
  };
823
443
  this._readTagForward = function(iterator) {
824
444
  var token = iterator.getCurrentToken();
825
445
  if (!token)
826
446
  return null;
827
-
828
- var value = "";
829
- var start;
830
-
447
+
448
+ var tag = new Tag();
831
449
  do {
832
- if (token.type.lastIndexOf("meta.tag", 0) === 0) {
833
- if (!start) {
834
- var start = {
835
- row: iterator.getCurrentTokenRow(),
836
- column: iterator.getCurrentTokenColumn()
837
- };
838
- }
839
- value += token.value;
840
- if (value.indexOf(">") !== -1) {
841
- var tag = this._parseTag(value);
842
- tag.start = start;
843
- tag.end = {
844
- row: iterator.getCurrentTokenRow(),
845
- column: iterator.getCurrentTokenColumn() + token.value.length
846
- };
847
- iterator.stepForward();
848
- return tag;
849
- }
450
+ if (is(token, "tag-open")) {
451
+ tag.closing = is(token, "end-tag-open");
452
+ tag.start.row = iterator.getCurrentTokenRow();
453
+ tag.start.column = iterator.getCurrentTokenColumn();
454
+ } else if (is(token, "tag-name")) {
455
+ tag.tagName = token.value;
456
+ } else if (is(token, "tag-close")) {
457
+ tag.selfClosing = token.value == "/>";
458
+ tag.end.row = iterator.getCurrentTokenRow();
459
+ tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
460
+ iterator.stepForward();
461
+ return tag;
850
462
  }
851
463
  } while(token = iterator.stepForward());
852
-
464
+
853
465
  return null;
854
466
  };
855
467
 
@@ -857,32 +469,24 @@ oop.inherits(FoldMode, BaseFoldMode);
857
469
  var token = iterator.getCurrentToken();
858
470
  if (!token)
859
471
  return null;
860
-
861
- var value = "";
862
- var end;
863
472
 
473
+ var tag = new Tag();
864
474
  do {
865
- if (token.type.lastIndexOf("meta.tag", 0) === 0) {
866
- if (!end) {
867
- end = {
868
- row: iterator.getCurrentTokenRow(),
869
- column: iterator.getCurrentTokenColumn() + token.value.length
870
- };
871
- }
872
- value = token.value + value;
873
- if (value.indexOf("<") !== -1) {
874
- var tag = this._parseTag(value);
875
- tag.end = end;
876
- tag.start = {
877
- row: iterator.getCurrentTokenRow(),
878
- column: iterator.getCurrentTokenColumn()
879
- };
880
- iterator.stepBackward();
881
- return tag;
882
- }
475
+ if (is(token, "tag-open")) {
476
+ tag.closing = is(token, "end-tag-open");
477
+ tag.start.row = iterator.getCurrentTokenRow();
478
+ tag.start.column = iterator.getCurrentTokenColumn();
479
+ iterator.stepBackward();
480
+ return tag;
481
+ } else if (is(token, "tag-name")) {
482
+ tag.tagName = token.value;
483
+ } else if (is(token, "tag-close")) {
484
+ tag.selfClosing = token.value == "/>";
485
+ tag.end.row = iterator.getCurrentTokenRow();
486
+ tag.end.column = iterator.getCurrentTokenColumn() + token.value.length;
883
487
  }
884
488
  } while(token = iterator.stepBackward());
885
-
489
+
886
490
  return null;
887
491
  };
888
492
 
@@ -893,10 +497,10 @@ oop.inherits(FoldMode, BaseFoldMode);
893
497
  if (!tag || top.tagName == tag.tagName) {
894
498
  return stack.pop();
895
499
  }
896
- else if (this.voidElements[tag.tagName]) {
500
+ else if (this.optionalEndTags.hasOwnProperty(tag.tagName)) {
897
501
  return;
898
502
  }
899
- else if (this.voidElements[top.tagName]) {
503
+ else if (this.optionalEndTags.hasOwnProperty(top.tagName)) {
900
504
  stack.pop();
901
505
  continue;
902
506
  } else {
@@ -908,7 +512,7 @@ oop.inherits(FoldMode, BaseFoldMode);
908
512
  this.getFoldWidgetRange = function(session, foldStyle, row) {
909
513
  var firstTag = this._getFirstTagInLine(session, row);
910
514
 
911
- if (!firstTag.match)
515
+ if (!firstTag)
912
516
  return null;
913
517
 
914
518
  var isBackward = firstTag.closing || firstTag.selfClosing;
@@ -916,10 +520,10 @@ oop.inherits(FoldMode, BaseFoldMode);
916
520
  var tag;
917
521
 
918
522
  if (!isBackward) {
919
- var iterator = new TokenIterator(session, row, firstTag.column);
523
+ var iterator = new TokenIterator(session, row, firstTag.start.column);
920
524
  var start = {
921
525
  row: row,
922
- column: firstTag.column + firstTag.tagName.length + 2
526
+ column: firstTag.start.column + firstTag.tagName.length + 2
923
527
  };
924
528
  while (tag = this._readTagForward(iterator)) {
925
529
  if (tag.selfClosing) {
@@ -937,15 +541,15 @@ oop.inherits(FoldMode, BaseFoldMode);
937
541
  return Range.fromPoints(start, tag.start);
938
542
  }
939
543
  else {
940
- stack.push(tag)
544
+ stack.push(tag);
941
545
  }
942
546
  }
943
547
  }
944
548
  else {
945
- var iterator = new TokenIterator(session, row, firstTag.column + firstTag.match.length);
549
+ var iterator = new TokenIterator(session, row, firstTag.end.column);
946
550
  var end = {
947
551
  row: row,
948
- column: firstTag.column
552
+ column: firstTag.start.column
949
553
  };
950
554
 
951
555
  while (tag = this._readTagBackward(iterator)) {
@@ -966,7 +570,7 @@ oop.inherits(FoldMode, BaseFoldMode);
966
570
  }
967
571
  }
968
572
  else {
969
- stack.push(tag)
573
+ stack.push(tag);
970
574
  }
971
575
  }
972
576
  }
@@ -977,102 +581,88 @@ oop.inherits(FoldMode, BaseFoldMode);
977
581
 
978
582
  });
979
583
 
980
- define('ace/mode/javascript', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/javascript_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/range', 'ace/worker/worker_client', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle'], function(require, exports, module) {
981
-
584
+ define("ace/mode/xml",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/text","ace/mode/xml_highlight_rules","ace/mode/behaviour/xml","ace/mode/folding/xml"], function(require, exports, module) {
585
+ "use strict";
982
586
 
983
587
  var oop = require("../lib/oop");
588
+ var lang = require("../lib/lang");
984
589
  var TextMode = require("./text").Mode;
985
- var Tokenizer = require("../tokenizer").Tokenizer;
986
- var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
987
- var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
988
- var Range = require("../range").Range;
989
- var WorkerClient = require("../worker/worker_client").WorkerClient;
990
- var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
991
- var CStyleFoldMode = require("./folding/cstyle").FoldMode;
590
+ var XmlHighlightRules = require("./xml_highlight_rules").XmlHighlightRules;
591
+ var XmlBehaviour = require("./behaviour/xml").XmlBehaviour;
592
+ var XmlFoldMode = require("./folding/xml").FoldMode;
992
593
 
993
594
  var Mode = function() {
994
- this.HighlightRules = JavaScriptHighlightRules;
995
-
996
- this.$outdent = new MatchingBraceOutdent();
997
- this.$behaviour = new CstyleBehaviour();
998
- this.foldingRules = new CStyleFoldMode();
595
+ this.HighlightRules = XmlHighlightRules;
596
+ this.$behaviour = new XmlBehaviour();
597
+ this.foldingRules = new XmlFoldMode();
999
598
  };
599
+
1000
600
  oop.inherits(Mode, TextMode);
1001
601
 
1002
602
  (function() {
1003
603
 
1004
- this.lineCommentStart = "//";
1005
- this.blockComment = {start: "/*", end: "*/"};
604
+ this.voidElements = lang.arrayToMap([]);
1006
605
 
1007
- this.getNextLineIndent = function(state, line, tab) {
1008
- var indent = this.$getIndent(line);
606
+ this.blockComment = {start: "<!--", end: "-->"};
1009
607
 
1010
- var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
1011
- var tokens = tokenizedLine.tokens;
1012
- var endState = tokenizedLine.state;
608
+ this.$id = "ace/mode/xml";
609
+ }).call(Mode.prototype);
1013
610
 
1014
- if (tokens.length && tokens[tokens.length-1].type == "comment") {
1015
- return indent;
1016
- }
611
+ exports.Mode = Mode;
612
+ });
1017
613
 
1018
- if (state == "start" || state == "no_regex") {
1019
- var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
1020
- if (match) {
1021
- indent += tab;
1022
- }
1023
- } else if (state == "doc-start") {
1024
- if (endState == "start" || endState == "no_regex") {
1025
- return "";
1026
- }
1027
- var match = line.match(/^\s*(\/?)\*/);
1028
- if (match) {
1029
- if (match[1]) {
1030
- indent += " ";
1031
- }
1032
- indent += "* ";
1033
- }
1034
- }
614
+ define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
615
+ "use strict";
1035
616
 
1036
- return indent;
1037
- };
617
+ var oop = require("../lib/oop");
618
+ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1038
619
 
1039
- this.checkOutdent = function(state, line, input) {
1040
- return this.$outdent.checkOutdent(line, input);
1041
- };
620
+ var DocCommentHighlightRules = function() {
1042
621
 
1043
- this.autoOutdent = function(state, doc, row) {
1044
- this.$outdent.autoOutdent(doc, row);
622
+ this.$rules = {
623
+ "start" : [ {
624
+ token : "comment.doc.tag",
625
+ regex : "@[\\w\\d_]+" // TODO: fix email addresses
626
+ }, {
627
+ token : "comment.doc.tag",
628
+ regex : "\\bTODO\\b"
629
+ }, {
630
+ defaultToken : "comment.doc"
631
+ }]
1045
632
  };
633
+ };
1046
634
 
1047
- this.createWorker = function(session) {
1048
- var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
1049
- worker.attachToDocument(session.getDocument());
1050
-
1051
- worker.on("jslint", function(results) {
1052
- session.setAnnotations(results.data);
1053
- });
635
+ oop.inherits(DocCommentHighlightRules, TextHighlightRules);
1054
636
 
1055
- worker.on("terminate", function() {
1056
- session.clearAnnotations();
1057
- });
637
+ DocCommentHighlightRules.getStartRule = function(start) {
638
+ return {
639
+ token : "comment.doc", // doc comment
640
+ regex : "\\/\\*(?=\\*)",
641
+ next : start
642
+ };
643
+ };
1058
644
 
1059
- return worker;
645
+ DocCommentHighlightRules.getEndRule = function (start) {
646
+ return {
647
+ token : "comment.doc", // closing comment
648
+ regex : "\\*\\/",
649
+ next : start
1060
650
  };
651
+ };
1061
652
 
1062
- this.$id = "ace/mode/javascript";
1063
- }).call(Mode.prototype);
1064
653
 
1065
- exports.Mode = Mode;
1066
- });
654
+ exports.DocCommentHighlightRules = DocCommentHighlightRules;
1067
655
 
1068
- 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) {
656
+ });
1069
657
 
658
+ 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) {
659
+ "use strict";
1070
660
 
1071
661
  var oop = require("../lib/oop");
1072
662
  var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
1073
663
  var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1074
664
 
1075
- var JavaScriptHighlightRules = function() {
665
+ var JavaScriptHighlightRules = function(options) {
1076
666
  var keywordMapper = this.createKeywordMapper({
1077
667
  "variable.language":
1078
668
  "Array|Boolean|Date|Function|Iterator|Number|Object|RegExp|String|Proxy|" + // Constructors
@@ -1197,19 +787,22 @@ var JavaScriptHighlightRules = function() {
1197
787
  }, {
1198
788
  token : ["punctuation.operator", "support.constant"],
1199
789
  regex : /(\.)(s(?:ystemLanguage|cr(?:ipts|ollbars|een(?:X|Y|Top|Left))|t(?:yle(?:Sheets)?|atus(?:Text|bar)?)|ibling(?:Below|Above)|ource|uffixes|e(?:curity(?:Policy)?|l(?:ection|f)))|h(?:istory|ost(?:name)?|as(?:h|Focus))|y|X(?:MLDocument|SLDocument)|n(?:ext|ame(?:space(?:s|URI)|Prop))|M(?:IN_VALUE|AX_VALUE)|c(?:haracterSet|o(?:n(?:structor|trollers)|okieEnabled|lorDepth|mp(?:onents|lete))|urrent|puClass|l(?:i(?:p(?:boardData)?|entInformation)|osed|asses)|alle(?:e|r)|rypto)|t(?:o(?:olbar|p)|ext(?:Transform|Indent|Decoration|Align)|ags)|SQRT(?:1_2|2)|i(?:n(?:ner(?:Height|Width)|put)|ds|gnoreCase)|zIndex|o(?:scpu|n(?:readystatechange|Line)|uter(?:Height|Width)|p(?:sProfile|ener)|ffscreenBuffering)|NEGATIVE_INFINITY|d(?:i(?:splay|alog(?:Height|Top|Width|Left|Arguments)|rectories)|e(?:scription|fault(?:Status|Ch(?:ecked|arset)|View)))|u(?:ser(?:Profile|Language|Agent)|n(?:iqueID|defined)|pdateInterval)|_content|p(?:ixelDepth|ort|ersonalbar|kcs11|l(?:ugins|atform)|a(?:thname|dding(?:Right|Bottom|Top|Left)|rent(?:Window|Layer)?|ge(?:X(?:Offset)?|Y(?:Offset)?))|r(?:o(?:to(?:col|type)|duct(?:Sub)?|mpter)|e(?:vious|fix)))|e(?:n(?:coding|abledPlugin)|x(?:ternal|pando)|mbeds)|v(?:isibility|endor(?:Sub)?|Linkcolor)|URLUnencoded|P(?:I|OSITIVE_INFINITY)|f(?:ilename|o(?:nt(?:Size|Family|Weight)|rmName)|rame(?:s|Element)|gColor)|E|whiteSpace|l(?:i(?:stStyleType|n(?:eHeight|kColor))|o(?:ca(?:tion(?:bar)?|lName)|wsrc)|e(?:ngth|ft(?:Context)?)|a(?:st(?:M(?:odified|atch)|Index|Paren)|yer(?:s|X)|nguage))|a(?:pp(?:MinorVersion|Name|Co(?:deName|re)|Version)|vail(?:Height|Top|Width|Left)|ll|r(?:ity|guments)|Linkcolor|bove)|r(?:ight(?:Context)?|e(?:sponse(?:XML|Text)|adyState))|global|x|m(?:imeTypes|ultiline|enubar|argin(?:Right|Bottom|Top|Left))|L(?:N(?:10|2)|OG(?:10E|2E))|b(?:o(?:ttom|rder(?:Width|RightWidth|BottomWidth|Style|Color|TopWidth|LeftWidth))|ufferDepth|elow|ackground(?:Color|Image)))\b/
790
+ }, {
791
+ token : ["support.constant"],
792
+ regex : /that\b/
1200
793
  }, {
1201
794
  token : ["storage.type", "punctuation.operator", "support.function.firebug"],
1202
- regex : /(console)(\.)(warn|info|log|error|time|timeEnd|assert)\b/
795
+ regex : /(console)(\.)(warn|info|log|error|time|trace|timeEnd|assert)\b/
1203
796
  }, {
1204
797
  token : keywordMapper,
1205
798
  regex : identifierRe
1206
799
  }, {
1207
800
  token : "keyword.operator",
1208
- regex : /--|\+\+|[!$%&*+\-~]|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|\*=|%=|\+=|\-=|&=|\^=/,
801
+ regex : /--|\+\+|===|==|=|!=|!==|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\|\||\?\:|[!$%&*+\-~\/^]=?/,
1209
802
  next : "start"
1210
803
  }, {
1211
804
  token : "punctuation.operator",
1212
- regex : /\?|\:|\,|\;|\./,
805
+ regex : /[?:,;.]/,
1213
806
  next : "start"
1214
807
  }, {
1215
808
  token : "paren.lparen",
@@ -1218,10 +811,6 @@ var JavaScriptHighlightRules = function() {
1218
811
  }, {
1219
812
  token : "paren.rparen",
1220
813
  regex : /[\])}]/
1221
- }, {
1222
- token : "keyword.operator",
1223
- regex : /\/=?/,
1224
- next : "start"
1225
814
  }, {
1226
815
  token: "comment",
1227
816
  regex: /^#!.*$/
@@ -1282,7 +871,7 @@ var JavaScriptHighlightRules = function() {
1282
871
  ],
1283
872
  "regex_character_class": [
1284
873
  {
1285
- token: "regexp.keyword.operator",
874
+ token: "regexp.charclass.keyword.operator",
1286
875
  regex: "\\\\(?:u[\\da-fA-F]{4}|x[\\da-fA-F]{2}|.)"
1287
876
  }, {
1288
877
  token: "constant.language.escape",
@@ -1364,9 +953,49 @@ var JavaScriptHighlightRules = function() {
1364
953
  }
1365
954
  ]
1366
955
  };
1367
-
956
+
957
+
958
+ if (!options || !options.noES6) {
959
+ this.$rules.no_regex.unshift({
960
+ regex: "[{}]", onMatch: function(val, state, stack) {
961
+ this.next = val == "{" ? this.nextState : "";
962
+ if (val == "{" && stack.length) {
963
+ stack.unshift("start", state);
964
+ return "paren";
965
+ }
966
+ if (val == "}" && stack.length) {
967
+ stack.shift();
968
+ this.next = stack.shift();
969
+ if (this.next.indexOf("string") != -1)
970
+ return "paren.quasi.end";
971
+ }
972
+ return val == "{" ? "paren.lparen" : "paren.rparen";
973
+ },
974
+ nextState: "start"
975
+ }, {
976
+ token : "string.quasi.start",
977
+ regex : /`/,
978
+ push : [{
979
+ token : "constant.language.escape",
980
+ regex : escapedRe
981
+ }, {
982
+ token : "paren.quasi.start",
983
+ regex : /\${/,
984
+ push : "start"
985
+ }, {
986
+ token : "string.quasi.end",
987
+ regex : /`/,
988
+ next : "pop"
989
+ }, {
990
+ defaultToken: "string.quasi"
991
+ }]
992
+ });
993
+ }
994
+
1368
995
  this.embedRules(DocCommentHighlightRules, "doc-",
1369
996
  [ DocCommentHighlightRules.getEndRule("no_regex") ]);
997
+
998
+ this.normalizeRules();
1370
999
  };
1371
1000
 
1372
1001
  oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
@@ -1374,92 +1003,406 @@ oop.inherits(JavaScriptHighlightRules, TextHighlightRules);
1374
1003
  exports.JavaScriptHighlightRules = JavaScriptHighlightRules;
1375
1004
  });
1376
1005
 
1377
- define('ace/mode/doc_comment_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
1006
+ define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"], function(require, exports, module) {
1007
+ "use strict";
1008
+
1009
+ var Range = require("../range").Range;
1010
+
1011
+ var MatchingBraceOutdent = function() {};
1012
+
1013
+ (function() {
1014
+
1015
+ this.checkOutdent = function(line, input) {
1016
+ if (! /^\s+$/.test(line))
1017
+ return false;
1018
+
1019
+ return /^\s*\}/.test(input);
1020
+ };
1021
+
1022
+ this.autoOutdent = function(doc, row) {
1023
+ var line = doc.getLine(row);
1024
+ var match = line.match(/^(\s*\})/);
1025
+
1026
+ if (!match) return 0;
1027
+
1028
+ var column = match[1].length;
1029
+ var openBracePos = doc.findMatchingBracket({row: row, column: column});
1030
+
1031
+ if (!openBracePos || openBracePos.row == row) return 0;
1032
+
1033
+ var indent = this.$getIndent(doc.getLine(openBracePos.row));
1034
+ doc.replace(new Range(row, 0, row, column-1), indent);
1035
+ };
1036
+
1037
+ this.$getIndent = function(line) {
1038
+ return line.match(/^\s*/)[0];
1039
+ };
1040
+
1041
+ }).call(MatchingBraceOutdent.prototype);
1042
+
1043
+ exports.MatchingBraceOutdent = MatchingBraceOutdent;
1044
+ });
1045
+
1046
+ define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"], function(require, exports, module) {
1047
+ "use strict";
1048
+
1049
+ var oop = require("../../lib/oop");
1050
+ var Behaviour = require("../behaviour").Behaviour;
1051
+ var TokenIterator = require("../../token_iterator").TokenIterator;
1052
+ var lang = require("../../lib/lang");
1053
+
1054
+ var SAFE_INSERT_IN_TOKENS =
1055
+ ["text", "paren.rparen", "punctuation.operator"];
1056
+ var SAFE_INSERT_BEFORE_TOKENS =
1057
+ ["text", "paren.rparen", "punctuation.operator", "comment"];
1058
+
1059
+ var context;
1060
+ var contextCache = {}
1061
+ var initContext = function(editor) {
1062
+ var id = -1;
1063
+ if (editor.multiSelect) {
1064
+ id = editor.selection.id;
1065
+ if (contextCache.rangeCount != editor.multiSelect.rangeCount)
1066
+ contextCache = {rangeCount: editor.multiSelect.rangeCount};
1067
+ }
1068
+ if (contextCache[id])
1069
+ return context = contextCache[id];
1070
+ context = contextCache[id] = {
1071
+ autoInsertedBrackets: 0,
1072
+ autoInsertedRow: -1,
1073
+ autoInsertedLineEnd: "",
1074
+ maybeInsertedBrackets: 0,
1075
+ maybeInsertedRow: -1,
1076
+ maybeInsertedLineStart: "",
1077
+ maybeInsertedLineEnd: ""
1078
+ };
1079
+ };
1080
+
1081
+ var CstyleBehaviour = function() {
1082
+ this.add("braces", "insertion", function(state, action, editor, session, text) {
1083
+ var cursor = editor.getCursorPosition();
1084
+ var line = session.doc.getLine(cursor.row);
1085
+ if (text == '{') {
1086
+ initContext(editor);
1087
+ var selection = editor.getSelectionRange();
1088
+ var selected = session.doc.getTextRange(selection);
1089
+ if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
1090
+ return {
1091
+ text: '{' + selected + '}',
1092
+ selection: false
1093
+ };
1094
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
1095
+ if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
1096
+ CstyleBehaviour.recordAutoInsert(editor, session, "}");
1097
+ return {
1098
+ text: '{}',
1099
+ selection: [1, 1]
1100
+ };
1101
+ } else {
1102
+ CstyleBehaviour.recordMaybeInsert(editor, session, "{");
1103
+ return {
1104
+ text: '{',
1105
+ selection: [1, 1]
1106
+ };
1107
+ }
1108
+ }
1109
+ } else if (text == '}') {
1110
+ initContext(editor);
1111
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1112
+ if (rightChar == '}') {
1113
+ var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
1114
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
1115
+ CstyleBehaviour.popAutoInsertedClosing();
1116
+ return {
1117
+ text: '',
1118
+ selection: [1, 1]
1119
+ };
1120
+ }
1121
+ }
1122
+ } else if (text == "\n" || text == "\r\n") {
1123
+ initContext(editor);
1124
+ var closing = "";
1125
+ if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
1126
+ closing = lang.stringRepeat("}", context.maybeInsertedBrackets);
1127
+ CstyleBehaviour.clearMaybeInsertedClosing();
1128
+ }
1129
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1130
+ if (rightChar === '}') {
1131
+ var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
1132
+ if (!openBracePos)
1133
+ return null;
1134
+ var next_indent = this.$getIndent(session.getLine(openBracePos.row));
1135
+ } else if (closing) {
1136
+ var next_indent = this.$getIndent(line);
1137
+ } else {
1138
+ CstyleBehaviour.clearMaybeInsertedClosing();
1139
+ return;
1140
+ }
1141
+ var indent = next_indent + session.getTabString();
1142
+
1143
+ return {
1144
+ text: '\n' + indent + '\n' + next_indent + closing,
1145
+ selection: [1, indent.length, 1, indent.length]
1146
+ };
1147
+ } else {
1148
+ CstyleBehaviour.clearMaybeInsertedClosing();
1149
+ }
1150
+ });
1151
+
1152
+ this.add("braces", "deletion", function(state, action, editor, session, range) {
1153
+ var selected = session.doc.getTextRange(range);
1154
+ if (!range.isMultiLine() && selected == '{') {
1155
+ initContext(editor);
1156
+ var line = session.doc.getLine(range.start.row);
1157
+ var rightChar = line.substring(range.end.column, range.end.column + 1);
1158
+ if (rightChar == '}') {
1159
+ range.end.column++;
1160
+ return range;
1161
+ } else {
1162
+ context.maybeInsertedBrackets--;
1163
+ }
1164
+ }
1165
+ });
1166
+
1167
+ this.add("parens", "insertion", function(state, action, editor, session, text) {
1168
+ if (text == '(') {
1169
+ initContext(editor);
1170
+ var selection = editor.getSelectionRange();
1171
+ var selected = session.doc.getTextRange(selection);
1172
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
1173
+ return {
1174
+ text: '(' + selected + ')',
1175
+ selection: false
1176
+ };
1177
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
1178
+ CstyleBehaviour.recordAutoInsert(editor, session, ")");
1179
+ return {
1180
+ text: '()',
1181
+ selection: [1, 1]
1182
+ };
1183
+ }
1184
+ } else if (text == ')') {
1185
+ initContext(editor);
1186
+ var cursor = editor.getCursorPosition();
1187
+ var line = session.doc.getLine(cursor.row);
1188
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1189
+ if (rightChar == ')') {
1190
+ var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
1191
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
1192
+ CstyleBehaviour.popAutoInsertedClosing();
1193
+ return {
1194
+ text: '',
1195
+ selection: [1, 1]
1196
+ };
1197
+ }
1198
+ }
1199
+ }
1200
+ });
1201
+
1202
+ this.add("parens", "deletion", function(state, action, editor, session, range) {
1203
+ var selected = session.doc.getTextRange(range);
1204
+ if (!range.isMultiLine() && selected == '(') {
1205
+ initContext(editor);
1206
+ var line = session.doc.getLine(range.start.row);
1207
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
1208
+ if (rightChar == ')') {
1209
+ range.end.column++;
1210
+ return range;
1211
+ }
1212
+ }
1213
+ });
1214
+
1215
+ this.add("brackets", "insertion", function(state, action, editor, session, text) {
1216
+ if (text == '[') {
1217
+ initContext(editor);
1218
+ var selection = editor.getSelectionRange();
1219
+ var selected = session.doc.getTextRange(selection);
1220
+ if (selected !== "" && editor.getWrapBehavioursEnabled()) {
1221
+ return {
1222
+ text: '[' + selected + ']',
1223
+ selection: false
1224
+ };
1225
+ } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
1226
+ CstyleBehaviour.recordAutoInsert(editor, session, "]");
1227
+ return {
1228
+ text: '[]',
1229
+ selection: [1, 1]
1230
+ };
1231
+ }
1232
+ } else if (text == ']') {
1233
+ initContext(editor);
1234
+ var cursor = editor.getCursorPosition();
1235
+ var line = session.doc.getLine(cursor.row);
1236
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1237
+ if (rightChar == ']') {
1238
+ var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
1239
+ if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
1240
+ CstyleBehaviour.popAutoInsertedClosing();
1241
+ return {
1242
+ text: '',
1243
+ selection: [1, 1]
1244
+ };
1245
+ }
1246
+ }
1247
+ }
1248
+ });
1249
+
1250
+ this.add("brackets", "deletion", function(state, action, editor, session, range) {
1251
+ var selected = session.doc.getTextRange(range);
1252
+ if (!range.isMultiLine() && selected == '[') {
1253
+ initContext(editor);
1254
+ var line = session.doc.getLine(range.start.row);
1255
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
1256
+ if (rightChar == ']') {
1257
+ range.end.column++;
1258
+ return range;
1259
+ }
1260
+ }
1261
+ });
1378
1262
 
1263
+ this.add("string_dquotes", "insertion", function(state, action, editor, session, text) {
1264
+ if (text == '"' || text == "'") {
1265
+ initContext(editor);
1266
+ var quote = text;
1267
+ var selection = editor.getSelectionRange();
1268
+ var selected = session.doc.getTextRange(selection);
1269
+ if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
1270
+ return {
1271
+ text: quote + selected + quote,
1272
+ selection: false
1273
+ };
1274
+ } else {
1275
+ var cursor = editor.getCursorPosition();
1276
+ var line = session.doc.getLine(cursor.row);
1277
+ var leftChar = line.substring(cursor.column-1, cursor.column);
1278
+ if (leftChar == '\\') {
1279
+ return null;
1280
+ }
1281
+ var tokens = session.getTokens(selection.start.row);
1282
+ var col = 0, token;
1283
+ var quotepos = -1; // Track whether we're inside an open quote.
1379
1284
 
1380
- var oop = require("../lib/oop");
1381
- var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
1285
+ for (var x = 0; x < tokens.length; x++) {
1286
+ token = tokens[x];
1287
+ if (token.type == "string") {
1288
+ quotepos = -1;
1289
+ } else if (quotepos < 0) {
1290
+ quotepos = token.value.indexOf(quote);
1291
+ }
1292
+ if ((token.value.length + col) > selection.start.column) {
1293
+ break;
1294
+ }
1295
+ col += tokens[x].value.length;
1296
+ }
1297
+ 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)))) {
1298
+ if (!CstyleBehaviour.isSaneInsertion(editor, session))
1299
+ return;
1300
+ return {
1301
+ text: quote + quote,
1302
+ selection: [1,1]
1303
+ };
1304
+ } else if (token && token.type === "string") {
1305
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
1306
+ if (rightChar == quote) {
1307
+ return {
1308
+ text: '',
1309
+ selection: [1, 1]
1310
+ };
1311
+ }
1312
+ }
1313
+ }
1314
+ }
1315
+ });
1382
1316
 
1383
- var DocCommentHighlightRules = function() {
1317
+ this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
1318
+ var selected = session.doc.getTextRange(range);
1319
+ if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
1320
+ initContext(editor);
1321
+ var line = session.doc.getLine(range.start.row);
1322
+ var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
1323
+ if (rightChar == selected) {
1324
+ range.end.column++;
1325
+ return range;
1326
+ }
1327
+ }
1328
+ });
1384
1329
 
1385
- this.$rules = {
1386
- "start" : [ {
1387
- token : "comment.doc.tag",
1388
- regex : "@[\\w\\d_]+" // TODO: fix email addresses
1389
- }, {
1390
- token : "comment.doc.tag",
1391
- regex : "\\bTODO\\b"
1392
- }, {
1393
- defaultToken : "comment.doc"
1394
- }]
1395
- };
1396
1330
  };
1397
1331
 
1398
- oop.inherits(DocCommentHighlightRules, TextHighlightRules);
1399
-
1400
- DocCommentHighlightRules.getStartRule = function(start) {
1401
- return {
1402
- token : "comment.doc", // doc comment
1403
- regex : "\\/\\*(?=\\*)",
1404
- next : start
1405
- };
1332
+
1333
+ CstyleBehaviour.isSaneInsertion = function(editor, session) {
1334
+ var cursor = editor.getCursorPosition();
1335
+ var iterator = new TokenIterator(session, cursor.row, cursor.column);
1336
+ if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
1337
+ var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
1338
+ if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
1339
+ return false;
1340
+ }
1341
+ iterator.stepForward();
1342
+ return iterator.getCurrentTokenRow() !== cursor.row ||
1343
+ this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
1406
1344
  };
1407
1345
 
1408
- DocCommentHighlightRules.getEndRule = function (start) {
1409
- return {
1410
- token : "comment.doc", // closing comment
1411
- regex : "\\*\\/",
1412
- next : start
1413
- };
1346
+ CstyleBehaviour.$matchTokenType = function(token, types) {
1347
+ return types.indexOf(token.type || token) > -1;
1414
1348
  };
1415
1349
 
1350
+ CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
1351
+ var cursor = editor.getCursorPosition();
1352
+ var line = session.doc.getLine(cursor.row);
1353
+ if (!this.isAutoInsertedClosing(cursor, line, context.autoInsertedLineEnd[0]))
1354
+ context.autoInsertedBrackets = 0;
1355
+ context.autoInsertedRow = cursor.row;
1356
+ context.autoInsertedLineEnd = bracket + line.substr(cursor.column);
1357
+ context.autoInsertedBrackets++;
1358
+ };
1416
1359
 
1417
- exports.DocCommentHighlightRules = DocCommentHighlightRules;
1418
-
1419
- });
1420
-
1421
- define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
1422
-
1423
-
1424
- var Range = require("../range").Range;
1425
-
1426
- var MatchingBraceOutdent = function() {};
1427
-
1428
- (function() {
1429
-
1430
- this.checkOutdent = function(line, input) {
1431
- if (! /^\s+$/.test(line))
1432
- return false;
1433
-
1434
- return /^\s*\}/.test(input);
1435
- };
1360
+ CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
1361
+ var cursor = editor.getCursorPosition();
1362
+ var line = session.doc.getLine(cursor.row);
1363
+ if (!this.isMaybeInsertedClosing(cursor, line))
1364
+ context.maybeInsertedBrackets = 0;
1365
+ context.maybeInsertedRow = cursor.row;
1366
+ context.maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
1367
+ context.maybeInsertedLineEnd = line.substr(cursor.column);
1368
+ context.maybeInsertedBrackets++;
1369
+ };
1436
1370
 
1437
- this.autoOutdent = function(doc, row) {
1438
- var line = doc.getLine(row);
1439
- var match = line.match(/^(\s*\})/);
1371
+ CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
1372
+ return context.autoInsertedBrackets > 0 &&
1373
+ cursor.row === context.autoInsertedRow &&
1374
+ bracket === context.autoInsertedLineEnd[0] &&
1375
+ line.substr(cursor.column) === context.autoInsertedLineEnd;
1376
+ };
1440
1377
 
1441
- if (!match) return 0;
1378
+ CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
1379
+ return context.maybeInsertedBrackets > 0 &&
1380
+ cursor.row === context.maybeInsertedRow &&
1381
+ line.substr(cursor.column) === context.maybeInsertedLineEnd &&
1382
+ line.substr(0, cursor.column) == context.maybeInsertedLineStart;
1383
+ };
1442
1384
 
1443
- var column = match[1].length;
1444
- var openBracePos = doc.findMatchingBracket({row: row, column: column});
1385
+ CstyleBehaviour.popAutoInsertedClosing = function() {
1386
+ context.autoInsertedLineEnd = context.autoInsertedLineEnd.substr(1);
1387
+ context.autoInsertedBrackets--;
1388
+ };
1445
1389
 
1446
- if (!openBracePos || openBracePos.row == row) return 0;
1390
+ CstyleBehaviour.clearMaybeInsertedClosing = function() {
1391
+ if (context) {
1392
+ context.maybeInsertedBrackets = 0;
1393
+ context.maybeInsertedRow = -1;
1394
+ }
1395
+ };
1447
1396
 
1448
- var indent = this.$getIndent(doc.getLine(openBracePos.row));
1449
- doc.replace(new Range(row, 0, row, column-1), indent);
1450
- };
1451
1397
 
1452
- this.$getIndent = function(line) {
1453
- return line.match(/^\s*/)[0];
1454
- };
1455
1398
 
1456
- }).call(MatchingBraceOutdent.prototype);
1399
+ oop.inherits(CstyleBehaviour, Behaviour);
1457
1400
 
1458
- exports.MatchingBraceOutdent = MatchingBraceOutdent;
1401
+ exports.CstyleBehaviour = CstyleBehaviour;
1459
1402
  });
1460
1403
 
1461
- define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1462
-
1404
+ define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
1405
+ "use strict";
1463
1406
 
1464
1407
  var oop = require("../../lib/oop");
1465
1408
  var Range = require("../../range").Range;
@@ -1553,8 +1496,95 @@ oop.inherits(FoldMode, BaseFoldMode);
1553
1496
 
1554
1497
  });
1555
1498
 
1556
- define('ace/mode/svg_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/javascript_highlight_rules', 'ace/mode/xml_highlight_rules'], function(require, exports, module) {
1499
+ define("ace/mode/javascript",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/javascript_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/worker/worker_client","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
1500
+ "use strict";
1501
+
1502
+ var oop = require("../lib/oop");
1503
+ var TextMode = require("./text").Mode;
1504
+ var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
1505
+ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
1506
+ var Range = require("../range").Range;
1507
+ var WorkerClient = require("../worker/worker_client").WorkerClient;
1508
+ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
1509
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1510
+
1511
+ var Mode = function() {
1512
+ this.HighlightRules = JavaScriptHighlightRules;
1513
+
1514
+ this.$outdent = new MatchingBraceOutdent();
1515
+ this.$behaviour = new CstyleBehaviour();
1516
+ this.foldingRules = new CStyleFoldMode();
1517
+ };
1518
+ oop.inherits(Mode, TextMode);
1519
+
1520
+ (function() {
1521
+
1522
+ this.lineCommentStart = "//";
1523
+ this.blockComment = {start: "/*", end: "*/"};
1524
+
1525
+ this.getNextLineIndent = function(state, line, tab) {
1526
+ var indent = this.$getIndent(line);
1527
+
1528
+ var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
1529
+ var tokens = tokenizedLine.tokens;
1530
+ var endState = tokenizedLine.state;
1531
+
1532
+ if (tokens.length && tokens[tokens.length-1].type == "comment") {
1533
+ return indent;
1534
+ }
1535
+
1536
+ if (state == "start" || state == "no_regex") {
1537
+ var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
1538
+ if (match) {
1539
+ indent += tab;
1540
+ }
1541
+ } else if (state == "doc-start") {
1542
+ if (endState == "start" || endState == "no_regex") {
1543
+ return "";
1544
+ }
1545
+ var match = line.match(/^\s*(\/?)\*/);
1546
+ if (match) {
1547
+ if (match[1]) {
1548
+ indent += " ";
1549
+ }
1550
+ indent += "* ";
1551
+ }
1552
+ }
1553
+
1554
+ return indent;
1555
+ };
1556
+
1557
+ this.checkOutdent = function(state, line, input) {
1558
+ return this.$outdent.checkOutdent(line, input);
1559
+ };
1560
+
1561
+ this.autoOutdent = function(state, doc, row) {
1562
+ this.$outdent.autoOutdent(doc, row);
1563
+ };
1564
+
1565
+ this.createWorker = function(session) {
1566
+ var worker = new WorkerClient(["ace"], "ace/mode/javascript_worker", "JavaScriptWorker");
1567
+ worker.attachToDocument(session.getDocument());
1568
+
1569
+ worker.on("jslint", function(results) {
1570
+ session.setAnnotations(results.data);
1571
+ });
1572
+
1573
+ worker.on("terminate", function() {
1574
+ session.clearAnnotations();
1575
+ });
1576
+
1577
+ return worker;
1578
+ };
1579
+
1580
+ this.$id = "ace/mode/javascript";
1581
+ }).call(Mode.prototype);
1582
+
1583
+ exports.Mode = Mode;
1584
+ });
1557
1585
 
1586
+ define("ace/mode/svg_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/javascript_highlight_rules","ace/mode/xml_highlight_rules"], function(require, exports, module) {
1587
+ "use strict";
1558
1588
 
1559
1589
  var oop = require("../lib/oop");
1560
1590
  var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules;
@@ -1573,8 +1603,8 @@ oop.inherits(SvgHighlightRules, XmlHighlightRules);
1573
1603
  exports.SvgHighlightRules = SvgHighlightRules;
1574
1604
  });
1575
1605
 
1576
- define('ace/mode/folding/mixed', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
1577
-
1606
+ define("ace/mode/folding/mixed",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode"], function(require, exports, module) {
1607
+ "use strict";
1578
1608
 
1579
1609
  var oop = require("../../lib/oop");
1580
1610
  var BaseFoldMode = require("./fold_mode").FoldMode;
@@ -1626,3 +1656,43 @@ oop.inherits(FoldMode, BaseFoldMode);
1626
1656
  }).call(FoldMode.prototype);
1627
1657
 
1628
1658
  });
1659
+
1660
+ define("ace/mode/svg",["require","exports","module","ace/lib/oop","ace/mode/xml","ace/mode/javascript","ace/mode/svg_highlight_rules","ace/mode/folding/mixed","ace/mode/folding/xml","ace/mode/folding/cstyle"], function(require, exports, module) {
1661
+ "use strict";
1662
+
1663
+ var oop = require("../lib/oop");
1664
+ var XmlMode = require("./xml").Mode;
1665
+ var JavaScriptMode = require("./javascript").Mode;
1666
+ var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules;
1667
+ var MixedFoldMode = require("./folding/mixed").FoldMode;
1668
+ var XmlFoldMode = require("./folding/xml").FoldMode;
1669
+ var CStyleFoldMode = require("./folding/cstyle").FoldMode;
1670
+
1671
+ var Mode = function() {
1672
+ XmlMode.call(this);
1673
+
1674
+ this.HighlightRules = SvgHighlightRules;
1675
+
1676
+ this.createModeDelegates({
1677
+ "js-": JavaScriptMode
1678
+ });
1679
+
1680
+ this.foldingRules = new MixedFoldMode(new XmlFoldMode(), {
1681
+ "js-": new CStyleFoldMode()
1682
+ });
1683
+ };
1684
+
1685
+ oop.inherits(Mode, XmlMode);
1686
+
1687
+ (function() {
1688
+
1689
+ this.getNextLineIndent = function(state, line, tab) {
1690
+ return this.$getIndent(line);
1691
+ };
1692
+
1693
+
1694
+ this.$id = "ace/mode/svg";
1695
+ }).call(Mode.prototype);
1696
+
1697
+ exports.Mode = Mode;
1698
+ });