@@ -88,7 +88,11 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
88
88
var AqlHighlightRules = function ( ) {
89
89
90
90
var keywords = (
91
- "for|return|filter|search|sort|limit|let|collect|asc|desc|in|into|insert|update|remove|replace|upsert|options|with|and|or|not|distinct|graph|shortest_path|outbound|inbound|any|all|none|at least|aggregate|like|k_shortest_paths|k_paths|all_shortest_paths|prune|window"
91
+ "for|return|filter|sort|limit|let|collect|asc|desc|in|into|insert|update|remove|replace|upsert|with|and|or|not|distinct|graph|shortest_path|outbound|inbound|any|all|none|aggregate|like|k_shortest_paths|k_paths|all_shortest_paths|window"
92
+ ) ;
93
+
94
+ var pseudoKeywords = (
95
+ "search|keep|to|prune|options"
92
96
) ;
93
97
94
98
var builtinFunctions = (
@@ -106,7 +110,7 @@ var AqlHighlightRules = function() {
106
110
"fail|passthru|v8|sleep|schema_get|schema_validate|shard_id|call_greenspun|version|noopt|noeval|not_null|" +
107
111
"first_list|first_document|parse_identifier|current_user|current_database|collection_count|pregel_result|" +
108
112
"collections|document|decode_rev|range|union|union_distinct|minus|intersection|flatten|is_same_collection|check_document|" +
109
- "ltrim|rtrim|find_first|find_last|split|substitute|ipv4_to_number|ipv4_from_number|is_ipv4|md5|sha1|sha512|crc32|fnv64|hash|random_token|to_base64|" +
113
+ "ltrim|rtrim|find_first|find_last|split|substitute|ipv4_to_number|ipv4_from_number|is_ipv4|md5|sha1|sha256| sha512|crc32|fnv64|hash|random_token|to_base64|" +
110
114
"to_hex|encode_uri_component|soundex|assert|warn|is_key|sorted|sorted_unique|count_distinct|count_unique|" +
111
115
"levenshtein_distance|levenshtein_match|regex_matches|regex_split|ngram_match|ngram_similarity|ngram_positional_similarity|uuid|" +
112
116
"tokens|exists|starts_with|phrase|min_match|bm25|tfidf|boost|analyzer|" +
@@ -115,9 +119,12 @@ var AqlHighlightRules = function() {
115
119
"geo_equals|geo_distance|geo_area|geo_in_range"
116
120
) ;
117
121
122
+ var aqlBindVariablePattern = "@(?:_+[a-zA-Z0-9]+[a-zA-Z0-9_]*|[a-zA-Z0-9][a-zA-Z0-9_]*)" ;
123
+
118
124
var keywordMapper = this . createKeywordMapper ( {
119
125
"support.function" : builtinFunctions ,
120
126
"keyword" : keywords ,
127
+ "keyword.other" : pseudoKeywords ,
121
128
"constant.language" : "null" ,
122
129
"constant.language.boolean" : "true|false"
123
130
} , "identifier" , true ) ;
@@ -132,44 +139,129 @@ var AqlHighlightRules = function() {
132
139
next : "comment_ml"
133
140
} , {
134
141
token : "string" , // " string
135
- regex : '".*?"'
142
+ regex : '"' ,
143
+ next : "string_double"
136
144
} , {
137
145
token : "string" , // ' string
138
- regex : "'.*?'"
146
+ regex : "'" ,
147
+ next : "string_single"
148
+ } , {
149
+ token : "variable.other" , // ` quoted identifier
150
+ regex : "`" ,
151
+ next : "identifier_backtick"
139
152
} , {
140
- token : "string" , // ` string
141
- regex : "`.*?`"
153
+ token : "variable.other" , // ´ quoted identifier
154
+ regex : "´" ,
155
+ next : "identifier_forwardtick"
142
156
} , {
143
157
token : "constant.numeric" , // binary integer
144
- regex : " 0[bB][01]+\\b"
158
+ regex : / 0 [ b B ] [ 0 1 ] + \b /
145
159
} , {
146
160
token : "constant.numeric" , // hexadecimal integer
147
- regex : " 0[xX][0-9a-fA-F]+\\b"
161
+ regex : / 0 [ x X ] [ 0 - 9 a - f A - F ] + \b /
148
162
} , {
149
163
token : "constant.numeric" , // float
150
- regex : "[+-]?\\d+ (?:(?:\\.\\d*)? (?:[eE][+-]?\\d +)?)?\\b"
164
+ regex : / (?: (?: 0 | [ 1 - 9 ] [ 0 - 9 ] * ) (?: \. [ 0 - 9 ] + ) ? | \. [ 0 - 9 ] + ) (?: [ e E ] [ \- \+ ] ? [ 0 - 9 ] + ) ? /
151
165
} , {
152
- token : keywordMapper ,
153
- regex : "[a-zA-Z_][a-zA-Z0-9_]*\\b"
166
+ token : "constant.numeric" , // decimal integer
167
+ regex : / 0 | [ 1 - 9 ] [ 0 - 9 ] * \b /
168
+ } , {
169
+ token : "variable.global" ,
170
+ regex : "@" + aqlBindVariablePattern
171
+ } , {
172
+ token : "variable" ,
173
+ regex : aqlBindVariablePattern
154
174
} , {
155
175
token : "keyword.operator" ,
156
- regex : "\\+|\\-|\\/|\\/\\/|%|@ >|<@| &&|\\|\\||!|<|>|<=|=>|==|!=|=|\\[\\*\\]"
176
+ regex : / = ~ | ! ~ | = = | ! = | > = | > | < = | < | = | ! | & & | \| \| | \+ | \- | \* | \/ | % | \? | : : | : | \. \. /
157
177
} , {
158
178
token : "paren.lparen" ,
159
- regex : "[\\(\\{]"
179
+ regex : / [ \( \{ \[ ] /
160
180
} , {
161
181
token : "paren.rparen" ,
162
- regex : "[\\)\\}]"
182
+ regex : / [ \) \} \] ] /
183
+ } , {
184
+ token : "punctuation" ,
185
+ regex : / [ \. , ] /
186
+ } , {
187
+ // COLLECT ... WITH COUNT INTO
188
+ // BUG: Need to use character classes because caseInsensitive: true
189
+ // would affect all other rules, https://github.com/ajaxorg/ace/issues/4887
190
+ token : "keyword" ,
191
+ regex : / [ W w ] [ I i ] [ T t ] [ H h ] \s + [ C c ] [ O o ] [ U u ] [ N n ] [ T t ] \s + [ I i ] [ N n ] [ T t ] [ O o ] \b /
192
+ } , {
193
+ // AT LEAST (...)
194
+ // BUG: See above
195
+ token : "keyword" ,
196
+ regex : / [ A a ] [ T t ] \s + [ L l ] [ E e ] [ A a ] [ S s ] [ T t ] \b /
197
+ } , {
198
+ token : "language.variable" , // case sensitive
199
+ regex : / (?: C U R R E N T | N E W | O L D ) \b /
200
+ } , {
201
+ token : keywordMapper ,
202
+ regex : / (?: \$ ? | _ + ) [ a - z A - Z ] + [ _ a - z A - Z 0 - 9 ] * \b /
163
203
} , {
164
204
token : "text" ,
165
- regex : "\\s+"
205
+ regex : / \s + /
166
206
} ] ,
167
207
"comment_ml" : [ {
168
208
token : "comment" ,
169
209
regex : / \* \/ / ,
170
- next : "start" ,
210
+ next : "start"
171
211
} , {
172
212
defaultToken : "comment"
213
+ } ] ,
214
+ "string_double" : [ {
215
+ token : "constant.character.escape" ,
216
+ regex : / \\ u [ 0 - 9 a - f A - F ] { 4 } /
217
+ } , {
218
+ token : "constant.character.escape" ,
219
+ regex : / \\ [ " ' \\ \/ b f n r t ] /
220
+ } , {
221
+ token : "string" ,
222
+ regex : '"' ,
223
+ next : "start"
224
+ } , {
225
+ defaultToken : "string"
226
+ } ] ,
227
+ "string_single" : [ {
228
+ token : "constant.character.escape" ,
229
+ regex : / \\ u [ 0 - 9 a - f A - F ] { 4 } /
230
+ } , {
231
+ token : "constant.character.escape" ,
232
+ regex : / \\ [ " ' \\ \/ b f n r t ] /
233
+ } , {
234
+ token : "string" ,
235
+ regex : "'" ,
236
+ next : "start"
237
+ } , {
238
+ defaultToken : "string"
239
+ } ] ,
240
+ "identifier_backtick" : [ {
241
+ token : "constant.character.escape" ,
242
+ regex : / \\ u [ 0 - 9 a - f A - F ] { 4 } /
243
+ } , {
244
+ token : "constant.character.escape" ,
245
+ regex : / \\ [ ` " ' \\ \/ b f n r t ] /
246
+ } , {
247
+ token : "variable.other" ,
248
+ regex : "`" ,
249
+ next : "start"
250
+ } , {
251
+ defaultToken : "variable.other"
252
+ } ] ,
253
+ "identifier_forwardtick" : [ {
254
+ token : "constant.character.escape" ,
255
+ regex : / \\ u [ 0 - 9 a - f A - F ] { 4 } /
256
+ } , {
257
+ token : "constant.character.escape" ,
258
+ regex : / \\ [ ´ " ' \\ \/ b f n r t ] /
259
+ } , {
260
+ token : "variable.other" ,
261
+ regex : "´" ,
262
+ next : "start"
263
+ } , {
264
+ defaultToken : "variable.other"
173
265
} ]
174
266
} ;
175
267
} ;
0 commit comments