238b48c537406ead43a4005567d5a013.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. ace.define("ace/mode/plsql_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module){/* ***** BEGIN LICENSE BLOCK *****
  2. * Distributed under the BSD license:
  3. *
  4. * Copyright (c) 2012, Ajax.org B.V.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * * Neither the name of Ajax.org B.V. nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. * ***** END LICENSE BLOCK ***** */
  30. "use strict";
  31. var oop = require("../lib/oop");
  32. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  33. var plsqlHighlightRules = function () {
  34. var keywords = ("all|alter|and|any|array|arrow|as|asc|at|begin|between|by|case|check|clusters|cluster|colauth|columns|compress|connect|crash|create|cross|current|database|declare|default|delete|desc|distinct|drop|else|end|exception|exclusive|exists|fetch|form|for|foreign|from|goto|grant|group|having|identified|if|in|inner|indexes|index|insert|intersect|into|is|join|key|left|like|lock|minus|mode|natural|nocompress|not|nowait|null|of|on|option|or|order,overlaps|outer|primary|prior|procedure|public|range|record|references|resource|revoke|right|select|share|size|sql|start|subtype|tabauth|table|then|to|type|union|unique|update|use|values|view|views|when|where|with");
  35. var builtinConstants = ("true|false");
  36. var builtinFunctions = ("abs|acos|add_months|ascii|asciistr|asin|atan|atan2|avg|bfilename|bin_to_num|bitand|cardinality|case|cast|ceil|chartorowid|chr|coalesce|compose|concat|convert|corr|cos|cosh|count|covar_pop|covar_samp|cume_dist|current_date|current_timestamp|dbtimezone|decode|decompose|dense_rank|dump|empty_blob|empty_clob|exp|extract|first_value|floor|from_tz|greatest|group_id|hextoraw|initcap|instr|instr2|instr4|instrb|instrc|lag|last_day|last_value|lead|least|length|length2|length4|lengthb|lengthc|listagg|ln|lnnvl|localtimestamp|log|lower|lpad|ltrim|max|median|min|mod|months_between|nanvl|nchr|new_time|next_day|nth_value|nullif|numtodsinterval|numtoyminterval|nvl|nvl2|power|rank|rawtohex|regexp_count|regexp_instr|regexp_replace|regexp_substr|remainder|replace|round|rownum|rpad|rtrim|sessiontimezone|sign|sin|sinh|soundex|sqrt|stddev|substr|sum|sys_context|sysdate|systimestamp|tan|tanh|to_char|to_clob|to_date|to_dsinterval|to_lob|to_multi_byte|to_nclob|to_number|to_single_byte|to_timestamp|to_timestamp_tz|to_yminterval|translate|trim|trunc|tz_offset|uid|upper|user|userenv|var_pop|var_samp|variance|vsize");
  37. var dataTypes = ("char|nchar|nvarchar2|varchar2|long|raw|" +
  38. "number|numeric|float|dec|decimal|integer|int|smallint|real|double|precision|" +
  39. "date|timestamp|interval|year|day|" +
  40. "bfile|blob|clob|nclob|" +
  41. "rowid|urowid");
  42. var keywordMapper = this.createKeywordMapper({
  43. "support.function": builtinFunctions,
  44. "keyword": keywords,
  45. "constant.language": builtinConstants,
  46. "storage.type": dataTypes
  47. }, "identifier", true);
  48. this.$rules = {
  49. "start": [{
  50. token: "comment",
  51. regex: "--.*$"
  52. }, {
  53. token: "comment",
  54. start: "/\\*",
  55. end: "\\*/"
  56. }, {
  57. token: "string", // " string
  58. regex: '".*?"'
  59. }, {
  60. token: "string", // ' string
  61. regex: "'.*?'"
  62. }, {
  63. token: "constant.numeric", // float
  64. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  65. }, {
  66. token: keywordMapper,
  67. regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  68. }, {
  69. token: "keyword.operator",
  70. regex: "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|="
  71. }, {
  72. token: "paren.lparen",
  73. regex: "[\\(]"
  74. }, {
  75. token: "paren.rparen",
  76. regex: "[\\)]"
  77. }, {
  78. token: "text",
  79. regex: "\\s+"
  80. }]
  81. };
  82. this.normalizeRules();
  83. };
  84. oop.inherits(plsqlHighlightRules, TextHighlightRules);
  85. exports.plsqlHighlightRules = plsqlHighlightRules;
  86. });
  87. 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";
  88. var oop = require("../../lib/oop");
  89. var Range = require("../../range").Range;
  90. var BaseFoldMode = require("./fold_mode").FoldMode;
  91. var FoldMode = exports.FoldMode = function (commentRegex) {
  92. if (commentRegex) {
  93. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  94. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  95. }
  96. };
  97. oop.inherits(FoldMode, BaseFoldMode);
  98. (function () {
  99. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  100. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  101. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  102. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  103. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  104. this._getFoldWidgetBase = this.getFoldWidget;
  105. this.getFoldWidget = function (session, foldStyle, row) {
  106. var line = session.getLine(row);
  107. if (this.singleLineBlockCommentRe.test(line)) {
  108. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  109. return "";
  110. }
  111. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  112. if (!fw && this.startRegionRe.test(line))
  113. return "start"; // lineCommentRegionStart
  114. return fw;
  115. };
  116. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  117. var line = session.getLine(row);
  118. if (this.startRegionRe.test(line))
  119. return this.getCommentRegionBlock(session, line, row);
  120. var match = line.match(this.foldingStartMarker);
  121. if (match) {
  122. var i = match.index;
  123. if (match[1])
  124. return this.openingBracketBlock(session, match[1], row, i);
  125. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  126. if (range && !range.isMultiLine()) {
  127. if (forceMultiline) {
  128. range = this.getSectionRange(session, row);
  129. }
  130. else if (foldStyle != "all")
  131. range = null;
  132. }
  133. return range;
  134. }
  135. if (foldStyle === "markbegin")
  136. return;
  137. var match = line.match(this.foldingStopMarker);
  138. if (match) {
  139. var i = match.index + match[0].length;
  140. if (match[1])
  141. return this.closingBracketBlock(session, match[1], row, i);
  142. return session.getCommentFoldRange(row, i, -1);
  143. }
  144. };
  145. this.getSectionRange = function (session, row) {
  146. var line = session.getLine(row);
  147. var startIndent = line.search(/\S/);
  148. var startRow = row;
  149. var startColumn = line.length;
  150. row = row + 1;
  151. var endRow = row;
  152. var maxRow = session.getLength();
  153. while (++row < maxRow) {
  154. line = session.getLine(row);
  155. var indent = line.search(/\S/);
  156. if (indent === -1)
  157. continue;
  158. if (startIndent > indent)
  159. break;
  160. var subRange = this.getFoldWidgetRange(session, "all", row);
  161. if (subRange) {
  162. if (subRange.start.row <= startRow) {
  163. break;
  164. }
  165. else if (subRange.isMultiLine()) {
  166. row = subRange.end.row;
  167. }
  168. else if (startIndent == indent) {
  169. break;
  170. }
  171. }
  172. endRow = row;
  173. }
  174. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  175. };
  176. this.getCommentRegionBlock = function (session, line, row) {
  177. var startColumn = line.search(/\s*$/);
  178. var maxRow = session.getLength();
  179. var startRow = row;
  180. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  181. var depth = 1;
  182. while (++row < maxRow) {
  183. line = session.getLine(row);
  184. var m = re.exec(line);
  185. if (!m)
  186. continue;
  187. if (m[1])
  188. depth--;
  189. else
  190. depth++;
  191. if (!depth)
  192. break;
  193. }
  194. var endRow = row;
  195. if (endRow > startRow) {
  196. return new Range(startRow, startColumn, endRow, line.length);
  197. }
  198. };
  199. }).call(FoldMode.prototype);
  200. });
  201. ace.define("ace/mode/folding/sql",["require","exports","module","ace/lib/oop","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  202. var oop = require("../../lib/oop");
  203. var BaseFoldMode = require("./cstyle").FoldMode;
  204. var FoldMode = exports.FoldMode = function () { };
  205. oop.inherits(FoldMode, BaseFoldMode);
  206. (function () {
  207. }).call(FoldMode.prototype);
  208. });
  209. ace.define("ace/mode/plsql",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/plsql_highlight_rules","ace/mode/folding/sql"], function(require, exports, module){/* ***** BEGIN LICENSE BLOCK *****
  210. * Distributed under the BSD license:
  211. *
  212. * Copyright (c) 2012, Ajax.org B.V.
  213. * All rights reserved.
  214. *
  215. * Redistribution and use in source and binary forms, with or without
  216. * modification, are permitted provided that the following conditions are met:
  217. * * Redistributions of source code must retain the above copyright
  218. * notice, this list of conditions and the following disclaimer.
  219. * * Redistributions in binary form must reproduce the above copyright
  220. * notice, this list of conditions and the following disclaimer in the
  221. * documentation and/or other materials provided with the distribution.
  222. * * Neither the name of Ajax.org B.V. nor the
  223. * names of its contributors may be used to endorse or promote products
  224. * derived from this software without specific prior written permission.
  225. *
  226. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  227. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  228. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  229. * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
  230. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  231. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  232. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  233. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  234. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  235. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  236. *
  237. * ***** END LICENSE BLOCK ***** */
  238. "use strict";
  239. var oop = require("../lib/oop");
  240. var TextMode = require("./text").Mode;
  241. var PLSqlHighlightRules = require("./plsql_highlight_rules").plsqlHighlightRules;
  242. var FoldMode = require("./folding/sql").FoldMode;
  243. var Mode = function () {
  244. this.HighlightRules = PLSqlHighlightRules;
  245. this.foldingRules = new FoldMode();
  246. };
  247. oop.inherits(Mode, TextMode);
  248. (function () {
  249. this.lineCommentStart = "--";
  250. this.blockComment = { start: "/*", end: "*/" };
  251. this.$id = "ace/mode/plsql";
  252. }).call(Mode.prototype);
  253. exports.Mode = Mode;
  254. }); (function() {
  255. ace.require(["ace/mode/plsql"], function(m) {
  256. if (typeof module == "object" && typeof exports == "object" && module) {
  257. module.exports = m;
  258. }
  259. });
  260. })();