marty 2.4.7 → 2.4.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile.dummy +8 -5
  3. data/Gemfile.lock +1 -1
  4. data/README.md +8 -0
  5. data/app/assets/javascripts/marty/application.js +1 -0
  6. data/app/assets/javascripts/marty/codemirror/codemirror.js +9730 -0
  7. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/delorean/delorean.js +0 -0
  8. data/app/assets/javascripts/marty/codemirror/mode/javascript/javascript.js +900 -0
  9. data/app/assets/javascripts/marty/codemirror/mode/python/python.js +399 -0
  10. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/ruby/ruby.js +135 -34
  11. data/app/{components/marty/script_form/client/Ext.ux.form.field.CodeMirror.js → assets/javascripts/marty/extjs/extensions/marty.js} +87 -6
  12. data/app/assets/stylesheets/marty/application.css +1 -13
  13. data/app/assets/stylesheets/marty/codemirror/codemirror.css +346 -0
  14. data/app/{components/marty/script_form/client → assets/stylesheets/marty/codemirror}/delorean.css +0 -0
  15. data/app/components/marty/auth_app/client/auth_app.js +82 -80
  16. data/app/components/marty/data_grid_view.rb +1 -54
  17. data/app/components/marty/data_grid_view/client/data_grid_view.js +49 -0
  18. data/app/components/marty/form.rb +1 -5
  19. data/app/components/marty/form/client/form.js +5 -0
  20. data/app/components/marty/grid.rb +1 -146
  21. data/app/components/marty/grid/client/grid.js +146 -0
  22. data/app/components/marty/import_view.rb +1 -32
  23. data/app/components/marty/import_view/client/import_view.js +32 -0
  24. data/app/components/marty/live_search_grid_panel.rb +1 -21
  25. data/app/components/marty/live_search_grid_panel/client/live_search_grid_panel.js +27 -0
  26. data/app/components/marty/main_auth_app.rb +4 -145
  27. data/app/components/marty/main_auth_app/client/main_auth_app.js +124 -0
  28. data/app/components/marty/mcfly_grid_panel.rb +1 -17
  29. data/app/components/marty/mcfly_grid_panel/client/mcfly_grid_panel.js +37 -0
  30. data/app/components/marty/new_posting_form.rb +1 -6
  31. data/app/components/marty/new_posting_form/client/new_posting_form.js +6 -0
  32. data/app/components/marty/panel.rb +1 -5
  33. data/app/components/marty/panel/client/panel.js +5 -0
  34. data/app/components/marty/posting_grid.rb +4 -55
  35. data/app/components/marty/posting_grid/client/posting_grid.js +50 -0
  36. data/app/components/marty/promise_view.rb +2 -75
  37. data/app/components/marty/promise_view/client/promise_view.css +12 -9
  38. data/app/components/marty/promise_view/client/promise_view.js +57 -0
  39. data/app/components/marty/report_form.rb +3 -69
  40. data/app/components/marty/report_form/client/report_form.js +78 -0
  41. data/app/components/marty/report_select.rb +1 -45
  42. data/app/components/marty/report_select/client/report_select.js +50 -0
  43. data/app/components/marty/reporting.rb +1 -8
  44. data/app/components/marty/reporting/client/reporting.js +8 -0
  45. data/app/components/marty/script_form.rb +2 -63
  46. data/app/components/marty/script_form/client/script_form.js +44 -0
  47. data/app/components/marty/script_tester.rb +1 -7
  48. data/app/components/marty/script_tester/client/script_tester.js +7 -0
  49. data/app/components/marty/scripting.rb +1 -55
  50. data/app/components/marty/scripting/client/scripting.js +62 -0
  51. data/app/components/marty/simple_app/client/simple_app.js +21 -13
  52. data/app/models/marty/promise.rb +22 -1
  53. data/app/views/layouts/marty/application.html.erb +8 -6
  54. data/docker-compose.dummy.yml +2 -0
  55. data/lib/marty/monkey.rb +0 -16
  56. data/lib/marty/version.rb +1 -1
  57. data/spec/dummy/config/initializers/assets.rb +1 -0
  58. data/spec/features/reporting_spec.rb +1 -0
  59. data/spec/features/scripting_spec.rb +4 -4
  60. data/spec/spec_helper.rb +1 -0
  61. data/spec/support/chromedriver.rb +5 -1
  62. data/spec/support/shared_connection_db_helpers.rb +42 -2
  63. metadata +29 -168
  64. data/app/assets/images/marty/.gitkeep +0 -0
  65. data/app/components/marty/mcfly_grid_panel/client/dup_in_form.js +0 -20
  66. data/app/components/marty/script_form/client/codemirror.css +0 -172
  67. data/app/components/marty/script_form/client/codemirror.js +0 -3130
  68. data/app/components/marty/script_form/client/mode/clike/clike.js +0 -284
  69. data/app/components/marty/script_form/client/mode/clike/index.html +0 -102
  70. data/app/components/marty/script_form/client/mode/clike/scala.html +0 -766
  71. data/app/components/marty/script_form/client/mode/clojure/clojure.js +0 -206
  72. data/app/components/marty/script_form/client/mode/clojure/index.html +0 -67
  73. data/app/components/marty/script_form/client/mode/coffeescript/LICENSE +0 -22
  74. data/app/components/marty/script_form/client/mode/coffeescript/coffeescript.js +0 -346
  75. data/app/components/marty/script_form/client/mode/coffeescript/index.html +0 -728
  76. data/app/components/marty/script_form/client/mode/commonlisp/commonlisp.js +0 -101
  77. data/app/components/marty/script_form/client/mode/commonlisp/index.html +0 -165
  78. data/app/components/marty/script_form/client/mode/css/css.js +0 -448
  79. data/app/components/marty/script_form/client/mode/css/index.html +0 -58
  80. data/app/components/marty/script_form/client/mode/css/test.js +0 -501
  81. data/app/components/marty/script_form/client/mode/diff/diff.js +0 -32
  82. data/app/components/marty/script_form/client/mode/diff/index.html +0 -105
  83. data/app/components/marty/script_form/client/mode/ecl/ecl.js +0 -203
  84. data/app/components/marty/script_form/client/mode/ecl/index.html +0 -42
  85. data/app/components/marty/script_form/client/mode/erlang/erlang.js +0 -463
  86. data/app/components/marty/script_form/client/mode/erlang/index.html +0 -63
  87. data/app/components/marty/script_form/client/mode/gfm/gfm.js +0 -150
  88. data/app/components/marty/script_form/client/mode/gfm/index.html +0 -48
  89. data/app/components/marty/script_form/client/mode/go/go.js +0 -170
  90. data/app/components/marty/script_form/client/mode/go/index.html +0 -73
  91. data/app/components/marty/script_form/client/mode/groovy/groovy.js +0 -210
  92. data/app/components/marty/script_form/client/mode/groovy/index.html +0 -72
  93. data/app/components/marty/script_form/client/mode/haskell/haskell.js +0 -242
  94. data/app/components/marty/script_form/client/mode/haskell/index.html +0 -61
  95. data/app/components/marty/script_form/client/mode/haxe/haxe.js +0 -429
  96. data/app/components/marty/script_form/client/mode/haxe/index.html +0 -91
  97. data/app/components/marty/script_form/client/mode/htmlembedded/htmlembedded.js +0 -72
  98. data/app/components/marty/script_form/client/mode/htmlembedded/index.html +0 -50
  99. data/app/components/marty/script_form/client/mode/htmlmixed/htmlmixed.js +0 -84
  100. data/app/components/marty/script_form/client/mode/htmlmixed/index.html +0 -52
  101. data/app/components/marty/script_form/client/mode/javascript/index.html +0 -78
  102. data/app/components/marty/script_form/client/mode/javascript/javascript.js +0 -361
  103. data/app/components/marty/script_form/client/mode/jinja2/index.html +0 -38
  104. data/app/components/marty/script_form/client/mode/jinja2/jinja2.js +0 -42
  105. data/app/components/marty/script_form/client/mode/less/index.html +0 -740
  106. data/app/components/marty/script_form/client/mode/less/less.js +0 -266
  107. data/app/components/marty/script_form/client/mode/lua/index.html +0 -73
  108. data/app/components/marty/script_form/client/mode/lua/lua.js +0 -140
  109. data/app/components/marty/script_form/client/mode/markdown/index.html +0 -343
  110. data/app/components/marty/script_form/client/mode/markdown/markdown.js +0 -382
  111. data/app/components/marty/script_form/client/mode/markdown/test.js +0 -1084
  112. data/app/components/marty/script_form/client/mode/mysql/index.html +0 -42
  113. data/app/components/marty/script_form/client/mode/mysql/mysql.js +0 -186
  114. data/app/components/marty/script_form/client/mode/ntriples/index.html +0 -33
  115. data/app/components/marty/script_form/client/mode/ntriples/ntriples.js +0 -172
  116. data/app/components/marty/script_form/client/mode/ocaml/index.html +0 -130
  117. data/app/components/marty/script_form/client/mode/ocaml/ocaml.js +0 -114
  118. data/app/components/marty/script_form/client/mode/pascal/LICENSE +0 -7
  119. data/app/components/marty/script_form/client/mode/pascal/index.html +0 -49
  120. data/app/components/marty/script_form/client/mode/pascal/pascal.js +0 -94
  121. data/app/components/marty/script_form/client/mode/perl/LICENSE +0 -19
  122. data/app/components/marty/script_form/client/mode/perl/index.html +0 -63
  123. data/app/components/marty/script_form/client/mode/perl/perl.js +0 -816
  124. data/app/components/marty/script_form/client/mode/php/index.html +0 -49
  125. data/app/components/marty/script_form/client/mode/php/php.js +0 -148
  126. data/app/components/marty/script_form/client/mode/pig/index.html +0 -43
  127. data/app/components/marty/script_form/client/mode/pig/pig.js +0 -172
  128. data/app/components/marty/script_form/client/mode/plsql/index.html +0 -63
  129. data/app/components/marty/script_form/client/mode/plsql/plsql.js +0 -217
  130. data/app/components/marty/script_form/client/mode/properties/index.html +0 -41
  131. data/app/components/marty/script_form/client/mode/properties/properties.js +0 -63
  132. data/app/components/marty/script_form/client/mode/python/LICENSE.txt +0 -21
  133. data/app/components/marty/script_form/client/mode/python/index.html +0 -123
  134. data/app/components/marty/script_form/client/mode/python/python.js +0 -338
  135. data/app/components/marty/script_form/client/mode/r/LICENSE +0 -24
  136. data/app/components/marty/script_form/client/mode/r/index.html +0 -74
  137. data/app/components/marty/script_form/client/mode/r/r.js +0 -141
  138. data/app/components/marty/script_form/client/mode/rpm/changes/changes.js +0 -19
  139. data/app/components/marty/script_form/client/mode/rpm/changes/index.html +0 -54
  140. data/app/components/marty/script_form/client/mode/rpm/spec/index.html +0 -100
  141. data/app/components/marty/script_form/client/mode/rpm/spec/spec.css +0 -5
  142. data/app/components/marty/script_form/client/mode/rpm/spec/spec.js +0 -66
  143. data/app/components/marty/script_form/client/mode/rst/index.html +0 -526
  144. data/app/components/marty/script_form/client/mode/rst/rst.js +0 -326
  145. data/app/components/marty/script_form/client/mode/ruby/LICENSE +0 -24
  146. data/app/components/marty/script_form/client/mode/ruby/index.html +0 -172
  147. data/app/components/marty/script_form/client/mode/rust/index.html +0 -49
  148. data/app/components/marty/script_form/client/mode/rust/rust.js +0 -432
  149. data/app/components/marty/script_form/client/mode/scheme/index.html +0 -65
  150. data/app/components/marty/script_form/client/mode/scheme/scheme.js +0 -230
  151. data/app/components/marty/script_form/client/mode/shell/index.html +0 -50
  152. data/app/components/marty/script_form/client/mode/shell/shell.js +0 -118
  153. data/app/components/marty/script_form/client/mode/sieve/LICENSE +0 -23
  154. data/app/components/marty/script_form/client/mode/sieve/index.html +0 -81
  155. data/app/components/marty/script_form/client/mode/sieve/sieve.js +0 -156
  156. data/app/components/marty/script_form/client/mode/smalltalk/index.html +0 -56
  157. data/app/components/marty/script_form/client/mode/smalltalk/smalltalk.js +0 -139
  158. data/app/components/marty/script_form/client/mode/smarty/index.html +0 -83
  159. data/app/components/marty/script_form/client/mode/smarty/smarty.js +0 -148
  160. data/app/components/marty/script_form/client/mode/sparql/index.html +0 -41
  161. data/app/components/marty/script_form/client/mode/sparql/sparql.js +0 -143
  162. data/app/components/marty/script_form/client/mode/stex/index.html +0 -98
  163. data/app/components/marty/script_form/client/mode/stex/stex.js +0 -182
  164. data/app/components/marty/script_form/client/mode/stex/test.js +0 -343
  165. data/app/components/marty/script_form/client/mode/tiddlywiki/index.html +0 -141
  166. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.css +0 -14
  167. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.js +0 -384
  168. data/app/components/marty/script_form/client/mode/tiki/index.html +0 -83
  169. data/app/components/marty/script_form/client/mode/tiki/tiki.css +0 -26
  170. data/app/components/marty/script_form/client/mode/tiki/tiki.js +0 -309
  171. data/app/components/marty/script_form/client/mode/vb/LICENSE.txt +0 -21
  172. data/app/components/marty/script_form/client/mode/vb/index.html +0 -89
  173. data/app/components/marty/script_form/client/mode/vb/vb.js +0 -260
  174. data/app/components/marty/script_form/client/mode/vbscript/index.html +0 -43
  175. data/app/components/marty/script_form/client/mode/vbscript/vbscript.js +0 -26
  176. data/app/components/marty/script_form/client/mode/velocity/index.html +0 -104
  177. data/app/components/marty/script_form/client/mode/velocity/velocity.js +0 -146
  178. data/app/components/marty/script_form/client/mode/verilog/index.html +0 -211
  179. data/app/components/marty/script_form/client/mode/verilog/verilog.js +0 -194
  180. data/app/components/marty/script_form/client/mode/xml/index.html +0 -45
  181. data/app/components/marty/script_form/client/mode/xml/xml.js +0 -318
  182. data/app/components/marty/script_form/client/mode/xquery/LICENSE +0 -20
  183. data/app/components/marty/script_form/client/mode/xquery/index.html +0 -223
  184. data/app/components/marty/script_form/client/mode/xquery/test/index.html +0 -27
  185. data/app/components/marty/script_form/client/mode/xquery/test/testBase.js +0 -42
  186. data/app/components/marty/script_form/client/mode/xquery/test/testEmptySequenceKeyword.js +0 -16
  187. data/app/components/marty/script_form/client/mode/xquery/test/testMultiAttr.js +0 -16
  188. data/app/components/marty/script_form/client/mode/xquery/test/testNamespaces.js +0 -91
  189. data/app/components/marty/script_form/client/mode/xquery/test/testProcessingInstructions.js +0 -16
  190. data/app/components/marty/script_form/client/mode/xquery/test/testQuotes.js +0 -19
  191. data/app/components/marty/script_form/client/mode/xquery/xquery.js +0 -451
  192. data/app/components/marty/script_form/client/mode/yaml/index.html +0 -68
  193. data/app/components/marty/script_form/client/mode/yaml/yaml.js +0 -95
  194. data/app/components/marty/script_form/client/theme/ambiance.css +0 -81
  195. data/app/components/marty/script_form/client/theme/blackboard.css +0 -25
  196. data/app/components/marty/script_form/client/theme/cobalt.css +0 -18
  197. data/app/components/marty/script_form/client/theme/eclipse.css +0 -25
  198. data/app/components/marty/script_form/client/theme/elegant.css +0 -10
  199. data/app/components/marty/script_form/client/theme/erlang-dark.css +0 -21
  200. data/app/components/marty/script_form/client/theme/lesser-dark.css +0 -44
  201. data/app/components/marty/script_form/client/theme/monokai.css +0 -28
  202. data/app/components/marty/script_form/client/theme/neat.css +0 -9
  203. data/app/components/marty/script_form/client/theme/night.css +0 -21
  204. data/app/components/marty/script_form/client/theme/rubyblue.css +0 -21
  205. data/app/components/marty/script_form/client/theme/vibrant-ink.css +0 -27
  206. data/app/components/marty/script_form/client/theme/xq-dark.css +0 -46
  207. data/app/components/marty/script_form/client/util/closetag.js +0 -164
  208. data/app/components/marty/script_form/client/util/dialog.css +0 -27
  209. data/app/components/marty/script_form/client/util/dialog.js +0 -70
  210. data/app/components/marty/script_form/client/util/foldcode.js +0 -196
  211. data/app/components/marty/script_form/client/util/formatting.js +0 -193
  212. data/app/components/marty/script_form/client/util/javascript-hint.js +0 -134
  213. data/app/components/marty/script_form/client/util/loadmode.js +0 -51
  214. data/app/components/marty/script_form/client/util/match-highlighter.js +0 -44
  215. data/app/components/marty/script_form/client/util/multiplex.js +0 -77
  216. data/app/components/marty/script_form/client/util/overlay.js +0 -54
  217. data/app/components/marty/script_form/client/util/pig-hint.js +0 -123
  218. data/app/components/marty/script_form/client/util/runmode-standalone.js +0 -90
  219. data/app/components/marty/script_form/client/util/runmode.js +0 -53
  220. data/app/components/marty/script_form/client/util/search.js +0 -118
  221. data/app/components/marty/script_form/client/util/searchcursor.js +0 -119
  222. data/app/components/marty/script_form/client/util/simple-hint.css +0 -16
  223. data/app/components/marty/script_form/client/util/simple-hint.js +0 -97
  224. data/app/components/marty/script_form/client/util/xml-hint.js +0 -137
  225. data/lib/marty/javascript/grid_view_in_form.js +0 -81
@@ -1,27 +0,0 @@
1
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
- "http://www.w3.org/TR/html4/loose.dtd">
3
- <html>
4
- <head>
5
- <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css"/>
6
- <script src="http://code.jquery.com/jquery-latest.js"> </script>
7
- <script type="text/javascript" src="http://code.jquery.com/qunit/qunit-git.js"></script>
8
-
9
- <script src="../../../lib/codemirror.js"></script>
10
- <script src="../xquery.js"></script>
11
-
12
- <script type="text/javascript" src="testBase.js"></script>
13
- <script type="text/javascript" src="testMultiAttr.js"></script>
14
- <script type="text/javascript" src="testQuotes.js"></script>
15
- <script type="text/javascript" src="testEmptySequenceKeyword.js"></script>
16
- <script type="text/javascript" src="testProcessingInstructions.js"></script>
17
- <script type="text/javascript" src="testNamespaces.js"></script>
18
- </head>
19
- <body>
20
- <h1 id="qunit-header">XQuery CodeMirror Mode</h1>
21
- <h2 id="qunit-banner"></h2>
22
- <h2 id="qunit-userAgent"></h2>
23
- <ol id="qunit-tests">
24
- </ol>
25
- <div id="sandbox" style="right:5000px; position:absolute; "></div>
26
- </body>
27
- </html>
@@ -1,42 +0,0 @@
1
- $(document).ready(function(){
2
- module("testBase");
3
- test("eviltest", function() {
4
- expect(1);
5
-
6
- var input = 'xquery version &quot;1.0-ml&quot;;\
7
- (: this is\
8
- : a \
9
- "comment" :)\
10
- let $let := &lt;x attr=&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt;function() $var {function()} {$var}&lt;/func&gt;&lt;/x&gt;\
11
- let $joe:=1\
12
- return element element {\
13
- attribute attribute { 1 },\
14
- element test { &#39;a&#39; }, \
15
- attribute foo { &quot;bar&quot; },\
16
- fn:doc()[ foo/@bar eq $let ],\
17
- //x } \
18
- \
19
- (: a more \'evil\' test :)\
20
- (: Modified Blakeley example (: with nested comment :) ... :)\
21
- declare private function local:declare() {()};\
22
- declare private function local:private() {()};\
23
- declare private function local:function() {()};\
24
- declare private function local:local() {()};\
25
- let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;\
26
- return element element {\
27
- attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },\
28
- attribute fn:doc { &quot;bar&quot; castable as xs:string },\
29
- element text { text { &quot;text&quot; } },\
30
- fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],\
31
- //fn:doc\
32
- }';
33
- var expected = '<span class="cm-keyword">xquery</span> <span class="cm-keyword">version</span> <span class="cm-string">"1.0-ml"</span><span class="cm-variable cm-def">;</span> <span class="cm-comment">(: this is : a "comment" :)</span> <span class="cm-keyword">let</span> <span class="cm-variable">$let</span> <span class="cm-keyword">:=</span> <span class="cm-tag">&lt;x </span><span class="cm-attribute">attr</span>=<span class="cm-string">"value"</span><span class="cm-tag">&gt;</span><span class="cm-word">"test"</span><span class="cm-tag">&lt;func&gt;</span><span class="cm-word">function()</span> <span class="cm-word">$var</span> {<span class="cm-keyword">function</span>()} {<span class="cm-variable">$var</span>}<span class="cm-tag">&lt;/func&gt;&lt;/x&gt;</span> <span class="cm-keyword">let</span> <span class="cm-variable">$joe</span><span class="cm-keyword">:=</span><span class="cm-atom">1</span> <span class="cm-keyword">return</span> <span class="cm-keyword">element</span> <span class="cm-word">element</span> { <span class="cm-keyword">attribute</span> <span class="cm-word">attribute</span> { <span class="cm-atom">1</span> }, <span class="cm-keyword">element</span> <span class="cm-word">test</span> { <span class="cm-string">\'a\'</span> }, <span class="cm-keyword">attribute</span> <span class="cm-word">foo</span> { <span class="cm-string">"bar"</span> }, <span class="cm-variable cm-def">fn:doc</span>()[ <span class="cm-word">foo</span><span class="cm-keyword">/</span><span class="cm-word">@bar</span> <span class="cm-keyword">eq</span> <span class="cm-variable">$let</span> ], <span class="cm-keyword">//</span><span class="cm-word">x</span> } <span class="cm-comment">(: a more \'evil\' test :)</span> <span class="cm-comment">(: Modified Blakeley example (: with nested comment :) ... :)</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:declare</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:private</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:function</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">declare</span> <span class="cm-keyword">private</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">local:local</span>() {()}<span class="cm-word">;</span> <span class="cm-keyword">let</span> <span class="cm-variable">$let</span> <span class="cm-keyword">:=</span> <span class="cm-tag">&lt;let&gt;</span><span class="cm-word">let</span> <span class="cm-word">$let</span> <span class="cm-word">:=</span> <span class="cm-word">"let"</span><span class="cm-tag">&lt;/let&gt;</span> <span class="cm-keyword">return</span> <span class="cm-keyword">element</span> <span class="cm-word">element</span> { <span class="cm-keyword">attribute</span> <span class="cm-word">attribute</span> { <span class="cm-keyword">try</span> { <span class="cm-variable cm-def">xdmp:version</span>() } <span class="cm-keyword">catch</span>(<span class="cm-variable">$e</span>) { <span class="cm-variable cm-def">xdmp:log</span>(<span class="cm-variable">$e</span>) } }, <span class="cm-keyword">attribute</span> <span class="cm-word">fn:doc</span> { <span class="cm-string">"bar"</span> <span class="cm-word">castable</span> <span class="cm-keyword">as</span> <span class="cm-atom">xs:string</span> }, <span class="cm-keyword">element</span> <span class="cm-word">text</span> { <span class="cm-keyword">text</span> { <span class="cm-string">"text"</span> } }, <span class="cm-variable cm-def">fn:doc</span>()[ <span class="cm-qualifier">child::</span><span class="cm-word">eq</span><span class="cm-keyword">/</span>(<span class="cm-word">@bar</span> <span class="cm-keyword">|</span> <span class="cm-qualifier">attribute::</span><span class="cm-word">attribute</span>) <span class="cm-keyword">eq</span> <span class="cm-variable">$let</span> ], <span class="cm-keyword">//</span><span class="cm-word">fn:doc</span> }';
34
-
35
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
36
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
37
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
38
-
39
- equal(result, expected);
40
- $("#editor").html("");
41
- });
42
- });
@@ -1,16 +0,0 @@
1
- $(document).ready(function(){
2
- module("testEmptySequenceKeyword");
3
- test("testEmptySequenceKeyword", function() {
4
- expect(1);
5
-
6
- var input = '"foo" instance of empty-sequence()';
7
- var expected = '<span class="cm-string">"foo"</span> <span class="cm-keyword">instance</span> <span class="cm-keyword">of</span> <span class="cm-keyword">empty-sequence</span>()';
8
-
9
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
10
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
11
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
12
-
13
- equal(result, expected);
14
- $("#editor").html("");
15
- });
16
- });
@@ -1,16 +0,0 @@
1
- $(document).ready(function(){
2
- module("testMultiAttr");
3
- test("test1", function() {
4
- expect(1);
5
-
6
- var expected = '<span class="cm-tag">&lt;p </span><span class="cm-attribute">a1</span>=<span class="cm-string">"foo"</span> <span class="cm-attribute">a2</span>=<span class="cm-string">"bar"</span><span class="cm-tag">&gt;</span><span class="cm-word">hello</span> <span class="cm-word">world</span><span class="cm-tag">&lt;/p&gt;</span>';
7
-
8
- $("#sandbox").html('<textarea id="editor"></textarea>');
9
- $("#editor").html('<p a1="foo" a2="bar">hello world</p>');
10
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
11
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
12
-
13
- equal(result, expected);
14
- $("#editor").html("");
15
- });
16
- });
@@ -1,91 +0,0 @@
1
- $(document).ready(function(){
2
- module("test namespaces");
3
-
4
- // --------------------------------------------------------------------------------
5
- // this test is based on this:
6
- //http://mbrevoort.github.com/CodeMirror2/#!exprSeqTypes/PrologExpr/VariableProlog/ExternalVariablesWith/K2-ExternalVariablesWith-10.xq
7
- // --------------------------------------------------------------------------------
8
- test("test namespaced variable", function() {
9
- expect(1);
10
-
11
- var input = 'declare namespace e = "http://example.com/ANamespace";\
12
- declare variable $e:exampleComThisVarIsNotRecognized as element(*) external;';
13
-
14
- var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">namespace</span> <span class="cm-word">e</span> <span class="cm-keyword">=</span> <span class="cm-string">"http://example.com/ANamespace"</span><span class="cm-word">;declare</span> <span class="cm-keyword">variable</span> <span class="cm-variable">$e:exampleComThisVarIsNotRecognized</span> <span class="cm-keyword">as</span> <span class="cm-keyword">element</span>(<span class="cm-keyword">*</span>) <span class="cm-word">external;</span>';
15
-
16
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
17
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
18
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
19
-
20
- equal(result, expected);
21
- $("#editor").html("");
22
- });
23
-
24
-
25
- // --------------------------------------------------------------------------------
26
- // this test is based on:
27
- // http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-002.xq
28
- // --------------------------------------------------------------------------------
29
- test("test EQName variable", function() {
30
- expect(1);
31
-
32
- var input = 'declare variable $"http://www.example.com/ns/my":var := 12;\
33
- <out>{$"http://www.example.com/ns/my":var}</out>';
34
-
35
- var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">variable</span> <span class="cm-variable">$"http://www.example.com/ns/my":var</span> <span class="cm-keyword">:=</span> <span class="cm-atom">12</span><span class="cm-word">;</span><span class="cm-tag">&lt;out&gt;</span>{<span class="cm-variable">$"http://www.example.com/ns/my":var</span>}<span class="cm-tag">&lt;/out&gt;</span>';
36
-
37
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
38
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
39
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
40
-
41
- equal(result, expected);
42
- $("#editor").html("");
43
- });
44
-
45
- // --------------------------------------------------------------------------------
46
- // this test is based on:
47
- // http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-003.xq
48
- // --------------------------------------------------------------------------------
49
- test("test EQName function", function() {
50
- expect(1);
51
-
52
- var input = 'declare function "http://www.example.com/ns/my":fn ($a as xs:integer) as xs:integer {\
53
- $a + 2\
54
- };\
55
- <out>{"http://www.example.com/ns/my":fn(12)}</out>';
56
-
57
- var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">"http://www.example.com/ns/my":fn</span> (<span class="cm-variable">$a</span> <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span>) <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span> { <span class="cm-variable">$a</span> <span class="cm-keyword">+</span> <span class="cm-atom">2</span>}<span class="cm-word">;</span><span class="cm-tag">&lt;out&gt;</span>{<span class="cm-variable cm-def">"http://www.example.com/ns/my":fn</span>(<span class="cm-atom">12</span>)}<span class="cm-tag">&lt;/out&gt;</span>';
58
-
59
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
60
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
61
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
62
-
63
- equal(result, expected);
64
- $("#editor").html("");
65
- });
66
-
67
- // --------------------------------------------------------------------------------
68
- // this test is based on:
69
- // http://mbrevoort.github.com/CodeMirror2/#!Basics/EQNames/eqname-003.xq
70
- // --------------------------------------------------------------------------------
71
- test("test EQName function with single quotes", function() {
72
- expect(1);
73
-
74
- var input = 'declare function \'http://www.example.com/ns/my\':fn ($a as xs:integer) as xs:integer {\
75
- $a + 2\
76
- };\
77
- <out>{\'http://www.example.com/ns/my\':fn(12)}</out>';
78
-
79
- var expected = '<span class="cm-keyword">declare</span> <span class="cm-keyword">function</span> <span class="cm-variable cm-def">\'http://www.example.com/ns/my\':fn</span> (<span class="cm-variable">$a</span> <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span>) <span class="cm-keyword">as</span> <span class="cm-atom">xs:integer</span> { <span class="cm-variable">$a</span> <span class="cm-keyword">+</span> <span class="cm-atom">2</span>}<span class="cm-word">;</span><span class="cm-tag">&lt;out&gt;</span>{<span class="cm-variable cm-def">\'http://www.example.com/ns/my\':fn</span>(<span class="cm-atom">12</span>)}<span class="cm-tag">&lt;/out&gt;</span>';
80
-
81
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
82
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
83
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
84
-
85
- equal(result, expected);
86
- $("#editor").html("");
87
- });
88
-
89
- });
90
-
91
-
@@ -1,16 +0,0 @@
1
- $(document).ready(function(){
2
- module("testProcessingInstructions");
3
- test("testProcessingInstructions", function() {
4
- expect(1);
5
-
6
- var input = 'data(<?target content?>) instance of xs:string';
7
- var expected = '<span class="cm-variable cm-def">data</span>(<span class="cm-comment cm-meta">&lt;?target content?&gt;</span>) <span class="cm-keyword">instance</span> <span class="cm-keyword">of</span> <span class="cm-atom">xs:string</span>';
8
-
9
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
10
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
11
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
12
-
13
- equal(result, expected);
14
- $("#editor").html("");
15
- });
16
- });
@@ -1,19 +0,0 @@
1
- $(document).ready(function(){
2
- module("testQuoteEscape");
3
- test("testQuoteEscapeDouble", function() {
4
- expect(1);
5
-
6
- var input = 'let $rootfolder := "c:\\builds\\winnt\\HEAD\\qa\\scripts\\"\
7
- let $keysfolder := concat($rootfolder, "keys\\")\
8
- return\
9
- $keysfolder';
10
- var expected = '<span class="cm-keyword">let</span> <span class="cm-variable">$rootfolder</span> <span class="cm-keyword">:=</span> <span class="cm-string">"c:\\builds\\winnt\\HEAD\\qa\\scripts\\"</span><span class="cm-keyword">let</span> <span class="cm-variable">$keysfolder</span> <span class="cm-keyword">:=</span> <span class="cm-variable cm-def">concat</span>(<span class="cm-variable">$rootfolder</span>, <span class="cm-string">"keys\\"</span>)<span class="cm-word">return$keysfolder</span>';
11
-
12
- $("#sandbox").html('<textarea id="editor">' + input + '</textarea>');
13
- var editor = CodeMirror.fromTextArea($("#editor")[0]);
14
- var result = $(".CodeMirror-lines div div pre")[0].innerHTML;
15
-
16
- equal(result, expected);
17
- $("#editor").html("");
18
- });
19
- });
@@ -1,451 +0,0 @@
1
- /*
2
- Copyright (C) 2011 by MarkLogic Corporation
3
- Author: Mike Brevoort <mike@brevoort.com>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
22
- */
23
- CodeMirror.defineMode("xquery", function(config, parserConfig) {
24
-
25
- // The keywords object is set to the result of this self executing
26
- // function. Each keyword is a property of the keywords object whose
27
- // value is {type: atype, style: astyle}
28
- var keywords = function(){
29
- // conveinence functions used to build keywords object
30
- function kw(type) {return {type: type, style: "keyword"};}
31
- var A = kw("keyword a")
32
- , B = kw("keyword b")
33
- , C = kw("keyword c")
34
- , operator = kw("operator")
35
- , atom = {type: "atom", style: "atom"}
36
- , punctuation = {type: "punctuation", style: ""}
37
- , qualifier = {type: "axis_specifier", style: "qualifier"};
38
-
39
- // kwObj is what is return from this function at the end
40
- var kwObj = {
41
- 'if': A, 'switch': A, 'while': A, 'for': A,
42
- 'else': B, 'then': B, 'try': B, 'finally': B, 'catch': B,
43
- 'element': C, 'attribute': C, 'let': C, 'implements': C, 'import': C, 'module': C, 'namespace': C,
44
- 'return': C, 'super': C, 'this': C, 'throws': C, 'where': C, 'private': C,
45
- ',': punctuation,
46
- 'null': atom, 'fn:false()': atom, 'fn:true()': atom
47
- };
48
-
49
- // a list of 'basic' keywords. For each add a property to kwObj with the value of
50
- // {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"}
51
- var basic = ['after','ancestor','ancestor-or-self','and','as','ascending','assert','attribute','before',
52
- 'by','case','cast','child','comment','declare','default','define','descendant','descendant-or-self',
53
- 'descending','document','document-node','element','else','eq','every','except','external','following',
54
- 'following-sibling','follows','for','function','if','import','in','instance','intersect','item',
55
- 'let','module','namespace','node','node','of','only','or','order','parent','precedes','preceding',
56
- 'preceding-sibling','processing-instruction','ref','return','returns','satisfies','schema','schema-element',
57
- 'self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where',
58
- 'xquery', 'empty-sequence'];
59
- for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
60
-
61
- // a list of types. For each add a property to kwObj with the value of
62
- // {type: "atom", style: "atom"}
63
- var types = ['xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime',
64
- 'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary',
65
- 'xs:base64Binary', 'xs:anyURI', 'xs:QName', 'xs:byte','xs:boolean','xs:anyURI','xf:yearMonthDuration'];
66
- for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;};
67
-
68
- // each operator will add a property to kwObj with value of {type: "operator", style: "keyword"}
69
- var operators = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', ':=', '=', '>', '>=', '<', '<=', '.', '|', '?', 'and', 'or', 'div', 'idiv', 'mod', '*', '/', '+', '-'];
70
- for(var i=0, l=operators.length; i < l; i++) { kwObj[operators[i]] = operator;};
71
-
72
- // each axis_specifiers will add a property to kwObj with value of {type: "axis_specifier", style: "qualifier"}
73
- var axis_specifiers = ["self::", "attribute::", "child::", "descendant::", "descendant-or-self::", "parent::",
74
- "ancestor::", "ancestor-or-self::", "following::", "preceding::", "following-sibling::", "preceding-sibling::"];
75
- for(var i=0, l=axis_specifiers.length; i < l; i++) { kwObj[axis_specifiers[i]] = qualifier; };
76
-
77
- return kwObj;
78
- }();
79
-
80
- // Used as scratch variables to communicate multiple values without
81
- // consing up tons of objects.
82
- var type, content;
83
-
84
- function ret(tp, style, cont) {
85
- type = tp; content = cont;
86
- return style;
87
- }
88
-
89
- function chain(stream, state, f) {
90
- state.tokenize = f;
91
- return f(stream, state);
92
- }
93
-
94
- // the primary mode tokenizer
95
- function tokenBase(stream, state) {
96
- var ch = stream.next(),
97
- mightBeFunction = false,
98
- isEQName = isEQNameAhead(stream);
99
-
100
- // an XML tag (if not in some sub, chained tokenizer)
101
- if (ch == "<") {
102
- if(stream.match("!--", true))
103
- return chain(stream, state, tokenXMLComment);
104
-
105
- if(stream.match("![CDATA", false)) {
106
- state.tokenize = tokenCDATA;
107
- return ret("tag", "tag");
108
- }
109
-
110
- if(stream.match("?", false)) {
111
- return chain(stream, state, tokenPreProcessing);
112
- }
113
-
114
- var isclose = stream.eat("/");
115
- stream.eatSpace();
116
- var tagName = "", c;
117
- while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
118
-
119
- return chain(stream, state, tokenTag(tagName, isclose));
120
- }
121
- // start code block
122
- else if(ch == "{") {
123
- pushStateStack(state,{ type: "codeblock"});
124
- return ret("", "");
125
- }
126
- // end code block
127
- else if(ch == "}") {
128
- popStateStack(state);
129
- return ret("", "");
130
- }
131
- // if we're in an XML block
132
- else if(isInXmlBlock(state)) {
133
- if(ch == ">")
134
- return ret("tag", "tag");
135
- else if(ch == "/" && stream.eat(">")) {
136
- popStateStack(state);
137
- return ret("tag", "tag");
138
- }
139
- else
140
- return ret("word", "variable");
141
- }
142
- // if a number
143
- else if (/\d/.test(ch)) {
144
- stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
145
- return ret("number", "atom");
146
- }
147
- // comment start
148
- else if (ch === "(" && stream.eat(":")) {
149
- pushStateStack(state, { type: "comment"});
150
- return chain(stream, state, tokenComment);
151
- }
152
- // quoted string
153
- else if ( !isEQName && (ch === '"' || ch === "'"))
154
- return chain(stream, state, tokenString(ch));
155
- // variable
156
- else if(ch === "$") {
157
- return chain(stream, state, tokenVariable);
158
- }
159
- // assignment
160
- else if(ch ===":" && stream.eat("=")) {
161
- return ret("operator", "keyword");
162
- }
163
- // open paren
164
- else if(ch === "(") {
165
- pushStateStack(state, { type: "paren"});
166
- return ret("", "");
167
- }
168
- // close paren
169
- else if(ch === ")") {
170
- popStateStack(state);
171
- return ret("", "");
172
- }
173
- // open paren
174
- else if(ch === "[") {
175
- pushStateStack(state, { type: "bracket"});
176
- return ret("", "");
177
- }
178
- // close paren
179
- else if(ch === "]") {
180
- popStateStack(state);
181
- return ret("", "");
182
- }
183
- else {
184
- var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
185
-
186
- // if there's a EQName ahead, consume the rest of the string portion, it's likely a function
187
- if(isEQName && ch === '\"') while(stream.next() !== '"'){}
188
- if(isEQName && ch === '\'') while(stream.next() !== '\''){}
189
-
190
- // gobble up a word if the character is not known
191
- if(!known) stream.eatWhile(/[\w\$_-]/);
192
-
193
- // gobble a colon in the case that is a lib func type call fn:doc
194
- var foundColon = stream.eat(":");
195
-
196
- // if there's not a second colon, gobble another word. Otherwise, it's probably an axis specifier
197
- // which should get matched as a keyword
198
- if(!stream.eat(":") && foundColon) {
199
- stream.eatWhile(/[\w\$_-]/);
200
- }
201
- // if the next non whitespace character is an open paren, this is probably a function (if not a keyword of other sort)
202
- if(stream.match(/^[ \t]*\(/, false)) {
203
- mightBeFunction = true;
204
- }
205
- // is the word a keyword?
206
- var word = stream.current();
207
- known = keywords.propertyIsEnumerable(word) && keywords[word];
208
-
209
- // if we think it's a function call but not yet known,
210
- // set style to variable for now for lack of something better
211
- if(mightBeFunction && !known) known = {type: "function_call", style: "variable def"};
212
-
213
- // if the previous word was element, attribute, axis specifier, this word should be the name of that
214
- if(isInXmlConstructor(state)) {
215
- popStateStack(state);
216
- return ret("word", "variable", word);
217
- }
218
- // as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
219
- // push the stack so we know to look for it on the next word
220
- if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
221
-
222
- // if the word is known, return the details of that else just call this a generic 'word'
223
- return known ? ret(known.type, known.style, word) :
224
- ret("word", "variable", word);
225
- }
226
- }
227
-
228
- // handle comments, including nested
229
- function tokenComment(stream, state) {
230
- var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
231
- while (ch = stream.next()) {
232
- if (ch == ")" && maybeEnd) {
233
- if(nestedCount > 0)
234
- nestedCount--;
235
- else {
236
- popStateStack(state);
237
- break;
238
- }
239
- }
240
- else if(ch == ":" && maybeNested) {
241
- nestedCount++;
242
- }
243
- maybeEnd = (ch == ":");
244
- maybeNested = (ch == "(");
245
- }
246
-
247
- return ret("comment", "comment");
248
- }
249
-
250
- // tokenizer for string literals
251
- // optionally pass a tokenizer function to set state.tokenize back to when finished
252
- function tokenString(quote, f) {
253
- return function(stream, state) {
254
- var ch;
255
-
256
- if(isInString(state) && stream.current() == quote) {
257
- popStateStack(state);
258
- if(f) state.tokenize = f;
259
- return ret("string", "string");
260
- }
261
-
262
- pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
263
-
264
- // if we're in a string and in an XML block, allow an embedded code block
265
- if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
266
- state.tokenize = tokenBase;
267
- return ret("string", "string");
268
- }
269
-
270
-
271
- while (ch = stream.next()) {
272
- if (ch == quote) {
273
- popStateStack(state);
274
- if(f) state.tokenize = f;
275
- break;
276
- }
277
- else {
278
- // if we're in a string and in an XML block, allow an embedded code block in an attribute
279
- if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
280
- state.tokenize = tokenBase;
281
- return ret("string", "string");
282
- }
283
-
284
- }
285
- }
286
-
287
- return ret("string", "string");
288
- };
289
- }
290
-
291
- // tokenizer for variables
292
- function tokenVariable(stream, state) {
293
- var isVariableChar = /[\w\$_-]/;
294
-
295
- // a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
296
- if(stream.eat("\"")) {
297
- while(stream.next() !== '\"'){};
298
- stream.eat(":");
299
- } else {
300
- stream.eatWhile(isVariableChar);
301
- if(!stream.match(":=", false)) stream.eat(":");
302
- }
303
- stream.eatWhile(isVariableChar);
304
- state.tokenize = tokenBase;
305
- return ret("variable", "variable");
306
- }
307
-
308
- // tokenizer for XML tags
309
- function tokenTag(name, isclose) {
310
- return function(stream, state) {
311
- stream.eatSpace();
312
- if(isclose && stream.eat(">")) {
313
- popStateStack(state);
314
- state.tokenize = tokenBase;
315
- return ret("tag", "tag");
316
- }
317
- // self closing tag without attributes?
318
- if(!stream.eat("/"))
319
- pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
320
- if(!stream.eat(">")) {
321
- state.tokenize = tokenAttribute;
322
- return ret("tag", "tag");
323
- }
324
- else {
325
- state.tokenize = tokenBase;
326
- }
327
- return ret("tag", "tag");
328
- };
329
- }
330
-
331
- // tokenizer for XML attributes
332
- function tokenAttribute(stream, state) {
333
- var ch = stream.next();
334
-
335
- if(ch == "/" && stream.eat(">")) {
336
- if(isInXmlAttributeBlock(state)) popStateStack(state);
337
- if(isInXmlBlock(state)) popStateStack(state);
338
- return ret("tag", "tag");
339
- }
340
- if(ch == ">") {
341
- if(isInXmlAttributeBlock(state)) popStateStack(state);
342
- return ret("tag", "tag");
343
- }
344
- if(ch == "=")
345
- return ret("", "");
346
- // quoted string
347
- if (ch == '"' || ch == "'")
348
- return chain(stream, state, tokenString(ch, tokenAttribute));
349
-
350
- if(!isInXmlAttributeBlock(state))
351
- pushStateStack(state, { type: "attribute", name: name, tokenize: tokenAttribute});
352
-
353
- stream.eat(/[a-zA-Z_:]/);
354
- stream.eatWhile(/[-a-zA-Z0-9_:.]/);
355
- stream.eatSpace();
356
-
357
- // the case where the attribute has not value and the tag was closed
358
- if(stream.match(">", false) || stream.match("/", false)) {
359
- popStateStack(state);
360
- state.tokenize = tokenBase;
361
- }
362
-
363
- return ret("attribute", "attribute");
364
- }
365
-
366
- // handle comments, including nested
367
- function tokenXMLComment(stream, state) {
368
- var ch;
369
- while (ch = stream.next()) {
370
- if (ch == "-" && stream.match("->", true)) {
371
- state.tokenize = tokenBase;
372
- return ret("comment", "comment");
373
- }
374
- }
375
- }
376
-
377
-
378
- // handle CDATA
379
- function tokenCDATA(stream, state) {
380
- var ch;
381
- while (ch = stream.next()) {
382
- if (ch == "]" && stream.match("]", true)) {
383
- state.tokenize = tokenBase;
384
- return ret("comment", "comment");
385
- }
386
- }
387
- }
388
-
389
- // handle preprocessing instructions
390
- function tokenPreProcessing(stream, state) {
391
- var ch;
392
- while (ch = stream.next()) {
393
- if (ch == "?" && stream.match(">", true)) {
394
- state.tokenize = tokenBase;
395
- return ret("comment", "comment meta");
396
- }
397
- }
398
- }
399
-
400
-
401
- // functions to test the current context of the state
402
- function isInXmlBlock(state) { return isIn(state, "tag"); }
403
- function isInXmlAttributeBlock(state) { return isIn(state, "attribute"); }
404
- function isInCodeBlock(state) { return isIn(state, "codeblock"); }
405
- function isInXmlConstructor(state) { return isIn(state, "xmlconstructor"); }
406
- function isInString(state) { return isIn(state, "string"); }
407
-
408
- function isEQNameAhead(stream) {
409
- // assume we've already eaten a quote (")
410
- if(stream.current() === '"')
411
- return stream.match(/^[^\"]+\"\:/, false);
412
- else if(stream.current() === '\'')
413
- return stream.match(/^[^\"]+\'\:/, false);
414
- else
415
- return false;
416
- }
417
-
418
- function isIn(state, type) {
419
- return (state.stack.length && state.stack[state.stack.length - 1].type == type);
420
- }
421
-
422
- function pushStateStack(state, newState) {
423
- state.stack.push(newState);
424
- }
425
-
426
- function popStateStack(state) {
427
- var popped = state.stack.pop();
428
- var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize;
429
- state.tokenize = reinstateTokenize || tokenBase;
430
- }
431
-
432
- // the interface for the mode API
433
- return {
434
- startState: function(basecolumn) {
435
- return {
436
- tokenize: tokenBase,
437
- cc: [],
438
- stack: []
439
- };
440
- },
441
-
442
- token: function(stream, state) {
443
- if (stream.eatSpace()) return null;
444
- var style = state.tokenize(stream, state);
445
- return style;
446
- }
447
- };
448
-
449
- });
450
-
451
- CodeMirror.defineMIME("application/xquery", "xquery");