PageRenderTime 85ms CodeModel.GetById 44ms RepoModel.GetById 0ms app.codeStats 0ms

/static/dashboard/node_modules/ace-builds/src-noconflict/mode-redshift.js

https://gitlab.com/IvettGeorge/tecnicassanacion
JavaScript | 360 lines | 317 code | 43 blank | 0 comment | 10 complexity | a07f2b025030bd4f277803aea0e6a539 MD5 | raw file
  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. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var DocCommentHighlightRules = function() {
  6. this.$rules = {
  7. "start" : [ {
  8. token : "comment.doc.tag",
  9. regex : "@[\\w\\d_]+" // TODO: fix email addresses
  10. },
  11. DocCommentHighlightRules.getTagRule(),
  12. {
  13. defaultToken : "comment.doc",
  14. caseInsensitive: true
  15. }]
  16. };
  17. };
  18. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  19. DocCommentHighlightRules.getTagRule = function(start) {
  20. return {
  21. token : "comment.doc.tag.storage.type",
  22. regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  23. };
  24. };
  25. DocCommentHighlightRules.getStartRule = function(start) {
  26. return {
  27. token : "comment.doc", // doc comment
  28. regex : "\\/\\*(?=\\*)",
  29. next : start
  30. };
  31. };
  32. DocCommentHighlightRules.getEndRule = function (start) {
  33. return {
  34. token : "comment.doc", // closing comment
  35. regex : "\\*\\/",
  36. next : start
  37. };
  38. };
  39. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  40. });
  41. ace.define("ace/mode/json_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  45. var JsonHighlightRules = function() {
  46. this.$rules = {
  47. "start" : [
  48. {
  49. token : "variable", // single line
  50. regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
  51. }, {
  52. token : "string", // single line
  53. regex : '"',
  54. next : "string"
  55. }, {
  56. token : "constant.numeric", // hex
  57. regex : "0[xX][0-9a-fA-F]+\\b"
  58. }, {
  59. token : "constant.numeric", // float
  60. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  61. }, {
  62. token : "constant.language.boolean",
  63. regex : "(?:true|false)\\b"
  64. }, {
  65. token : "text", // single quoted strings are not allowed
  66. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  67. }, {
  68. token : "comment", // comments are not allowed, but who cares?
  69. regex : "\\/\\/.*$"
  70. }, {
  71. token : "comment.start", // comments are not allowed, but who cares?
  72. regex : "\\/\\*",
  73. next : "comment"
  74. }, {
  75. token : "paren.lparen",
  76. regex : "[[({]"
  77. }, {
  78. token : "paren.rparen",
  79. regex : "[\\])}]"
  80. }, {
  81. token : "text",
  82. regex : "\\s+"
  83. }
  84. ],
  85. "string" : [
  86. {
  87. token : "constant.language.escape",
  88. regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
  89. }, {
  90. token : "string",
  91. regex : '"|$',
  92. next : "start"
  93. }, {
  94. defaultToken : "string"
  95. }
  96. ],
  97. "comment" : [
  98. {
  99. token : "comment.end", // comments are not allowed, but who cares?
  100. regex : "\\*\\/",
  101. next : "start"
  102. }, {
  103. defaultToken: "comment"
  104. }
  105. ]
  106. };
  107. };
  108. oop.inherits(JsonHighlightRules, TextHighlightRules);
  109. exports.JsonHighlightRules = JsonHighlightRules;
  110. });
  111. 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) {
  112. var oop = require("../lib/oop");
  113. var lang = require("../lib/lang");
  114. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  115. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  116. var JsonHighlightRules = require("./json_highlight_rules").JsonHighlightRules;
  117. var RedshiftHighlightRules = function() {
  118. var keywords = (
  119. "aes128|aes256|all|allowoverwrite|analyse|analyze|and|any|array|as|asc|authorization|backup|" +
  120. "between|binary|blanksasnull|both|bytedict|bzip2|case|cast|check|collate|column|constraint|create|credentials|" +
  121. "cross|current_date|current_time|current_timestamp|current_user|current_user_id|default|deferrable|deflate|defrag|delta|" +
  122. "delta32k|desc|disable|distinct|do|else|emptyasnull|enable|encode|encrypt|encryption|end|except|explicit|false|for|foreign|" +
  123. "freeze|from|full|globaldict256|globaldict64k|grant|group|gzip|having|identity|ignore|ilike|in|initially|inner|intersect|into|is|" +
  124. "isnull|join|leading|left|like|limit|localtime|localtimestamp|lun|luns|lzo|lzop|minus|mostly13|mostly32|mostly8|natural|new|not|notnull|" +
  125. "null|nulls|off|offline|offset|old|on|only|open|or|order|outer|overlaps|parallel|partition|percent|permissions|placing|primary|raw|readratio|" +
  126. "recover|references|rejectlog|resort|restore|right|select|session_user|similar|some|sysdate|system|table|tag|tdes|text255|text32k|then|timestamp|" +
  127. "to|top|trailing|true|truncatecolumns|union|unique|user|using|verbose|wallet|when|where|with|without"
  128. );
  129. var builtinFunctions = (
  130. "current_schema|current_schemas|has_database_privilege|has_schema_privilege|has_table_privilege|age|current_time|current_timestamp|localtime|" +
  131. "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|" +
  132. "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|" +
  133. "percentile_cont|percentile_disc|rank|ratio_to_report|row_number|case|coalesce|decode|greatest|least|nvl|nvl2|nullif|add_months|age|convert_timezone|" +
  134. "current_date|timeofday|current_time|current_timestamp|date_cmp|date_cmp_timestamp|date_part_year|dateadd|datediff|date_part|date_trunc|extract|getdate|" +
  135. "interval_cmp|isfinite|last_day|localtime|localtimestamp|months_between|next_day|now|sysdate|timestamp_cmp|timestamp_cmp_date|trunc|abs|acos|asin|atan|" +
  136. "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|" +
  137. "bpcharcmp|btrim|bttext_pattern_cmp|char_length|character_length|charindex|chr|concat|crc32|func_sha1|get_bit|get_byte|initcap|left|right|len|length|" +
  138. "lower|lpad|rpad|ltrim|md5|octet_length|position|quote_ident|quote_literal|regexp_count|regexp_instr|regexp_replace|regexp_substr|repeat|replace|replicate|" +
  139. "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|" +
  140. "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|" +
  141. "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"
  142. );
  143. var keywordMapper = this.createKeywordMapper({
  144. "support.function": builtinFunctions,
  145. "keyword": keywords
  146. }, "identifier", true);
  147. var sqlRules = [{
  148. token : "string", // single line string -- assume dollar strings if multi-line for now
  149. regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
  150. }, {
  151. token : "variable.language", // pg identifier
  152. regex : '".*?"'
  153. }, {
  154. token : "constant.numeric", // float
  155. regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  156. }, {
  157. token : keywordMapper,
  158. regex : "[a-zA-Z_][a-zA-Z0-9_$]*\\b" // TODO - Unicode in identifiers
  159. }, {
  160. token : "keyword.operator",
  161. regex : "!|!!|!~|!~\\*|!~~|!~~\\*|#|##|#<|#<=|#<>|#=|#>|#>=|%|\\&|\\&\\&|\\&<|\\&<\\||\\&>|\\*|\\+|" +
  162. "\\-|/|<|<#>|<\\->|<<|<<=|<<\\||<=|<>|<\\?>|<@|<\\^|=|>|>=|>>|>>=|>\\^|\\?#|\\?\\-|\\?\\-\\||" +
  163. "\\?\\||\\?\\|\\||@|@\\-@|@>|@@|@@@|\\^|\\||\\|\\&>|\\|/|\\|>>|\\|\\||\\|\\|/|~|~\\*|~<=~|~<~|" +
  164. "~=|~>=~|~>~|~~|~~\\*"
  165. }, {
  166. token : "paren.lparen",
  167. regex : "[\\(]"
  168. }, {
  169. token : "paren.rparen",
  170. regex : "[\\)]"
  171. }, {
  172. token : "text",
  173. regex : "\\s+"
  174. }
  175. ];
  176. this.$rules = {
  177. "start" : [{
  178. token : "comment",
  179. regex : "--.*$"
  180. },
  181. DocCommentHighlightRules.getStartRule("doc-start"),
  182. {
  183. token : "comment", // multi-line comment
  184. regex : "\\/\\*",
  185. next : "comment"
  186. },{
  187. token : "keyword.statementBegin",
  188. regex : "^[a-zA-Z]+", // Could enumerate starting keywords but this allows things to work when new statements are added.
  189. next : "statement"
  190. },{
  191. token : "support.buildin", // psql directive
  192. regex : "^\\\\[\\S]+.*$"
  193. }
  194. ],
  195. "statement" : [{
  196. token : "comment",
  197. regex : "--.*$"
  198. }, {
  199. token : "comment", // multi-line comment
  200. regex : "\\/\\*",
  201. next : "commentStatement"
  202. }, {
  203. token : "statementEnd",
  204. regex : ";",
  205. next : "start"
  206. }, {
  207. token : "string",
  208. regex : "\\$json\\$",
  209. next : "json-start"
  210. }, {
  211. token : "string",
  212. regex : "\\$[\\w_0-9]*\\$$", // dollar quote at the end of a line
  213. next : "dollarSql"
  214. }, {
  215. token : "string",
  216. regex : "\\$[\\w_0-9]*\\$",
  217. next : "dollarStatementString"
  218. }
  219. ].concat(sqlRules),
  220. "dollarSql" : [{
  221. token : "comment",
  222. regex : "--.*$"
  223. }, {
  224. token : "comment", // multi-line comment
  225. regex : "\\/\\*",
  226. next : "commentDollarSql"
  227. }, {
  228. token : "string", // end quoting with dollar at the start of a line
  229. regex : "^\\$[\\w_0-9]*\\$",
  230. next : "statement"
  231. }, {
  232. token : "string",
  233. regex : "\\$[\\w_0-9]*\\$",
  234. next : "dollarSqlString"
  235. }
  236. ].concat(sqlRules),
  237. "comment" : [{
  238. token : "comment", // closing comment
  239. regex : ".*?\\*\\/",
  240. next : "start"
  241. }, {
  242. token : "comment", // comment spanning whole line
  243. regex : ".+"
  244. }
  245. ],
  246. "commentStatement" : [{
  247. token : "comment", // closing comment
  248. regex : ".*?\\*\\/",
  249. next : "statement"
  250. }, {
  251. token : "comment", // comment spanning whole line
  252. regex : ".+"
  253. }
  254. ],
  255. "commentDollarSql" : [{
  256. token : "comment", // closing comment
  257. regex : ".*?\\*\\/",
  258. next : "dollarSql"
  259. }, {
  260. token : "comment", // comment spanning whole line
  261. regex : ".+"
  262. }
  263. ],
  264. "dollarStatementString" : [{
  265. token : "string", // closing dollarstring
  266. regex : ".*?\\$[\\w_0-9]*\\$",
  267. next : "statement"
  268. }, {
  269. token : "string", // dollarstring spanning whole line
  270. regex : ".+"
  271. }
  272. ],
  273. "dollarSqlString" : [{
  274. token : "string", // closing dollarstring
  275. regex : ".*?\\$[\\w_0-9]*\\$",
  276. next : "dollarSql"
  277. }, {
  278. token : "string", // dollarstring spanning whole line
  279. regex : ".+"
  280. }
  281. ]
  282. };
  283. this.embedRules(DocCommentHighlightRules, "doc-", [ DocCommentHighlightRules.getEndRule("start") ]);
  284. this.embedRules(JsonHighlightRules, "json-", [{token : "string", regex : "\\$json\\$", next : "statement"}]);
  285. };
  286. oop.inherits(RedshiftHighlightRules, TextHighlightRules);
  287. exports.RedshiftHighlightRules = RedshiftHighlightRules;
  288. });
  289. 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) {
  290. var oop = require("../lib/oop");
  291. var TextMode = require("../mode/text").Mode;
  292. var RedshiftHighlightRules = require("./redshift_highlight_rules").RedshiftHighlightRules;
  293. var Range = require("../range").Range;
  294. var Mode = function() {
  295. this.HighlightRules = RedshiftHighlightRules;
  296. };
  297. oop.inherits(Mode, TextMode);
  298. (function() {
  299. this.lineCommentStart = "--";
  300. this.blockComment = {start: "/*", end: "*/"};
  301. this.getNextLineIndent = function(state, line, tab) {
  302. if (state == "start" || state == "keyword.statementEnd") {
  303. return "";
  304. } else {
  305. return this.$getIndent(line); // Keep whatever indent the previous line has
  306. }
  307. };
  308. this.$id = "ace/mode/redshift";
  309. }).call(Mode.prototype);
  310. exports.Mode = Mode;
  311. }); (function() {
  312. ace.require(["ace/mode/redshift"], function(m) {
  313. if (typeof module == "object" && typeof exports == "object" && module) {
  314. module.exports = m;
  315. }
  316. });
  317. })();