Projekt

Obecné

Profil

Stáhnout (14 KB) Statistiky
| Větev: | Tag: | Revize:
1
ace.define("ace/mode/doc_comment_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
2
"use strict";
3

    
4
var oop = require("../lib/oop");
5
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
6

    
7
var DocCommentHighlightRules = function() {
8
    this.$rules = {
9
        "start" : [ {
10
            token : "comment.doc.tag",
11
            regex : "@[\\w\\d_]+" // TODO: fix email addresses
12
        }, 
13
        DocCommentHighlightRules.getTagRule(),
14
        {
15
            defaultToken : "comment.doc",
16
            caseInsensitive: true
17
        }]
18
    };
19
};
20

    
21
oop.inherits(DocCommentHighlightRules, TextHighlightRules);
22

    
23
DocCommentHighlightRules.getTagRule = function(start) {
24
    return {
25
        token : "comment.doc.tag.storage.type",
26
        regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
27
    };
28
};
29

    
30
DocCommentHighlightRules.getStartRule = function(start) {
31
    return {
32
        token : "comment.doc", // doc comment
33
        regex : "\\/\\*(?=\\*)",
34
        next  : start
35
    };
36
};
37

    
38
DocCommentHighlightRules.getEndRule = function (start) {
39
    return {
40
        token : "comment.doc", // closing comment
41
        regex : "\\*\\/",
42
        next  : start
43
    };
44
};
45

    
46

    
47
exports.DocCommentHighlightRules = DocCommentHighlightRules;
48

    
49
});
50

    
51
ace.define("ace/mode/json_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
52
"use strict";
53

    
54
var oop = require("../lib/oop");
55
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
56

    
57
var JsonHighlightRules = function() {
58
    this.$rules = {
59
        "start" : [
60
            {
61
                token : "variable", // single line
62
                regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
63
            }, {
64
                token : "string", // single line
65
                regex : '"',
66
                next  : "string"
67
            }, {
68
                token : "constant.numeric", // hex
69
                regex : "0[xX][0-9a-fA-F]+\\b"
70
            }, {
71
                token : "constant.numeric", // float
72
                regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
73
            }, {
74
                token : "constant.language.boolean",
75
                regex : "(?:true|false)\\b"
76
            }, {
77
                token : "text", // single quoted strings are not allowed
78
                regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
79
            }, {
80
                token : "comment", // comments are not allowed, but who cares?
81
                regex : "\\/\\/.*$"
82
            }, {
83
                token : "comment.start", // comments are not allowed, but who cares?
84
                regex : "\\/\\*",
85
                next  : "comment"
86
            }, {
87
                token : "paren.lparen",
88
                regex : "[[({]"
89
            }, {
90
                token : "paren.rparen",
91
                regex : "[\\])}]"
92
            }, {
93
                token : "text",
94
                regex : "\\s+"
95
            }
96
        ],
97
        "string" : [
98
            {
99
                token : "constant.language.escape",
100
                regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
101
            }, {
102
                token : "string",
103
                regex : '"|$',
104
                next  : "start"
105
            }, {
106
                defaultToken : "string"
107
            }
108
        ],
109
        "comment" : [
110
            {
111
                token : "comment.end", // comments are not allowed, but who cares?
112
                regex : "\\*\\/",
113
                next  : "start"
114
            }, {
115
                defaultToken: "comment"
116
            }
117
        ]
118
    };
119
    
120
};
121

    
122
oop.inherits(JsonHighlightRules, TextHighlightRules);
123

    
124
exports.JsonHighlightRules = JsonHighlightRules;
125
});
126

    
127
ace.define("ace/mode/redshift_highlight_rules",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules","ace/mode/json_highlight_rules"], function(require, exports, module) {
128

    
129
var oop = require("../lib/oop");
130
var lang = require("../lib/lang");
131
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
132
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
133
var JsonHighlightRules = require("./json_highlight_rules").JsonHighlightRules;
134

    
135
var RedshiftHighlightRules = function() {
136
    var keywords = (
137
        "aes128|aes256|all|allowoverwrite|analyse|analyze|and|any|array|as|asc|authorization|backup|" + 
138
        "between|binary|blanksasnull|both|bytedict|bzip2|case|cast|check|collate|column|constraint|create|credentials|" + 
139
        "cross|current_date|current_time|current_timestamp|current_user|current_user_id|default|deferrable|deflate|defrag|delta|" + 
140
        "delta32k|desc|disable|distinct|do|else|emptyasnull|enable|encode|encrypt|encryption|end|except|explicit|false|for|foreign|" + 
141
        "freeze|from|full|globaldict256|globaldict64k|grant|group|gzip|having|identity|ignore|ilike|in|initially|inner|intersect|into|is|" + 
142
        "isnull|join|leading|left|like|limit|localtime|localtimestamp|lun|luns|lzo|lzop|minus|mostly13|mostly32|mostly8|natural|new|not|notnull|" + 
143
        "null|nulls|off|offline|offset|old|on|only|open|or|order|outer|overlaps|parallel|partition|percent|permissions|placing|primary|raw|readratio|" +
144
        "recover|references|rejectlog|resort|restore|right|select|session_user|similar|some|sysdate|system|table|tag|tdes|text255|text32k|then|timestamp|" + 
145
        "to|top|trailing|true|truncatecolumns|union|unique|user|using|verbose|wallet|when|where|with|without"
146
    );
147

    
148

    
149
    var builtinFunctions = (
150
        "current_schema|current_schemas|has_database_privilege|has_schema_privilege|has_table_privilege|age|current_time|current_timestamp|localtime|" + 
151
        "isfinite|now|ascii|get_bit|get_byte|octet_length|set_bit|set_byte|to_ascii|avg|count|listagg|max|min|stddev_samp|stddev_pop|sum|var_samp|var_pop|" + 
152
        "bit_and|bit_or|bool_and|bool_or|avg|count|cume_dist|dense_rank|first_value|last_value|lag|lead|listagg|max|median|min|nth_value|ntile|percent_rank|" + 
153
        "percentile_cont|percentile_disc|rank|ratio_to_report|row_number|case|coalesce|decode|greatest|least|nvl|nvl2|nullif|add_months|age|convert_timezone|" +
154
        "current_date|timeofday|current_time|current_timestamp|date_cmp|date_cmp_timestamp|date_part_year|dateadd|datediff|date_part|date_trunc|extract|getdate|" +
155
        "interval_cmp|isfinite|last_day|localtime|localtimestamp|months_between|next_day|now|sysdate|timestamp_cmp|timestamp_cmp_date|trunc|abs|acos|asin|atan|" +
156
        "atan2|cbrt|ceiling|ceil|checksum|cos|cot|degrees|dexp|dlog1|dlog10|exp|floor|ln|log|mod|pi|power|radians|random|round|sin|sign|sqrt|tan|trunc|ascii|" +
157
        "bpcharcmp|btrim|bttext_pattern_cmp|char_length|character_length|charindex|chr|concat|crc32|func_sha1|get_bit|get_byte|initcap|left|right|len|length|" +
158
        "lower|lpad|rpad|ltrim|md5|octet_length|position|quote_ident|quote_literal|regexp_count|regexp_instr|regexp_replace|regexp_substr|repeat|replace|replicate|" +
159
        "reverse|rtrim|set_bit|set_byte|split_part|strpos|strtol|substring|textlen|to_ascii|to_hex|translate|trim|upper|json_array_length|json_extract_array_element_text|" +
160
        "json_extract_path_text|cast|convert|to_char|to_date|to_number|current_database|current_schema|current_schemas|current_user|current_user_id|has_database_privilege|" +
161
        "has_schema_privilege|has_table_privilege|pg_backend_pid|pg_last_copy_count|pg_last_copy_id|pg_last_query_id|pg_last_unload_count|session_user|slice_num|user|version"
162
    );
163

    
164
    var keywordMapper = this.createKeywordMapper({
165
        "support.function": builtinFunctions,
166
        "keyword": keywords
167
    }, "identifier", true);
168

    
169

    
170
    var sqlRules = [{
171
            token : "string", // single line string -- assume dollar strings if multi-line for now
172
            regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
173
        }, {
174
            token : "variable.language", // pg identifier
175
            regex : '".*?"'
176
        }, {
177
            token : "constant.numeric", // float
178
            regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
179
        }, {
180
            token : keywordMapper,
181
            regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b" // TODO - Unicode in identifiers
182
        }, {
183
            token : "keyword.operator",
184
            regex : "!|!!|!~|!~\\*|!~~|!~~\\*|#|##|#<|#<=|#<>|#=|#>|#>=|%|\\&|\\&\\&|\\&<|\\&<\\||\\&>|\\*|\\+|" +
185
                    "\\-|/|<|<#>|<\\->|<<|<<=|<<\\||<=|<>|<\\?>|<@|<\\^|=|>|>=|>>|>>=|>\\^|\\?#|\\?\\-|\\?\\-\\||" +
186
                    "\\?\\||\\?\\|\\||@|@\\-@|@>|@@|@@@|\\^|\\||\\|\\&>|\\|/|\\|>>|\\|\\||\\|\\|/|~|~\\*|~<=~|~<~|" +
187
                    "~=|~>=~|~>~|~~|~~\\*"
188
        }, {
189
            token : "paren.lparen",
190
            regex : "[\\(]"
191
        }, {
192
            token : "paren.rparen",
193
            regex : "[\\)]"
194
        }, {
195
            token : "text",
196
            regex : "\\s+"
197
        }
198
    ];
199

    
200

    
201
    this.$rules = {
202
        "start" : [{
203
                token : "comment",
204
                regex : "--.*$"
205
            },
206
            DocCommentHighlightRules.getStartRule("doc-start"),
207
            {
208
                token : "comment", // multi-line comment
209
                regex : "\\/\\*",
210
                next : "comment"
211
            },{
212
                token : "keyword.statementBegin",
213
                regex : "^[a-zA-Z]+", // Could enumerate starting keywords but this allows things to work when new statements are added.
214
                next : "statement"
215
            },{
216
                token : "support.buildin", // psql directive
217
                regex : "^\\\\[\\S]+.*$"
218
            }
219
        ],
220

    
221
        "statement" : [{
222
                token : "comment",
223
                regex : "--.*$"
224
            }, {
225
                token : "comment", // multi-line comment
226
                regex : "\\/\\*",
227
                next : "commentStatement"
228
            }, {
229
                token : "statementEnd",
230
                regex : ";",
231
                next : "start"
232
            }, {
233
                token : "string",
234
                regex : "\\$json\\$",
235
                next : "json-start"
236
            }, {
237
                token : "string",
238
                regex : "\\$[\\w_0-9]*\\$$", // dollar quote at the end of a line
239
                next : "dollarSql"
240
            }, {
241
                token : "string",
242
                regex : "\\$[\\w_0-9]*\\$",
243
                next : "dollarStatementString"
244
            }
245
        ].concat(sqlRules),
246

    
247
        "dollarSql" : [{
248
                token : "comment",
249
                regex : "--.*$"
250
            }, {
251
                token : "comment", // multi-line comment
252
                regex : "\\/\\*",
253
                next : "commentDollarSql"
254
            }, {
255
                token : "string", // end quoting with dollar at the start of a line
256
                regex : "^\\$[\\w_0-9]*\\$",
257
                next : "statement"
258
            }, {
259
                token : "string",
260
                regex : "\\$[\\w_0-9]*\\$",
261
                next : "dollarSqlString"
262
            }
263
        ].concat(sqlRules),
264

    
265
        "comment" : [{
266
                token : "comment", // closing comment
267
                regex : ".*?\\*\\/",
268
                next : "start"
269
            }, {
270
                token : "comment", // comment spanning whole line
271
                regex : ".+"
272
            }
273
        ],
274

    
275
        "commentStatement" : [{
276
                token : "comment", // closing comment
277
                regex : ".*?\\*\\/",
278
                next : "statement"
279
            }, {
280
                token : "comment", // comment spanning whole line
281
                regex : ".+"
282
            }
283
        ],
284

    
285
        "commentDollarSql" : [{
286
                token : "comment", // closing comment
287
                regex : ".*?\\*\\/",
288
                next : "dollarSql"
289
            }, {
290
                token : "comment", // comment spanning whole line
291
                regex : ".+"
292
            }
293
        ],
294

    
295
        "dollarStatementString" : [{
296
                token : "string", // closing dollarstring
297
                regex : ".*?\\$[\\w_0-9]*\\$",
298
                next : "statement"
299
            }, {
300
                token : "string", // dollarstring spanning whole line
301
                regex : ".+"
302
            }
303
        ],
304

    
305
        "dollarSqlString" : [{
306
                token : "string", // closing dollarstring
307
                regex : ".*?\\$[\\w_0-9]*\\$",
308
                next : "dollarSql"
309
            }, {
310
                token : "string", // dollarstring spanning whole line
311
                regex : ".+"
312
            }
313
        ]
314
    };
315

    
316
    this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]);
317
    this.embedRules(JsonHighlightRules, "json-", [{token : "string", regex : "\\$json\\$", next : "statement"}]);
318
};
319

    
320
oop.inherits(RedshiftHighlightRules, TextHighlightRules);
321

    
322
exports.RedshiftHighlightRules = RedshiftHighlightRules;
323
});
324

    
325
ace.define("ace/mode/redshift",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/redshift_highlight_rules","ace/range"], function(require, exports, module) {
326

    
327
var oop = require("../lib/oop");
328
var TextMode = require("../mode/text").Mode;
329
var RedshiftHighlightRules = require("./redshift_highlight_rules").RedshiftHighlightRules;
330
var Range = require("../range").Range;
331

    
332
var Mode = function() {
333
    this.HighlightRules = RedshiftHighlightRules;
334
};
335
oop.inherits(Mode, TextMode);
336

    
337
(function() {
338
    this.lineCommentStart = "--";
339
    this.blockComment = {start: "/*", end: "*/"};
340

    
341
    this.getNextLineIndent = function(state, line, tab) { 
342
        if (state == "start" || state == "keyword.statementEnd") {
343
            return "";
344
        } else {
345
            return this.$getIndent(line); // Keep whatever indent the previous line has
346
        }
347
    };
348

    
349
    this.$id = "ace/mode/redshift";
350
}).call(Mode.prototype);
351

    
352
exports.Mode = Mode;
353
});                (function() {
354
                    ace.require(["ace/mode/redshift"], function(m) {
355
                        if (typeof module == "object" && typeof exports == "object" && module) {
356
                            module.exports = m;
357
                        }
358
                    });
359
                })();
360
            
(154-154/244)