aboutsummaryrefslogtreecommitdiff
path: root/imports/codemirror/mode/xquery
diff options
context:
space:
mode:
authorAnanya Sen2012-04-04 12:27:35 -0700
committerAnanya Sen2012-04-04 12:27:35 -0700
commit671d2b94996ac71d56b2d05d5fe694ed7d84fa59 (patch)
tree8a6b6437567b9e359717fac73891605d60748823 /imports/codemirror/mode/xquery
parente5dc1a5f35c2c6f3273e89109f1be445471b2dec (diff)
downloadninja-671d2b94996ac71d56b2d05d5fe694ed7d84fa59.tar.gz
upgrading to CodeMirror 2.23, since it has an important fix to Not close Ninja, if backspace is pressed while autocomplete dropdown is open.
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'imports/codemirror/mode/xquery')
-rw-r--r--imports/codemirror/mode/xquery/LICENSE20
-rw-r--r--imports/codemirror/mode/xquery/index.html222
-rw-r--r--imports/codemirror/mode/xquery/test/index.html27
-rw-r--r--imports/codemirror/mode/xquery/test/testBase.js42
-rw-r--r--imports/codemirror/mode/xquery/test/testEmptySequenceKeyword.js16
-rw-r--r--imports/codemirror/mode/xquery/test/testMultiAttr.js16
-rw-r--r--imports/codemirror/mode/xquery/test/testNamespaces.js91
-rw-r--r--imports/codemirror/mode/xquery/test/testProcessingInstructions.js16
-rw-r--r--imports/codemirror/mode/xquery/test/testQuotes.js19
-rw-r--r--imports/codemirror/mode/xquery/xquery.js448
10 files changed, 917 insertions, 0 deletions
diff --git a/imports/codemirror/mode/xquery/LICENSE b/imports/codemirror/mode/xquery/LICENSE
new file mode 100644
index 00000000..2a2d47be
--- /dev/null
+++ b/imports/codemirror/mode/xquery/LICENSE
@@ -0,0 +1,20 @@
1Copyright (C) 2011 by MarkLogic Corporation
2Author: Mike Brevoort <mike@brevoort.com>
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE. \ No newline at end of file
diff --git a/imports/codemirror/mode/xquery/index.html b/imports/codemirror/mode/xquery/index.html
new file mode 100644
index 00000000..82f00d24
--- /dev/null
+++ b/imports/codemirror/mode/xquery/index.html
@@ -0,0 +1,222 @@
1<!doctype html>
2<html>
3<!--
4/*
5Copyright (C) 2011 by MarkLogic Corporation
6Author: Mike Brevoort <mike@brevoort.com>
7
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25*/
26-->
27 <head>
28 <title>CodeMirror 2: JavaScript mode</title>
29 <link rel="stylesheet" href="../../lib/codemirror.css">
30 <script src="http://codemirror.net/lib/codemirror.js"></script>
31 <script src="xquery.js"></script>
32 <link rel="stylesheet" href="../../doc/docs.css">
33 <link rel="stylesheet" href="../../theme/xq-dark.css">
34 <style type="text/css">
35 .CodeMirror {
36 border-top: 1px solid black; border-bottom: 1px solid black;
37 }
38 .CodeMirror-scroll {
39 height:400px;
40 }
41 </style>
42 </head>
43 <body>
44 <h1>CodeMirror 2: XQuery mode</h1>
45
46<div class="cm-s-default">
47 <textarea id="code" name="code">
48xquery version &quot;1.0-ml&quot;;
49(: this is
50 : a
51 "comment" :)
52let $let := &lt;x attr=&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt;function() $var {function()} {$var}&lt;/func&gt;&lt;/x&gt;
53let $joe:=1
54return element element {
55 attribute attribute { 1 },
56 element test { &#39;a&#39; },
57 attribute foo { &quot;bar&quot; },
58 fn:doc()[ foo/@bar eq $let ],
59 //x }
60
61(: a more 'evil' test :)
62(: Modified Blakeley example (: with nested comment :) ... :)
63declare private function local:declare() {()};
64declare private function local:private() {()};
65declare private function local:function() {()};
66declare private function local:local() {()};
67let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;
68return element element {
69 attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
70 attribute fn:doc { &quot;bar&quot; castable as xs:string },
71 element text { text { &quot;text&quot; } },
72 fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
73 //fn:doc
74}
75
76
77
78xquery version &quot;1.0-ml&quot;;
79
80(: Copyright 2006-2010 Mark Logic Corporation. :)
81
82(:
83 : Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
84 : you may not use this file except in compliance with the License.
85 : You may obtain a copy of the License at
86 :
87 : http://www.apache.org/licenses/LICENSE-2.0
88 :
89 : Unless required by applicable law or agreed to in writing, software
90 : distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
91 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
92 : See the License for the specific language governing permissions and
93 : limitations under the License.
94 :)
95
96module namespace json = &quot;http://marklogic.com/json&quot;;
97declare default function namespace &quot;http://www.w3.org/2005/xpath-functions&quot;;
98
99(: Need to backslash escape any double quotes, backslashes, and newlines :)
100declare function json:escape($s as xs:string) as xs:string {
101 let $s := replace($s, &quot;\\&quot;, &quot;\\\\&quot;)
102 let $s := replace($s, &quot;&quot;&quot;&quot;, &quot;\\&quot;&quot;&quot;)
103 let $s := replace($s, codepoints-to-string((13, 10)), &quot;\\n&quot;)
104 let $s := replace($s, codepoints-to-string(13), &quot;\\n&quot;)
105 let $s := replace($s, codepoints-to-string(10), &quot;\\n&quot;)
106 return $s
107};
108
109declare function json:atomize($x as element()) as xs:string {
110 if (count($x/node()) = 0) then 'null'
111 else if ($x/@type = &quot;number&quot;) then
112 let $castable := $x castable as xs:float or
113 $x castable as xs:double or
114 $x castable as xs:decimal
115 return
116 if ($castable) then xs:string($x)
117 else error(concat(&quot;Not a number: &quot;, xdmp:describe($x)))
118 else if ($x/@type = &quot;boolean&quot;) then
119 let $castable := $x castable as xs:boolean
120 return
121 if ($castable) then xs:string(xs:boolean($x))
122 else error(concat(&quot;Not a boolean: &quot;, xdmp:describe($x)))
123 else concat('&quot;', json:escape($x), '&quot;')
124};
125
126(: Print the thing that comes after the colon :)
127declare function json:print-value($x as element()) as xs:string {
128 if (count($x/*) = 0) then
129 json:atomize($x)
130 else if ($x/@quote = &quot;true&quot;) then
131 concat('&quot;', json:escape(xdmp:quote($x/node())), '&quot;')
132 else
133 string-join(('{',
134 string-join(for $i in $x/* return json:print-name-value($i), &quot;,&quot;),
135 '}'), &quot;&quot;)
136};
137
138(: Print the name and value both :)
139declare function json:print-name-value($x as element()) as xs:string? {
140 let $name := name($x)
141 let $first-in-array :=
142 count($x/preceding-sibling::*[name(.) = $name]) = 0 and
143 (count($x/following-sibling::*[name(.) = $name]) &gt; 0 or $x/@array = &quot;true&quot;)
144 let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) &gt; 0
145 return
146
147 if ($later-in-array) then
148 () (: I was handled previously :)
149 else if ($first-in-array) then
150 string-join(('&quot;', json:escape($name), '&quot;:[',
151 string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), &quot;,&quot;),
152 ']'), &quot;&quot;)
153 else
154 string-join(('&quot;', json:escape($name), '&quot;:', json:print-value($x)), &quot;&quot;)
155};
156
157(:~
158 Transforms an XML element into a JSON string representation. See http://json.org.
159 &lt;p/&gt;
160 Sample usage:
161 &lt;pre&gt;
162 xquery version &quot;1.0-ml&quot;;
163 import module namespace json=&quot;http://marklogic.com/json&quot; at &quot;json.xqy&quot;;
164 json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;)
165 &lt;/pre&gt;
166 Sample transformations:
167 &lt;pre&gt;
168 &amp;lt;e/&amp;gt; becomes {&quot;e&quot;:null}
169 &amp;lt;e&amp;gt;text&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;text&quot;}
170 &amp;lt;e&amp;gt;quote &quot; escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;quote \&quot; escaping&quot;}
171 &amp;lt;e&amp;gt;backslash \ escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;backslash \\ escaping&quot;}
172 &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;b&amp;gt;text2&amp;lt;/b&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:&quot;text1&quot;,&quot;b&quot;:&quot;text2&quot;}}
173 &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;a&amp;gt;text2&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;,&quot;text2&quot;]}}
174 &amp;lt;e&amp;gt;&amp;lt;a array=&quot;true&quot;&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&