22cc8dfa6780c4baf11191388b0a4e71.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. ace.define("ace/mode/doc_comment_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 DocCommentHighlightRules = function () {
  5. this.$rules = {
  6. "start": [{
  7. token: "comment.doc.tag",
  8. regex: "@[\\w\\d_]+" // TODO: fix email addresses
  9. },
  10. DocCommentHighlightRules.getTagRule(),
  11. {
  12. defaultToken: "comment.doc",
  13. caseInsensitive: true
  14. }]
  15. };
  16. };
  17. oop.inherits(DocCommentHighlightRules, TextHighlightRules);
  18. DocCommentHighlightRules.getTagRule = function (start) {
  19. return {
  20. token: "comment.doc.tag.storage.type",
  21. regex: "\\b(?:TODO|FIXME|XXX|HACK)\\b"
  22. };
  23. };
  24. DocCommentHighlightRules.getStartRule = function (start) {
  25. return {
  26. token: "comment.doc",
  27. regex: "\\/\\*(?=\\*)",
  28. next: start
  29. };
  30. };
  31. DocCommentHighlightRules.getEndRule = function (start) {
  32. return {
  33. token: "comment.doc",
  34. regex: "\\*\\/",
  35. next: start
  36. };
  37. };
  38. exports.DocCommentHighlightRules = DocCommentHighlightRules;
  39. });
  40. ace.define("ace/mode/sqlserver_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module){"use strict";
  41. var oop = require("../lib/oop");
  42. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  43. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  44. var SqlServerHighlightRules = function () {
  45. var logicalOperators = "ALL|AND|ANY|BETWEEN|EXISTS|IN|LIKE|NOT|OR|SOME";
  46. logicalOperators += "|NULL|IS|APPLY|INNER|OUTER|LEFT|RIGHT|JOIN|CROSS"; //SSMS colors these gray too
  47. var builtinFunctions = (
  48. "OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|" +
  49. "AVG|CHECKSUM_AGG|COUNT|COUNT_BIG|GROUPING|GROUPING_ID|MAX|MIN|STDEV|STDEVP|SUM|VAR|VARP|" +
  50. "DENSE_RANK|NTILE|RANK|ROW_NUMBER" +
  51. "@@DATEFIRST|@@DBTS|@@LANGID|@@LANGUAGE|@@LOCK_TIMEOUT|@@MAX_CONNECTIONS|@@MAX_PRECISION|@@NESTLEVEL|@@OPTIONS|@@REMSERVER|@@SERVERNAME|@@SERVICENAME|@@SPID|@@TEXTSIZE|@@VERSION|" +
  52. "CAST|CONVERT|PARSE|TRY_CAST|TRY_CONVERT|TRY_PARSE" +
  53. "@@CURSOR_ROWS|@@FETCH_STATUS|CURSOR_STATUS|" +
  54. "@@DATEFIRST|@@LANGUAGE|CURRENT_TIMESTAMP|DATEADD|DATEDIFF|DATEFROMPARTS|DATENAME|DATEPART|DATETIME2FROMPARTS|DATETIMEFROMPARTS|DATETIMEOFFSETFROMPARTS|DAY|EOMONTH|GETDATE|GETUTCDATE|ISDATE|MONTH|SET DATEFIRST|SET DATEFORMAT|SET LANGUAGE|SMALLDATETIMEFROMPARTS|SP_HELPLANGUAGE|SWITCHOFFSET|SYSDATETIME|SYSDATETIMEOFFSET|SYSUTCDATETIME|TIMEFROMPARTS|TODATETIMEOFFSET|YEAR|" +
  55. "CHOOSE|IIF|" +
  56. "ABS|ACOS|ASIN|ATAN|ATN2|CEILING|COS|COT|DEGREES|EXP|FLOOR|LOG|LOG10|PI|POWER|RADIANS|RAND|ROUND|SIGN|SIN|SQRT|SQUARE|TAN|" +
  57. "@@PROCID|APPLOCK_MODE|APPLOCK_TEST|APP_NAME|ASSEMBLYPROPERTY|COLUMNPROPERTY|COL_LENGTH|COL_NAME|DATABASEPROPERTYEX|DATABASE_PRINCIPAL_ID|DB_ID|DB_NAME|FILEGROUPPROPERTY|FILEGROUP_ID|FILEGROUP_NAME|FILEPROPERTY|FILE_ID|FILE_IDEX|FILE_NAME|FULLTEXTCATALOGPROPERTY|FULLTEXTSERVICEPROPERTY|INDEXKEY_PROPERTY|INDEXPROPERTY|INDEX_COL|OBJECTPROPERTY|OBJECTPROPERTYEX|OBJECT_DEFINITION|OBJECT_ID|OBJECT_NAME|OBJECT_SCHEMA_NAME|ORIGINAL_DB_NAME|PARSENAME|SCHEMA_ID|SCHEMA_NAME|SCOPE_IDENTITY|SERVERPROPERTY|STATS_DATE|TYPEPROPERTY|TYPE_ID|TYPE_NAME|" +
  58. "CERTENCODED|CERTPRIVATEKEY|CURRENT_USER|DATABASE_PRINCIPAL_ID|HAS_PERMS_BY_NAME|IS_MEMBER|IS_ROLEMEMBER|IS_SRVROLEMEMBER|ORIGINAL_LOGIN|PERMISSIONS|PWDCOMPARE|PWDENCRYPT|SCHEMA_ID|SCHEMA_NAME|SESSION_USER|SUSER_ID|SUSER_NAME|SUSER_SID|SUSER_SNAME|SYS.FN_BUILTIN_PERMISSIONS|SYS.FN_GET_AUDIT_FILE|SYS.FN_MY_PERMISSIONS|SYSTEM_USER|USER_ID|USER_NAME|" +
  59. "ASCII|CHAR|CHARINDEX|CONCAT|DIFFERENCE|FORMAT|LEN|LOWER|LTRIM|NCHAR|PATINDEX|QUOTENAME|REPLACE|REPLICATE|REVERSE|RTRIM|SOUNDEX|SPACE|STR|STUFF|SUBSTRING|UNICODE|UPPER|" +
  60. "$PARTITION|@@ERROR|@@IDENTITY|@@PACK_RECEIVED|@@ROWCOUNT|@@TRANCOUNT|BINARY_CHECKSUM|CHECKSUM|CONNECTIONPROPERTY|CONTEXT_INFO|CURRENT_REQUEST_ID|ERROR_LINE|ERROR_MESSAGE|ERROR_NUMBER|ERROR_PROCEDURE|ERROR_SEVERITY|ERROR_STATE|FORMATMESSAGE|GETANSINULL|GET_FILESTREAM_TRANSACTION_CONTEXT|HOST_ID|HOST_NAME|ISNULL|ISNUMERIC|MIN_ACTIVE_ROWVERSION|NEWID|NEWSEQUENTIALID|ROWCOUNT_BIG|XACT_STATE|" +
  61. "@@CONNECTIONS|@@CPU_BUSY|@@IDLE|@@IO_BUSY|@@PACKET_ERRORS|@@PACK_RECEIVED|@@PACK_SENT|@@TIMETICKS|@@TOTAL_ERRORS|@@TOTAL_READ|@@TOTAL_WRITE|FN_VIRTUALFILESTATS|" +
  62. "PATINDEX|TEXTPTR|TEXTVALID|" +
  63. "COALESCE|NULLIF");
  64. var dataTypes = ("BIGINT|BINARY|BIT|CHAR|CURSOR|DATE|DATETIME|DATETIME2|DATETIMEOFFSET|DECIMAL|FLOAT|HIERARCHYID|IMAGE|INTEGER|INT|MONEY|NCHAR|NTEXT|NUMERIC|NVARCHAR|REAL|SMALLDATETIME|SMALLINT|SMALLMONEY|SQL_VARIANT|TABLE|TEXT|TIME|TIMESTAMP|TINYINT|UNIQUEIDENTIFIER|VARBINARY|VARCHAR|XML");
  65. var builtInStoredProcedures = "sp_addextendedproc|sp_addextendedproperty|sp_addmessage|sp_addtype|sp_addumpdevice|sp_add_data_file_recover_suspect_db|sp_add_log_file_recover_suspect_db|sp_altermessage|sp_attach_db|sp_attach_single_file_db|sp_autostats|sp_bindefault|sp_bindrule|sp_bindsession|sp_certify_removable|sp_clean_db_file_free_space|sp_clean_db_free_space|sp_configure|sp_control_plan_guide|sp_createstats|sp_create_plan_guide|sp_create_plan_guide_from_handle|sp_create_removable|sp_cycle_errorlog|sp_datatype_info|sp_dbcmptlevel|sp_dbmmonitoraddmonitoring|sp_dbmmonitorchangealert|sp_dbmmonitorchangemonitoring|sp_dbmmonitordropalert|sp_dbmmonitordropmonitoring|sp_dbmmonitorhelpalert|sp_dbmmonitorhelpmonitoring|sp_dbmmonitorresults|sp_db_increased_partitions|sp_delete_backuphistory|sp_depends|sp_describe_first_result_set|sp_describe_undeclared_parameters|sp_detach_db|sp_dropdevice|sp_dropextendedproc|sp_dropextendedproperty|sp_dropmessage|sp_droptype|sp_execute|sp_executesql|sp_getapplock|sp_getbindtoken|sp_help|sp_helpconstraint|sp_helpdb|sp_helpdevice|sp_helpextendedproc|sp_helpfile|sp_helpfilegroup|sp_helpindex|sp_helplanguage|sp_helpserver|sp_helpsort|sp_helpstats|sp_helptext|sp_helptrigger|sp_indexoption|sp_invalidate_textptr|sp_lock|sp_monitor|sp_prepare|sp_prepexec|sp_prepexecrpc|sp_procoption|sp_recompile|sp_refreshview|sp_releaseapplock|sp_rename|sp_renamedb|sp_resetstatus|sp_sequence_get_range|sp_serveroption|sp_setnetname|sp_settriggerorder|sp_spaceused|sp_tableoption|sp_unbindefault|sp_unbindrule|sp_unprepare|sp_updateextendedproperty|sp_updatestats|sp_validname|sp_who|sys.sp_merge_xtp_checkpoint_files|sys.sp_xtp_bind_db_resource_pool|sys.sp_xtp_checkpoint_force_garbage_collection|sys.sp_xtp_control_proc_exec_stats|sys.sp_xtp_control_query_exec_stats|sys.sp_xtp_unbind_db_resource_pool";
  66. var keywords = "ABSOLUTE|ACTION|ADA|ADD|ADMIN|AFTER|AGGREGATE|ALIAS|ALL|ALLOCATE|ALTER|AND|ANY|ARE|ARRAY|AS|ASC|ASENSITIVE|ASSERTION|ASYMMETRIC|AT|ATOMIC|AUTHORIZATION|BACKUP|BEFORE|BEGIN|BETWEEN|BIT_LENGTH|BLOB|BOOLEAN|BOTH|BREADTH|BREAK|BROWSE|BULK|BY|CALL|CALLED|CARDINALITY|CASCADE|CASCADED|CASE|CATALOG|CHARACTER|CHARACTER_LENGTH|CHAR_LENGTH|CHECK|CHECKPOINT|CLASS|CLOB|CLOSE|CLUSTERED|COALESCE|COLLATE|COLLATION|COLLECT|COLUMN|COMMIT|COMPLETION|COMPUTE|CONDITION|CONNECT|CONNECTION|CONSTRAINT|CONSTRAINTS|CONSTRUCTOR|CONTAINS|CONTAINSTABLE|CONTINUE|CORR|CORRESPONDING|COVAR_POP|COVAR_SAMP|CREATE|CROSS|CUBE|CUME_DIST|CURRENT|CURRENT_CATALOG|CURRENT_DATE|CURRENT_DEFAULT_TRANSFORM_GROUP|CURRENT_PATH|CURRENT_ROLE|CURRENT_SCHEMA|CURRENT_TIME|CURRENT_TRANSFORM_GROUP_FOR_TYPE|CYCLE|DATA|DATABASE|DBCC|DEALLOCATE|DEC|DECLARE|DEFAULT|DEFERRABLE|DEFERRED|DELETE|DENY|DEPTH|DEREF|DESC|DESCRIBE|DESCRIPTOR|DESTROY|DESTRUCTOR|DETERMINISTIC|DIAGNOSTICS|DICTIONARY|DISCONNECT|DISK|DISTINCT|DISTRIBUTED|DOMAIN|DOUBLE|DROP|DUMP|DYNAMIC|EACH|ELEMENT|ELSE|END|END-EXEC|EQUALS|ERRLVL|ESCAPE|EVERY|EXCEPT|EXCEPTION|EXEC|EXECUTE|EXISTS|EXIT|EXTERNAL|EXTRACT|FETCH|FILE|FILLFACTOR|FILTER|FIRST|FOR|FOREIGN|FORTRAN|FOUND|FREE|FREETEXT|FREETEXTTABLE|FROM|FULL|FULLTEXTTABLE|FUNCTION|FUSION|GENERAL|GET|GLOBAL|GO|GOTO|GRANT|GROUP|HAVING|HOLD|HOLDLOCK|HOST|HOUR|IDENTITY|IDENTITYCOL|IDENTITY_INSERT|IF|IGNORE|IMMEDIATE|IN|INCLUDE|INDEX|INDICATOR|INITIALIZE|INITIALLY|INNER|INOUT|INPUT|INSENSITIVE|INSERT|INTEGER|INTERSECT|INTERSECTION|INTERVAL|INTO|IS|ISOLATION|ITERATE|JOIN|KEY|KILL|LANGUAGE|LARGE|LAST|LATERAL|LEADING|LESS|LEVEL|LIKE|LIKE_REGEX|LIMIT|LINENO|LN|LOAD|LOCAL|LOCALTIME|LOCALTIMESTAMP|LOCATOR|MAP|MATCH|MEMBER|MERGE|METHOD|MINUTE|MOD|MODIFIES|MODIFY|MODULE|MULTISET|NAMES|NATIONAL|NATURAL|NCLOB|NEW|NEXT|NO|NOCHECK|NONCLUSTERED|NONE|NORMALIZE|NOT|NULL|NULLIF|OBJECT|OCCURRENCES_REGEX|OCTET_LENGTH|OF|OFF|OFFSETS|OLD|ON|ONLY|OPEN|OPERATION|OPTION|OR|ORDER|ORDINALITY|OUT|OUTER|OUTPUT|OVER|OVERLAPS|OVERLAY|PAD|PARAMETER|PARAMETERS|PARTIAL|PARTITION|PASCAL|PATH|PERCENT|PERCENTILE_CONT|PERCENTILE_DISC|PERCENT_RANK|PIVOT|PLAN|POSITION|POSITION_REGEX|POSTFIX|PRECISION|PREFIX|PREORDER|PREPARE|PRESERVE|PRIMARY|PRINT|PRIOR|PRIVILEGES|PROC|PROCEDURE|PUBLIC|RAISERROR|RANGE|READ|READS|READTEXT|RECONFIGURE|RECURSIVE|REF|REFERENCES|REFERENCING|REGR_AVGX|REGR_AVGY|REGR_COUNT|REGR_INTERCEPT|REGR_R2|REGR_SLOPE|REGR_SXX|REGR_SXY|REGR_SYY|RELATIVE|RELEASE|REPLICATION|RESTORE|RESTRICT|RESULT|RETURN|RETURNS|REVERT|REVOKE|ROLE|ROLLBACK|ROLLUP|ROUTINE|ROW|ROWCOUNT|ROWGUIDCOL|ROWS|RULE|SAVE|SAVEPOINT|SCHEMA|SCOPE|SCROLL|SEARCH|SECOND|SECTION|SECURITYAUDIT|SELECT|SEMANTICKEYPHRASETABLE|SEMANTICSIMILARITYDETAILSTABLE|SEMANTICSIMILARITYTABLE|SENSITIVE|SEQUENCE|SESSION|SET|SETS|SETUSER|SHUTDOWN|SIMILAR|SIZE|SOME|SPECIFIC|SPECIFICTYPE|SQL|SQLCA|SQLCODE|SQLERROR|SQLEXCEPTION|SQLSTATE|SQLWARNING|START|STATE|STATEMENT|STATIC|STATISTICS|STDDEV_POP|STDDEV_SAMP|STRUCTURE|SUBMULTISET|SUBSTRING_REGEX|SYMMETRIC|SYSTEM|TABLESAMPLE|TEMPORARY|TERMINATE|TEXTSIZE|THAN|THEN|TIMEZONE_HOUR|TIMEZONE_MINUTE|TO|TOP|TRAILING|TRAN|TRANSACTION|TRANSLATE|TRANSLATE_REGEX|TRANSLATION|TREAT|TRIGGER|TRIM|TRUNCATE|TSEQUAL|UESCAPE|UNDER|UNION|UNIQUE|UNKNOWN|UNNEST|UNPIVOT|UPDATE|UPDATETEXT|USAGE|USE|USER|USING|VALUE|VALUES|VARIABLE|VARYING|VAR_POP|VAR_SAMP|VIEW|WAITFOR|WHEN|WHENEVER|WHERE|WHILE|WIDTH_BUCKET|WINDOW|WITH|WITHIN|WITHIN GROUP|WITHOUT|WORK|WRITE|WRITETEXT|XMLAGG|XMLATTRIBUTES|XMLBINARY|XMLCAST|XMLCOMMENT|XMLCONCAT|XMLDOCUMENT|XMLELEMENT|XMLEXISTS|XMLFOREST|XMLITERATE|XMLNAMESPACES|XMLPARSE|XMLPI|XMLQUERY|XMLSERIALIZE|XMLTABLE|XMLTEXT|XMLVALIDATE|ZONE";
  67. keywords += "|KEEPIDENTITY|KEEPDEFAULTS|IGNORE_CONSTRAINTS|IGNORE_TRIGGERS|XLOCK|FORCESCAN|FORCESEEK|HOLDLOCK|NOLOCK|NOWAIT|PAGLOCK|READCOMMITTED|READCOMMITTEDLOCK|READPAST|READUNCOMMITTED|REPEATABLEREAD|ROWLOCK|SERIALIZABLE|SNAPSHOT|SPATIAL_WINDOW_MAX_CELLS|TABLOCK|TABLOCKX|UPDLOCK|XLOCK|IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX|EXPAND|VIEWS|FAST|FORCE|KEEP|KEEPFIXED|MAXDOP|MAXRECURSION|OPTIMIZE|PARAMETERIZATION|SIMPLE|FORCED|RECOMPILE|ROBUST|PLAN|SPATIAL_WINDOW_MAX_CELLS|NOEXPAND|HINT";
  68. keywords += "|LOOP|HASH|MERGE|REMOTE";
  69. keywords += "|TRY|CATCH|THROW";
  70. keywords += "|TYPE";
  71. keywords = keywords.split('|');
  72. keywords = keywords.filter(function (value, index, self) {
  73. return logicalOperators.split('|').indexOf(value) === -1 && builtinFunctions.split('|').indexOf(value) === -1 && dataTypes.split('|').indexOf(value) === -1;
  74. });
  75. keywords = keywords.sort().join('|');
  76. var keywordMapper = this.createKeywordMapper({
  77. "constant.language": logicalOperators,
  78. "storage.type": dataTypes,
  79. "support.function": builtinFunctions,
  80. "support.storedprocedure": builtInStoredProcedures,
  81. "keyword": keywords
  82. }, "identifier", true);
  83. var setStatements = "SET ANSI_DEFAULTS|SET ANSI_NULLS|SET ANSI_NULL_DFLT_OFF|SET ANSI_NULL_DFLT_ON|SET ANSI_PADDING|SET ANSI_WARNINGS|SET ARITHABORT|SET ARITHIGNORE|SET CONCAT_NULL_YIELDS_NULL|SET CURSOR_CLOSE_ON_COMMIT|SET DATEFIRST|SET DATEFORMAT|SET DEADLOCK_PRIORITY|SET FIPS_FLAGGER|SET FMTONLY|SET FORCEPLAN|SET IDENTITY_INSERT|SET IMPLICIT_TRANSACTIONS|SET LANGUAGE|SET LOCK_TIMEOUT|SET NOCOUNT|SET NOEXEC|SET NUMERIC_ROUNDABORT|SET OFFSETS|SET PARSEONLY|SET QUERY_GOVERNOR_COST_LIMIT|SET QUOTED_IDENTIFIER|SET REMOTE_PROC_TRANSACTIONS|SET ROWCOUNT|SET SHOWPLAN_ALL|SET SHOWPLAN_TEXT|SET SHOWPLAN_XML|SET STATISTICS IO|SET STATISTICS PROFILE|SET STATISTICS TIME|SET STATISTICS XML|SET TEXTSIZE|SET XACT_ABORT".split('|');
  84. var isolationLevels = "READ UNCOMMITTED|READ COMMITTED|REPEATABLE READ|SNAPSHOP|SERIALIZABLE".split('|');
  85. for (var i = 0; i < isolationLevels.length; i++) {
  86. setStatements.push('SET TRANSACTION ISOLATION LEVEL ' + isolationLevels[i]);
  87. }
  88. this.$rules = {
  89. start: [{
  90. token: "string.start",
  91. regex: "'",
  92. next: [{
  93. token: "constant.language.escape",
  94. regex: /''/
  95. }, {
  96. token: "string.end",
  97. next: "start",
  98. regex: "'"
  99. }, {
  100. defaultToken: "string"
  101. }]
  102. },
  103. DocCommentHighlightRules.getStartRule("doc-start"), {
  104. token: "comment",
  105. regex: "--.*$"
  106. }, {
  107. token: "comment",
  108. start: "/\\*",
  109. end: "\\*/"
  110. }, {
  111. token: "constant.numeric",
  112. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  113. }, {
  114. token: keywordMapper,
  115. regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b(?!])" //up to 2 @symbols for some built in functions
  116. }, {
  117. token: "constant.class",
  118. regex: "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  119. }, {
  120. token: "keyword.operator",
  121. regex: "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=|\\*"
  122. }, {
  123. token: "paren.lparen",
  124. regex: "[\\(]"
  125. }, {
  126. token: "paren.rparen",
  127. regex: "[\\)]"
  128. }, {
  129. token: "punctuation",
  130. regex: ",|;"
  131. }, {
  132. token: "text",
  133. regex: "\\s+"
  134. }],
  135. comment: [
  136. DocCommentHighlightRules.getTagRule(), {
  137. token: "comment",
  138. regex: "\\*\\/",
  139. next: "no_regex"
  140. }, {
  141. defaultToken: "comment",
  142. caseInsensitive: true
  143. }
  144. ]
  145. };
  146. for (var i = 0; i < setStatements.length; i++) {
  147. this.$rules.start.unshift({
  148. token: "set.statement",
  149. regex: setStatements[i]
  150. });
  151. }
  152. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  153. this.normalizeRules();
  154. var completions = [];
  155. var addCompletions = function (arr, meta) {
  156. arr.forEach(function (v) {
  157. completions.push({
  158. name: v,
  159. value: v,
  160. score: 0,
  161. meta: meta
  162. });
  163. });
  164. };
  165. addCompletions(builtInStoredProcedures.split('|'), 'procedure');
  166. addCompletions(logicalOperators.split('|'), 'operator');
  167. addCompletions(builtinFunctions.split('|'), 'function');
  168. addCompletions(dataTypes.split('|'), 'type');
  169. addCompletions(setStatements, 'statement');
  170. addCompletions(keywords.split('|'), 'keyword');
  171. this.completions = completions;
  172. };
  173. oop.inherits(SqlServerHighlightRules, TextHighlightRules);
  174. exports.SqlHighlightRules = SqlServerHighlightRules;
  175. });
  176. 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";
  177. var oop = require("../../lib/oop");
  178. var Range = require("../../range").Range;
  179. var BaseFoldMode = require("./fold_mode").FoldMode;
  180. var FoldMode = exports.FoldMode = function (commentRegex) {
  181. if (commentRegex) {
  182. this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start));
  183. this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end));
  184. }
  185. };
  186. oop.inherits(FoldMode, BaseFoldMode);
  187. (function () {
  188. this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/;
  189. this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/;
  190. this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/;
  191. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  192. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  193. this._getFoldWidgetBase = this.getFoldWidget;
  194. this.getFoldWidget = function (session, foldStyle, row) {
  195. var line = session.getLine(row);
  196. if (this.singleLineBlockCommentRe.test(line)) {
  197. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  198. return "";
  199. }
  200. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  201. if (!fw && this.startRegionRe.test(line))
  202. return "start"; // lineCommentRegionStart
  203. return fw;
  204. };
  205. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  206. var line = session.getLine(row);
  207. if (this.startRegionRe.test(line))
  208. return this.getCommentRegionBlock(session, line, row);
  209. var match = line.match(this.foldingStartMarker);
  210. if (match) {
  211. var i = match.index;
  212. if (match[1])
  213. return this.openingBracketBlock(session, match[1], row, i);
  214. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  215. if (range && !range.isMultiLine()) {
  216. if (forceMultiline) {
  217. range = this.getSectionRange(session, row);
  218. }
  219. else if (foldStyle != "all")
  220. range = null;
  221. }
  222. return range;
  223. }
  224. if (foldStyle === "markbegin")
  225. return;
  226. var match = line.match(this.foldingStopMarker);
  227. if (match) {
  228. var i = match.index + match[0].length;
  229. if (match[1])
  230. return this.closingBracketBlock(session, match[1], row, i);
  231. return session.getCommentFoldRange(row, i, -1);
  232. }
  233. };
  234. this.getSectionRange = function (session, row) {
  235. var line = session.getLine(row);
  236. var startIndent = line.search(/\S/);
  237. var startRow = row;
  238. var startColumn = line.length;
  239. row = row + 1;
  240. var endRow = row;
  241. var maxRow = session.getLength();
  242. while (++row < maxRow) {
  243. line = session.getLine(row);
  244. var indent = line.search(/\S/);
  245. if (indent === -1)
  246. continue;
  247. if (startIndent > indent)
  248. break;
  249. var subRange = this.getFoldWidgetRange(session, "all", row);
  250. if (subRange) {
  251. if (subRange.start.row <= startRow) {
  252. break;
  253. }
  254. else if (subRange.isMultiLine()) {
  255. row = subRange.end.row;
  256. }
  257. else if (startIndent == indent) {
  258. break;
  259. }
  260. }
  261. endRow = row;
  262. }
  263. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  264. };
  265. this.getCommentRegionBlock = function (session, line, row) {
  266. var startColumn = line.search(/\s*$/);
  267. var maxRow = session.getLength();
  268. var startRow = row;
  269. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  270. var depth = 1;
  271. while (++row < maxRow) {
  272. line = session.getLine(row);
  273. var m = re.exec(line);
  274. if (!m)
  275. continue;
  276. if (m[1])
  277. depth--;
  278. else
  279. depth++;
  280. if (!depth)
  281. break;
  282. }
  283. var endRow = row;
  284. if (endRow > startRow) {
  285. return new Range(startRow, startColumn, endRow, line.length);
  286. }
  287. };
  288. }).call(FoldMode.prototype);
  289. });
  290. ace.define("ace/mode/folding/sqlserver",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/cstyle"], function(require, exports, module){"use strict";
  291. var oop = require("../../lib/oop");
  292. var Range = require("../../range").Range;
  293. var BaseFoldMode = require("./cstyle").FoldMode;
  294. var FoldMode = exports.FoldMode = function () { };
  295. oop.inherits(FoldMode, BaseFoldMode);
  296. (function () {
  297. this.foldingStartMarker = /(\bCASE\b|\bBEGIN\b)|^\s*(\/\*)/i;
  298. this.startRegionRe = /^\s*(\/\*|--)#?region\b/;
  299. this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) {
  300. var line = session.getLine(row);
  301. if (this.startRegionRe.test(line))
  302. return this.getCommentRegionBlock(session, line, row);
  303. var match = line.match(this.foldingStartMarker);
  304. if (match) {
  305. var i = match.index;
  306. if (match[1])
  307. return this.getBeginEndBlock(session, row, i, match[1]);
  308. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  309. if (range && !range.isMultiLine()) {
  310. if (forceMultiline) {
  311. range = this.getSectionRange(session, row);
  312. }
  313. else if (foldStyle != "all")
  314. range = null;
  315. }
  316. return range;
  317. }
  318. if (foldStyle === "markbegin")
  319. return;
  320. return;
  321. };
  322. this.getBeginEndBlock = function (session, row, column, matchSequence) {
  323. var start = {
  324. row: row,
  325. column: column + matchSequence.length
  326. };
  327. var maxRow = session.getLength();
  328. var line;
  329. var depth = 1;
  330. var re = /(\bCASE\b|\bBEGIN\b)|(\bEND\b)/i;
  331. while (++row < maxRow) {
  332. line = session.getLine(row);
  333. var m = re.exec(line);
  334. if (!m)
  335. continue;
  336. if (m[1])
  337. depth++;
  338. else
  339. depth--;
  340. if (!depth)
  341. break;
  342. }
  343. var endRow = row;
  344. if (endRow > start.row) {
  345. return new Range(start.row, start.column, endRow, line.length);
  346. }
  347. };
  348. }).call(FoldMode.prototype);
  349. });
  350. ace.define("ace/mode/sqlserver",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/sqlserver_highlight_rules","ace/mode/folding/sqlserver"], function(require, exports, module){"use strict";
  351. var oop = require("../lib/oop");
  352. var TextMode = require("./text").Mode;
  353. var SqlServerHighlightRules = require("./sqlserver_highlight_rules").SqlHighlightRules;
  354. var SqlServerFoldMode = require("./folding/sqlserver").FoldMode;
  355. var Mode = function () {
  356. this.HighlightRules = SqlServerHighlightRules;
  357. this.foldingRules = new SqlServerFoldMode();
  358. this.$behaviour = this.$defaultBehaviour;
  359. };
  360. oop.inherits(Mode, TextMode);
  361. (function () {
  362. this.lineCommentStart = "--";
  363. this.blockComment = { start: "/*", end: "*/" };
  364. this.getCompletions = function (state, session, pos, prefix) {
  365. return session.$mode.$highlightRules.completions;
  366. };
  367. this.$id = "ace/mode/sqlserver";
  368. this.snippetFileId = "ace/snippets/sqlserver";
  369. }).call(Mode.prototype);
  370. exports.Mode = Mode;
  371. }); (function() {
  372. ace.require(["ace/mode/sqlserver"], function(m) {
  373. if (typeof module == "object" && typeof exports == "object" && module) {
  374. module.exports = m;
  375. }
  376. });
  377. })();