swagr 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +20 -0
- data/bin/swagr +37 -9
- data/examples/examples01/app.rb +5 -1
- data/examples/examples01/views/edit.slim +31 -0
- data/examples/examples01/views/footer.slim +1 -1
- data/examples/examples01/views/layout.slim +23 -5
- data/examples/examples01/views/navbar.slim +17 -16
- data/lib/swagr/version.rb +3 -1
- data/templates/app.rb +5 -1
- data/templates/static/js/codemirror/keymap/vim.js +279 -66
- data/templates/static/js/codemirror/lib/codemirror.css +10 -9
- data/templates/static/js/codemirror/lib/codemirror.js +385 -152
- data/templates/static/js/codemirror/mode/apl/apl.js +160 -0
- data/templates/static/js/codemirror/mode/apl/index.html +61 -0
- data/templates/static/js/codemirror/mode/asterisk/asterisk.js +183 -0
- data/templates/static/js/codemirror/mode/asterisk/index.html +142 -0
- data/templates/static/js/codemirror/mode/clike/clike.js +2 -0
- data/templates/static/js/codemirror/mode/clike/index.html +1 -1
- data/templates/static/js/codemirror/mode/clike/scala.html +1 -1
- data/templates/static/js/codemirror/mode/clojure/clojure.js +3 -3
- data/templates/static/js/codemirror/mode/css/css.js +2 -2
- data/templates/static/js/codemirror/mode/css/test.js +76 -471
- data/templates/static/js/codemirror/mode/d/d.js +205 -0
- data/templates/static/js/codemirror/mode/d/index.html +262 -0
- data/templates/static/js/codemirror/mode/erlang/index.html +1 -1
- data/templates/static/js/codemirror/mode/gfm/gfm.js +2 -1
- data/templates/static/js/codemirror/mode/gfm/index.html +1 -2
- data/templates/static/js/codemirror/mode/gfm/test.js +84 -225
- data/templates/static/js/codemirror/mode/go/index.html +1 -1
- data/templates/static/js/codemirror/mode/groovy/index.html +1 -1
- data/templates/static/js/codemirror/mode/haskell/index.html +1 -1
- data/templates/static/js/codemirror/mode/javascript/index.html +2 -2
- data/templates/static/js/codemirror/mode/javascript/javascript.js +13 -2
- data/templates/static/js/codemirror/mode/less/index.html +1 -1
- data/templates/static/js/codemirror/mode/lua/index.html +1 -1
- data/templates/static/js/codemirror/mode/markdown/index.html +1 -1
- data/templates/static/js/codemirror/mode/markdown/markdown.js +8 -7
- data/templates/static/js/codemirror/mode/markdown/test.js +579 -1266
- data/templates/static/js/codemirror/mode/meta.js +71 -0
- data/templates/static/js/codemirror/mode/mysql/index.html +2 -0
- data/templates/static/js/codemirror/mode/ocaml/index.html +1 -1
- data/templates/static/js/codemirror/mode/php/index.html +1 -1
- data/templates/static/js/codemirror/mode/plsql/index.html +2 -0
- data/templates/static/js/codemirror/mode/python/index.html +1 -1
- data/templates/static/js/codemirror/mode/ruby/index.html +1 -1
- data/templates/static/js/codemirror/mode/sass/index.html +54 -0
- data/templates/static/js/codemirror/mode/sass/sass.js +349 -0
- data/templates/static/js/codemirror/mode/shell/index.html +1 -1
- data/templates/static/js/codemirror/mode/sieve/LICENSE +0 -4
- data/templates/static/js/codemirror/mode/sieve/sieve.js +37 -10
- data/templates/static/js/codemirror/mode/smalltalk/index.html +1 -1
- data/templates/static/js/codemirror/mode/sparql/index.html +1 -1
- data/templates/static/js/codemirror/mode/sql/index.html +68 -0
- data/templates/static/js/codemirror/mode/sql/sql.js +268 -0
- data/templates/static/js/codemirror/mode/stex/test.js +104 -343
- data/templates/static/js/codemirror/mode/tiddlywiki/index.html +1 -1
- data/templates/static/js/codemirror/mode/vb/index.html +1 -1
- data/templates/static/js/codemirror/mode/xquery/test.js +54 -67
- data/templates/static/js/codemirror/mode/xquery/xquery.js +8 -8
- data/templates/static/js/crossfilter.min.js +1 -0
- data/templates/views/edit.slim +31 -0
- data/templates/views/footer.slim +1 -1
- data/templates/views/layout.slim +23 -5
- data/templates/views/navbar.slim +17 -16
- metadata +16 -30
- data/examples/examples01/static/css/codemirror.css +0 -1247
- data/examples/examples01/static/js/codemirror-compressed-3-0.js +0 -5
- data/examples/examples01/views/about.slim +0 -15
- data/examples/examples01/views/application.slim +0 -0
- data/examples/examples01/views/layout_cm.slim +0 -17
- data/templates/static/js/codemirror/lib/util/closetag.js +0 -85
- data/templates/static/js/codemirror/lib/util/colorize.js +0 -29
- data/templates/static/js/codemirror/lib/util/continuecomment.js +0 -36
- data/templates/static/js/codemirror/lib/util/continuelist.js +0 -28
- data/templates/static/js/codemirror/lib/util/dialog.css +0 -32
- data/templates/static/js/codemirror/lib/util/dialog.js +0 -75
- data/templates/static/js/codemirror/lib/util/foldcode.js +0 -182
- data/templates/static/js/codemirror/lib/util/formatting.js +0 -108
- data/templates/static/js/codemirror/lib/util/javascript-hint.js +0 -137
- data/templates/static/js/codemirror/lib/util/loadmode.js +0 -51
- data/templates/static/js/codemirror/lib/util/match-highlighter.js +0 -46
- data/templates/static/js/codemirror/lib/util/matchbrackets.js +0 -63
- data/templates/static/js/codemirror/lib/util/multiplex.js +0 -95
- data/templates/static/js/codemirror/lib/util/overlay.js +0 -59
- data/templates/static/js/codemirror/lib/util/pig-hint.js +0 -117
- data/templates/static/js/codemirror/lib/util/runmode-standalone.js +0 -90
- data/templates/static/js/codemirror/lib/util/runmode.js +0 -52
- data/templates/static/js/codemirror/lib/util/search.js +0 -119
- data/templates/static/js/codemirror/lib/util/searchcursor.js +0 -119
- data/templates/static/js/codemirror/lib/util/simple-hint.css +0 -16
- data/templates/static/js/codemirror/lib/util/simple-hint.js +0 -102
- data/templates/static/js/codemirror/lib/util/xml-hint.js +0 -131
- data/templates/views/about.slim +0 -15
@@ -17,7 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
17
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
18
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
THE SOFTWARE.
|
20
|
-
|
21
|
-
Please note that some subdirectories of the CodeMirror distribution
|
22
|
-
include their own LICENSE files, and are released under different
|
23
|
-
licences.
|
@@ -31,19 +31,37 @@ CodeMirror.defineMode("sieve", function(config) {
|
|
31
31
|
state.tokenize = tokenString(ch);
|
32
32
|
return state.tokenize(stream, state);
|
33
33
|
}
|
34
|
-
|
35
|
-
if (ch
|
36
|
-
|
37
|
-
|
34
|
+
|
35
|
+
if (ch == "(") {
|
36
|
+
state._indent.push("(");
|
37
|
+
// add virtual angel wings so that editor behaves...
|
38
|
+
// ...more sane incase of broken brackets
|
39
|
+
state._indent.push("{");
|
38
40
|
return null;
|
39
41
|
}
|
40
42
|
|
41
|
-
if (ch === "
|
42
|
-
|
43
|
-
state._indent--;
|
43
|
+
if (ch === "{") {
|
44
|
+
state._indent.push("{");
|
44
45
|
return null;
|
45
46
|
}
|
47
|
+
|
48
|
+
if (ch == ")") {
|
49
|
+
state._indent.pop();
|
50
|
+
state._indent.pop();
|
51
|
+
}
|
46
52
|
|
53
|
+
if (ch === "}") {
|
54
|
+
state._indent.pop();
|
55
|
+
return null;
|
56
|
+
}
|
57
|
+
|
58
|
+
if (ch == ",")
|
59
|
+
return null;
|
60
|
+
|
61
|
+
if (ch == ";")
|
62
|
+
return null;
|
63
|
+
|
64
|
+
|
47
65
|
if (/[{}\(\),;]/.test(ch))
|
48
66
|
return null;
|
49
67
|
|
@@ -62,7 +80,7 @@ CodeMirror.defineMode("sieve", function(config) {
|
|
62
80
|
return "operator";
|
63
81
|
}
|
64
82
|
|
65
|
-
stream.eatWhile(
|
83
|
+
stream.eatWhile(/\w/);
|
66
84
|
var cur = stream.current();
|
67
85
|
|
68
86
|
// "text:" *(SP / HTAB) (hash-comment / CRLF)
|
@@ -79,6 +97,8 @@ CodeMirror.defineMode("sieve", function(config) {
|
|
79
97
|
|
80
98
|
if (atoms.propertyIsEnumerable(cur))
|
81
99
|
return "atom";
|
100
|
+
|
101
|
+
return null;
|
82
102
|
}
|
83
103
|
|
84
104
|
function tokenMultiLineString(stream, state)
|
@@ -135,7 +155,7 @@ CodeMirror.defineMode("sieve", function(config) {
|
|
135
155
|
startState: function(base) {
|
136
156
|
return {tokenize: tokenBase,
|
137
157
|
baseIndent: base || 0,
|
138
|
-
_indent:
|
158
|
+
_indent: []};
|
139
159
|
},
|
140
160
|
|
141
161
|
token: function(stream, state) {
|
@@ -146,7 +166,14 @@ CodeMirror.defineMode("sieve", function(config) {
|
|
146
166
|
},
|
147
167
|
|
148
168
|
indent: function(state, _textAfter) {
|
149
|
-
|
169
|
+
var length = state._indent.length;
|
170
|
+
if (_textAfter && (_textAfter[0] == "}"))
|
171
|
+
length--;
|
172
|
+
|
173
|
+
if (length <0)
|
174
|
+
length = 0;
|
175
|
+
|
176
|
+
return length * indentUnit;
|
150
177
|
},
|
151
178
|
|
152
179
|
electricChars: "}"
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<title>CodeMirror: Smalltalk mode</title>
|
6
6
|
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
7
|
<script src="../../lib/codemirror.js"></script>
|
8
|
-
<script src="../../
|
8
|
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
9
9
|
<script src="smalltalk.js"></script>
|
10
10
|
<link rel="stylesheet" href="../../doc/docs.css">
|
11
11
|
<style>
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<title>CodeMirror: SPARQL mode</title>
|
6
6
|
<link rel="stylesheet" href="../../lib/codemirror.css">
|
7
7
|
<script src="../../lib/codemirror.js"></script>
|
8
|
-
<script src="../../
|
8
|
+
<script src="../../addon/edit/matchbrackets.js"></script>
|
9
9
|
<script src="sparql.js"></script>
|
10
10
|
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
11
11
|
<link rel="stylesheet" href="../../doc/docs.css">
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title>SQL Mode for CodeMirror</title>
|
6
|
+
<link rel="stylesheet" href="../../lib/codemirror.css" />
|
7
|
+
<script src="../../lib/codemirror.js"></script>
|
8
|
+
<script src="../../lib/codemirror.js"></script>
|
9
|
+
<script src="../../lib/util/continuelist.js"></script>
|
10
|
+
<script src="sql.js"></script>
|
11
|
+
<style>
|
12
|
+
.CodeMirror {
|
13
|
+
border-top: 1px solid black;
|
14
|
+
border-bottom: 1px solid black;
|
15
|
+
}
|
16
|
+
</style>
|
17
|
+
<link rel="stylesheet" href="../../doc/docs.css">
|
18
|
+
<script>
|
19
|
+
var init = function() {
|
20
|
+
var mime = 'text/x-mariadb';
|
21
|
+
|
22
|
+
// get mime type
|
23
|
+
if (window.location.href.indexOf('mime=') > -1) {
|
24
|
+
mime = window.location.href.substr(window.location.href.indexOf('mime=') + 5);
|
25
|
+
}
|
26
|
+
|
27
|
+
window.editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
28
|
+
mode: mime,
|
29
|
+
indentWithTabs: true,
|
30
|
+
smartIndent: true,
|
31
|
+
lineNumbers: true,
|
32
|
+
matchBrackets : true,
|
33
|
+
autofocus: true
|
34
|
+
});
|
35
|
+
};
|
36
|
+
</script>
|
37
|
+
</head>
|
38
|
+
<body onload="init();">
|
39
|
+
<h1>SQL Mode for CodeMirror</h1>
|
40
|
+
<form>
|
41
|
+
<textarea id="code" name="code">-- SQL Mode for CodeMirror
|
42
|
+
SELECT SQL_NO_CACHE DISTINCT
|
43
|
+
@var1 AS `val1`, @'val2', @global.'sql_mode',
|
44
|
+
1.1 AS `float_val`, .14 AS `another_float`, 0.09e3 AS `int_with_esp`,
|
45
|
+
0xFA5 AS `hex`, x'fa5' AS `hex2`, 0b101 AS `bin`, b'101' AS `bin2`,
|
46
|
+
DATE '1994-01-01' AS `sql_date`, { T "1994-01-01" } AS `odbc_date`,
|
47
|
+
'myString', UNKNOWN
|
48
|
+
FROM DUAL
|
49
|
+
-- space needed after '--'
|
50
|
+
# 1 line comment
|
51
|
+
/* multiline
|
52
|
+
comment! */
|
53
|
+
LIMIT 1 OFFSET 0;
|
54
|
+
</textarea>
|
55
|
+
</form>
|
56
|
+
<p><strong>MIME types defined:</strong>
|
57
|
+
<code><a href="?mime=text/x-sql">text/x-sql</a></code>,
|
58
|
+
<code><a href="?mime=text/x-mysql">text/x-mysql</a></code>,
|
59
|
+
<code><a href="?mime=text/x-mariadb">text/x-mariadb</a></code>,
|
60
|
+
<code><a href="?mime=text/x-plsql">text/x-plsql</a></code>.
|
61
|
+
</p>
|
62
|
+
<p>
|
63
|
+
<strong>Tests:</strong>
|
64
|
+
<a href="../../test/index.html#sql_*">normal</a>,
|
65
|
+
<a href="../../test/index.html#verbose,sql_*">verbose</a>.
|
66
|
+
</p>
|
67
|
+
</body>
|
68
|
+
</html>
|
@@ -0,0 +1,268 @@
|
|
1
|
+
CodeMirror.defineMode("sql", function(config, parserConfig) {
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var client = parserConfig.client || {},
|
5
|
+
atoms = parserConfig.atoms || {"false": true, "true": true, "null": true},
|
6
|
+
builtin = parserConfig.builtin || {},
|
7
|
+
keywords = parserConfig.keywords,
|
8
|
+
operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/,
|
9
|
+
support = parserConfig.support || {},
|
10
|
+
hooks = parserConfig.hooks || {},
|
11
|
+
dateSQL = parserConfig.dateSQL || {"date" : true, "time" : true, "timestamp" : true};
|
12
|
+
|
13
|
+
function tokenBase(stream, state) {
|
14
|
+
var ch = stream.next();
|
15
|
+
|
16
|
+
// call hooks from the mime type
|
17
|
+
if (hooks[ch]) {
|
18
|
+
var result = hooks[ch](stream, state);
|
19
|
+
if (result !== false) return result;
|
20
|
+
}
|
21
|
+
|
22
|
+
if ((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/))
|
23
|
+
|| (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/)) {
|
24
|
+
// hex
|
25
|
+
return "number";
|
26
|
+
} else if (((ch == "b" || ch == "B") && stream.match(/^'[01]+'/))
|
27
|
+
|| (ch == "0" && stream.match(/^b[01]+/))) {
|
28
|
+
// bitstring
|
29
|
+
return "number";
|
30
|
+
} else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {
|
31
|
+
// numbers
|
32
|
+
stream.match(/^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/);
|
33
|
+
return "number";
|
34
|
+
} else if (ch == "?" && (stream.eatSpace() || stream.eol() || stream.eat(";"))) {
|
35
|
+
// placeholders
|
36
|
+
return "variable-3";
|
37
|
+
} else if (ch == '"' || ch == "'") {
|
38
|
+
// strings
|
39
|
+
state.tokenize = tokenLiteral(ch);
|
40
|
+
return state.tokenize(stream, state);
|
41
|
+
} else if (/^[\(\),\;\[\]]/.test(ch)) {
|
42
|
+
// no highlightning
|
43
|
+
return null;
|
44
|
+
} else if (ch == "#" || (ch == "-" && stream.eat("-") && stream.eat(" "))) {
|
45
|
+
// 1-line comments
|
46
|
+
stream.skipToEnd();
|
47
|
+
return "comment";
|
48
|
+
} else if (ch == "/" && stream.eat("*")) {
|
49
|
+
// multi-line comments
|
50
|
+
state.tokenize = tokenComment;
|
51
|
+
return state.tokenize(stream, state);
|
52
|
+
} else if (ch == ".") {
|
53
|
+
// .1 for 0.1
|
54
|
+
if (stream.match(/^[0-9eE]+/) && support.zerolessFloat == true) {
|
55
|
+
return "number";
|
56
|
+
}
|
57
|
+
// .table_name (ODBC)
|
58
|
+
if (stream.match(/^[a-zA-Z_]+/) && support.ODBCdotTable == true) {
|
59
|
+
return "variable-2";
|
60
|
+
}
|
61
|
+
} else if (operatorChars.test(ch)) {
|
62
|
+
// operators
|
63
|
+
stream.eatWhile(operatorChars);
|
64
|
+
return null;
|
65
|
+
} else if (ch == '{' &&
|
66
|
+
(stream.match(/^( )*(d|D|t|T|ts|TS)( )*'[^']*'( )*}/) || stream.match(/^( )*(d|D|t|T|ts|TS)( )*"[^"]*"( )*}/))) {
|
67
|
+
// dates (weird ODBC syntax)
|
68
|
+
return "number";
|
69
|
+
} else {
|
70
|
+
stream.eatWhile(/^[_\w\d]/);
|
71
|
+
var word = stream.current().toLowerCase();
|
72
|
+
// dates (standard SQL syntax)
|
73
|
+
if (dateSQL.hasOwnProperty(word) && (stream.match(/^( )+'[^']*'/) || stream.match(/^( )+"[^"]*"/)))
|
74
|
+
return "number";
|
75
|
+
if (atoms.hasOwnProperty(word)) return "atom";
|
76
|
+
if (builtin.hasOwnProperty(word)) return "builtin";
|
77
|
+
if (keywords.hasOwnProperty(word)) return "keyword";
|
78
|
+
if (client.hasOwnProperty(word)) return "string-2";
|
79
|
+
return null;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
// 'string', with char specified in quote escaped by '\'
|
84
|
+
function tokenLiteral(quote) {
|
85
|
+
return function(stream, state) {
|
86
|
+
var escaped = false, ch;
|
87
|
+
while ((ch = stream.next()) != null) {
|
88
|
+
if (ch == quote && !escaped) {
|
89
|
+
state.tokenize = tokenBase;
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
escaped = !escaped && ch == "\\";
|
93
|
+
}
|
94
|
+
return "string";
|
95
|
+
};
|
96
|
+
}
|
97
|
+
function tokenComment(stream, state) {
|
98
|
+
while (true) {
|
99
|
+
if (stream.skipTo("*")) {
|
100
|
+
stream.next();
|
101
|
+
if (stream.eat("/")) {
|
102
|
+
state.tokenize = tokenBase;
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
} else {
|
106
|
+
stream.skipToEnd();
|
107
|
+
break;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
return "comment";
|
111
|
+
}
|
112
|
+
|
113
|
+
function pushContext(stream, state, type) {
|
114
|
+
state.context = {
|
115
|
+
prev: state.context,
|
116
|
+
indent: stream.indentation(),
|
117
|
+
col: stream.column(),
|
118
|
+
type: type
|
119
|
+
};
|
120
|
+
}
|
121
|
+
|
122
|
+
function popContext(state) {
|
123
|
+
state.indent = state.context.indent;
|
124
|
+
state.context = state.context.prev;
|
125
|
+
}
|
126
|
+
|
127
|
+
return {
|
128
|
+
startState: function() {
|
129
|
+
return {tokenize: tokenBase, context: null};
|
130
|
+
},
|
131
|
+
|
132
|
+
token: function(stream, state) {
|
133
|
+
if (stream.sol()) {
|
134
|
+
if (state.context && state.context.align == null)
|
135
|
+
state.context.align = false;
|
136
|
+
}
|
137
|
+
if (stream.eatSpace()) return null;
|
138
|
+
|
139
|
+
var style = state.tokenize(stream, state);
|
140
|
+
if (style == "comment") return style;
|
141
|
+
|
142
|
+
if (state.context && state.context.align == null)
|
143
|
+
state.context.align = true;
|
144
|
+
|
145
|
+
var tok = stream.current();
|
146
|
+
if (tok == "(")
|
147
|
+
pushContext(stream, state, ")");
|
148
|
+
else if (tok == "[")
|
149
|
+
pushContext(stream, state, "]");
|
150
|
+
else if (state.context && state.context.type == tok)
|
151
|
+
popContext(state);
|
152
|
+
return style;
|
153
|
+
},
|
154
|
+
|
155
|
+
indent: function(state, textAfter) {
|
156
|
+
var cx = state.context;
|
157
|
+
if (!cx) return CodeMirror.Pass;
|
158
|
+
if (cx.align) return cx.col + (textAfter.charAt(0) == cx.type ? 0 : 1);
|
159
|
+
else return cx.indent + config.indentUnit;
|
160
|
+
}
|
161
|
+
};
|
162
|
+
});
|
163
|
+
|
164
|
+
(function() {
|
165
|
+
"use strict";
|
166
|
+
|
167
|
+
// `identifier`
|
168
|
+
function hookIdentifier(stream) {
|
169
|
+
var escaped = false, ch;
|
170
|
+
while ((ch = stream.next()) != null) {
|
171
|
+
if (ch == "`" && !escaped) return "variable-2";
|
172
|
+
escaped = !escaped && ch == "`";
|
173
|
+
}
|
174
|
+
return null;
|
175
|
+
}
|
176
|
+
|
177
|
+
// variable token
|
178
|
+
function hookVar(stream) {
|
179
|
+
// variables
|
180
|
+
// @@ and prefix
|
181
|
+
if (stream.eat("@")) {
|
182
|
+
stream.match(/^session\./);
|
183
|
+
stream.match(/^local\./);
|
184
|
+
stream.match(/^global\./);
|
185
|
+
}
|
186
|
+
|
187
|
+
if (stream.eat("'")) {
|
188
|
+
stream.match(/^.*'/);
|
189
|
+
return "variable-2";
|
190
|
+
} else if (stream.eat('"')) {
|
191
|
+
stream.match(/^.*"/);
|
192
|
+
return "variable-2";
|
193
|
+
} else if (stream.eat("`")) {
|
194
|
+
stream.match(/^.*`/);
|
195
|
+
return "variable-2";
|
196
|
+
} else if (stream.match(/^[0-9a-zA-Z$\.\_]+/)) {
|
197
|
+
return "variable-2";
|
198
|
+
}
|
199
|
+
return null;
|
200
|
+
};
|
201
|
+
|
202
|
+
// short client keyword token
|
203
|
+
function hookClient(stream) {
|
204
|
+
// \g, etc
|
205
|
+
return stream.match(/^[a-zA-Z]\b/) ? "variable-2" : null;
|
206
|
+
}
|
207
|
+
|
208
|
+
var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from having in insert into is join like not on or order select set table union update values where ";
|
209
|
+
|
210
|
+
function set(str) {
|
211
|
+
var obj = {}, words = str.split(" ");
|
212
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
213
|
+
return obj;
|
214
|
+
}
|
215
|
+
|
216
|
+
CodeMirror.defineMIME("text/x-sql", {
|
217
|
+
name: "sql",
|
218
|
+
keywords: set(sqlKeywords + "begin"),
|
219
|
+
builtin: set("bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric"),
|
220
|
+
atoms: set("false true null unknown"),
|
221
|
+
operatorChars: /^[*+\-%<>!=]/,
|
222
|
+
dateSQL: set("date time timestamp"),
|
223
|
+
support: set("ODBCdotTable")
|
224
|
+
});
|
225
|
+
|
226
|
+
CodeMirror.defineMIME("text/x-mysql", {
|
227
|
+
name: "sql",
|
228
|
+
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
229
|
+
keywords: set(sqlKeywords + "accessible action add after algorithm all analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general global grant grants group groupby_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
|
230
|
+
builtin: set("bool boolean bit blob decimal double enum float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
|
231
|
+
atoms: set("false true null unknown"),
|
232
|
+
operatorChars: /^[*+\-%<>!=&|^]/,
|
233
|
+
dateSQL: set("date time timestamp"),
|
234
|
+
support: set("ODBCdotTable zerolessFloat"),
|
235
|
+
hooks: {
|
236
|
+
"@": hookVar,
|
237
|
+
"`": hookIdentifier,
|
238
|
+
"\\": hookClient
|
239
|
+
}
|
240
|
+
});
|
241
|
+
|
242
|
+
CodeMirror.defineMIME("text/x-mariadb", {
|
243
|
+
name: "sql",
|
244
|
+
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
245
|
+
keywords: set(sqlKeywords + "accessible action add after algorithm all always analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general generated global grant grants group groupby_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password persistent phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views virtual warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
|
246
|
+
builtin: set("bool boolean bit blob decimal double enum float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
|
247
|
+
atoms: set("false true null unknown"),
|
248
|
+
operatorChars: /^[*+\-%<>!=&|^]/,
|
249
|
+
dateSQL: set("date time timestamp"),
|
250
|
+
support: set("ODBCdotTable zerolessFloat"),
|
251
|
+
hooks: {
|
252
|
+
"@": hookVar,
|
253
|
+
"`": hookIdentifier,
|
254
|
+
"\\": hookClient
|
255
|
+
}
|
256
|
+
});
|
257
|
+
|
258
|
+
// this is based on Peter Raganitsch's 'plsql' mode
|
259
|
+
CodeMirror.defineMIME("text/x-plsql", {
|
260
|
+
name: "sql",
|
261
|
+
client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"),
|
262
|
+
keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"),
|
263
|
+
functions: set("abs acos add_months ascii asin atan atan2 average bfilename ceil chartorowid chr concat convert cos cosh count decode deref dual dump dup_val_on_index empty error exp false floor found glb greatest hextoraw initcap instr instrb isopen last_day least lenght lenghtb ln lower lpad ltrim lub make_ref max min mod months_between new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null nvl others power rawtohex reftohex round rowcount rowidtochar rpad rtrim sign sin sinh soundex sqlcode sqlerrm sqrt stddev substr substrb sum sysdate tan tanh to_char to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid upper user userenv variance vsize"),
|
264
|
+
builtin: set("bfile blob character clob dec float int integer mlslabel natural naturaln nchar nclob number numeric nvarchar2 real rowtype signtype smallint string varchar varchar2"),
|
265
|
+
operatorChars: /^[*+\-%<>!=~]/,
|
266
|
+
dateSQL: set("date time timestamp")
|
267
|
+
});
|
268
|
+
}());
|