6ff5826d3c93e2bd37bc511affebc78b.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. ace.define("ace/mode/sql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  2. var oop = require("../lib/oop");
  3. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  4. var SqlHighlightRules = function () {
  5. var keywords = ("select|insert|update|delete|from|where|and|or|group|by|order|limit|offset|having|as|case|" +
  6. "when|then|else|end|type|left|right|join|on|outer|desc|asc|union|create|table|primary|key|if|" +
  7. "foreign|not|references|default|null|inner|cross|natural|database|drop|grant|distinct");
  8. var builtinConstants = ("true|false");
  9. var builtinFunctions = ("avg|count|first|last|max|min|sum|ucase|lcase|mid|len|round|rank|now|format|" +
  10. "coalesce|ifnull|isnull|nvl");
  11. var dataTypes = ("int|numeric|decimal|date|varchar|char|bigint|float|double|bit|binary|text|set|timestamp|" +
  12. "money|real|number|integer");
  13. var keywordMapper = this.createKeywordMapper({
  14. "support.function": builtinFunctions,
  15. "keyword": keywords,
  16. "constant.language": builtinConstants,
  17. "storage.type": dataTypes
  18. }, "identifier", true);
  19. this.$rules = {
  20. "start": [{
  21. token: "comment",
  22. regex: "--.*$"
  23. }, {
  24. token: "comment",
  25. start: "/\\*",
  26. end: "\\*/"
  27. }, {
  28. token: "string",
  29. regex: '".*?"'
  30. }, {
  31. token: "string",
  32. regex: "'.*?'"
  33. }, {
  34. token: "string",
  35. regex: "`.*?`"
  36. }, {
  37. token: "constant.numeric",
  38. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  39. }, {
  40. token: keywordMapper,
  41. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  42. }, {
  43. token: "keyword.operator",
  44. regex: "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  45. }, {
  46. token: "paren.lparen",
  47. regex: "[\\(]"
  48. }, {
  49. token: "paren.rparen",
  50. regex: "[\\)]"
  51. }, {
  52. token: "text",
  53. regex: "\\s+"
  54. }]
  55. };
  56. this.normalizeRules();
  57. };
  58. oop.inherits(SqlHighlightRules, TextHighlightRules);
  59. exports.SqlHighlightRules = SqlHighlightRules;
  60. });
  61. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module){"use strict";
  62. var oop = require("../../lib/oop");
  63. var Range = require("../../range").Range;
  64. var BaseFoldMode = require("./fold_mode").FoldMode;
  65. var FoldMode = exports.FoldMode = function (commentRegex) {
  66. if (commentRegex) {
  67. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  68. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  69. }
  70. };
  71. oop.inherits(FoldMode, BaseFoldMode);
  72. (function () {
  73. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  74. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  75. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  76. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  77. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  78. this._getFoldWidgetBase = this.getFoldWidget;
  79. this.getFoldWidget = function (session, foldStyle, row) {
  80. var line = session.getLine(row);
  81. if (this.singleLineBlockCommentRe.test(line)) {
  82. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  83. return "";
  84. }
  85. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  86. if (!fw && this.startRegionRe.test(line))
  87. return "start"; // lineCommentRegionStart
  88. return fw;
  89. };
  90. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  91. var line = session.getLine(row);
  92. if (this.startRegionRe.test(line))
  93. return this.getCommentRegionBlock(session, line, row);
  94. var match = line.match(this.foldingStartMarker);
  95. if (match) {
  96. var i = match.index;
  97. if (match[1])
  98. return this.openingBracketBlock(session, match[1], row, i);
  99. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  100. if (range && !range.isMultiLine()) {
  101. if (forceMultiline) {
  102. range = this.getSectionRange(session, row);
  103. }
  104. else if (foldStyle != "all")
  105. range = null;
  106. }
  107. return range;
  108. }
  109. if (foldStyle === "markbegin")
  110. return;
  111. var match = line.match(this.foldingStopMarker);
  112. if (match) {
  113. var i = match.index + match[0].length;
  114. if (match[1])
  115. return this.closingBracketBlock(session, match[1], row, i);
  116. return session.getCommentFoldRange(row, i, -1);
  117. }
  118. };
  119. this.getSectionRange = function (session, row) {
  120. var line = session.getLine(row);
  121. var startIndent = line.search(/\S/);
  122. var startRow = row;
  123. var startColumn = line.length;
  124. row = row + 1;
  125. var endRow = row;
  126. var maxRow = session.getLength();
  127. while (++row < maxRow) {
  128. line = session.getLine(row);
  129. var indent = line.search(/\S/);
  130. if (indent === -1)
  131. continue;
  132. if (startIndent > indent)
  133. break;
  134. var subRange = this.getFoldWidgetRange(session, "all", row);
  135. if (subRange) {
  136. if (subRange.start.row <= startRow) {
  137. break;
  138. }
  139. else if (subRange.isMultiLine()) {
  140. row = subRange.end.row;
  141. }
  142. else if (startIndent == indent) {
  143. break;
  144. }
  145. }
  146. endRow = row;
  147. }
  148. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  149. };
  150. this.getCommentRegionBlock = function (session, line, row) {
  151. var startColumn = line.search(/\s*$/);
  152. var maxRow = session.getLength();
  153. var startRow = row;
  154. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  155. var depth = 1;
  156. while (++row < maxRow) {
  157. line = session.getLine(row);
  158. var m = re.exec(line);
  159. if (!m)
  160. continue;
  161. if (m[1])
  162. depth--;
  163. else
  164. depth++;
  165. if (!depth)
  166. break;
  167. }
  168. var endRow = row;
  169. if (endRow > startRow) {
  170. return new Range(startRow, startColumn, endRow, line.length);
  171. }
  172. };
  173. }).call(FoldMode.prototype);
  174. });
  175. ace.define("ace/mode/folding/sql",["require","exports","module","ace/lib/oop","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  176. var oop = require("../../lib/oop");
  177. var BaseFoldMode = require("./cstyle").FoldMode;
  178. var FoldMode = exports.FoldMode = function () { };
  179. oop.inherits(FoldMode, BaseFoldMode);
  180. (function () {
  181. }).call(FoldMode.prototype);
  182. });
  183. ace.define("ace/mode/sql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sql_highlight_rules","ace/mode/folding/sql"], function(require, exports, module){"use strict";
  184. var oop = require("../lib/oop");
  185. var TextMode = require("./text").Mode;
  186. var SqlHighlightRules = require("./sql_highlight_rules").SqlHighlightRules;
  187. var SqlFoldMode = require("./folding/sql").FoldMode;
  188. var Mode = function () {
  189. this.HighlightRules = SqlHighlightRules;
  190. this.foldingRules = new SqlFoldMode();
  191. this.$behaviour = this.$defaultBehaviour;
  192. };
  193. oop.inherits(Mode, TextMode);
  194. (function () {
  195. this.lineCommentStart = "--";
  196. this.blockComment = { start: "/*", end: "*/" };
  197. this.$id = "ace/mode/sql";
  198. this.snippetFileId = "ace/snippets/sql";
  199. }).call(Mode.prototype);
  200. exports.Mode = Mode;
  201. }); (function() {
  202. ace.require(["ace/mode/sql"], function(m) {
  203. if (typeof module == "object" && typeof exports == "object" && module) {
  204. module.exports = m;
  205. }
  206. });
  207. })();