mode-sqlserver.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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/sqlserver_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/doc_comment_highlight_rules","ace/mode/text_highlight_rules"], function(require, exports, module) {
  42. "use strict";
  43. var oop = require("../lib/oop");
  44. var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
  45. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  46. var SqlServerHighlightRules = function() {
  47. var logicalOperators = "ALL|AND|ANY|BETWEEN|EXISTS|IN|LIKE|NOT|OR|SOME";
  48. logicalOperators += "|NULL|IS|APPLY|INNER|OUTER|LEFT|RIGHT|JOIN|CROSS"; //SSMS colors these gray too
  49. var builtinFunctions = (
  50. "OPENDATASOURCE|OPENQUERY|OPENROWSET|OPENXML|" +
  51. "AVG|CHECKSUM_AGG|COUNT|COUNT_BIG|GROUPING|GROUPING_ID|MAX|MIN|STDEV|STDEVP|SUM|VAR|VARP|" +
  52. "DENSE_RANK|NTILE|RANK|ROW_NUMBER" +
  53. "@@DATEFIRST|@@DBTS|@@LANGID|@@LANGUAGE|@@LOCK_TIMEOUT|@@MAX_CONNECTIONS|@@MAX_PRECISION|@@NESTLEVEL|@@OPTIONS|@@REMSERVER|@@SERVERNAME|@@SERVICENAME|@@SPID|@@TEXTSIZE|@@VERSION|" +
  54. "CAST|CONVERT|PARSE|TRY_CAST|TRY_CONVERT|TRY_PARSE" +
  55. "@@CURSOR_ROWS|@@FETCH_STATUS|CURSOR_STATUS|" +
  56. "@@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|" +
  57. "CHOOSE|IIF|" +
  58. "ABS|ACOS|ASIN|ATAN|ATN2|CEILING|COS|COT|DEGREES|EXP|FLOOR|LOG|LOG10|PI|POWER|RADIANS|RAND|ROUND|SIGN|SIN|SQRT|SQUARE|TAN|" +
  59. "@@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|" +
  60. "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|" +
  61. "ASCII|CHAR|CHARINDEX|CONCAT|DIFFERENCE|FORMAT|LEN|LOWER|LTRIM|NCHAR|PATINDEX|QUOTENAME|REPLACE|REPLICATE|REVERSE|RTRIM|SOUNDEX|SPACE|STR|STUFF|SUBSTRING|UNICODE|UPPER|" +
  62. "$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|" +
  63. "@@CONNECTIONS|@@CPU_BUSY|@@IDLE|@@IO_BUSY|@@PACKET_ERRORS|@@PACK_RECEIVED|@@PACK_SENT|@@TIMETICKS|@@TOTAL_ERRORS|@@TOTAL_READ|@@TOTAL_WRITE|FN_VIRTUALFILESTATS|" +
  64. "PATINDEX|TEXTPTR|TEXTVALID|" +
  65. "COALESCE|NULLIF"
  66. );
  67. 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");
  68. 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";
  69. 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";
  70. 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";
  71. keywords += "|LOOP|HASH|MERGE|REMOTE";
  72. keywords += "|TRY|CATCH|THROW";
  73. keywords += "|TYPE";
  74. keywords = keywords.split('|');
  75. keywords = keywords.filter(function(value, index, self) {
  76. return logicalOperators.split('|').indexOf(value) === -1 && builtinFunctions.split('|').indexOf(value) === -1 && dataTypes.split('|').indexOf(value) === -1;
  77. });
  78. keywords = keywords.sort().join('|');
  79. var keywordMapper = this.createKeywordMapper({
  80. "constant.language": logicalOperators,
  81. "storage.type": dataTypes,
  82. "support.function": builtinFunctions,
  83. "support.storedprocedure": builtInStoredProcedures,
  84. "keyword": keywords
  85. }, "identifier", true);
  86. 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('|');
  87. var isolationLevels = "READ UNCOMMITTED|READ COMMITTED|REPEATABLE READ|SNAPSHOP|SERIALIZABLE".split('|');
  88. for (var i = 0; i < isolationLevels.length; i++) {
  89. setStatements.push('SET TRANSACTION ISOLATION LEVEL ' + isolationLevels[i]);
  90. }
  91. this.$rules = {
  92. start: [{
  93. token: "string.start",
  94. regex: "'",
  95. next: [{
  96. token: "constant.language.escape",
  97. regex: /''/
  98. }, {
  99. token: "string.end",
  100. next: "start",
  101. regex: "'"
  102. }, {
  103. defaultToken: "string"
  104. }]
  105. },
  106. DocCommentHighlightRules.getStartRule("doc-start"), {
  107. token: "comment",
  108. regex: "--.*$"
  109. }, {
  110. token: "comment",
  111. start: "/\\*",
  112. end: "\\*/"
  113. }, {
  114. token: "constant.numeric", // float
  115. regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
  116. }, {
  117. token: keywordMapper,
  118. regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b(?!])" //up to 2 @symbols for some built in functions
  119. }, {
  120. token: "constant.class",
  121. regex: "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
  122. }, {
  123. token: "keyword.operator",
  124. regex: "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=|\\*"
  125. }, {
  126. token: "paren.lparen",
  127. regex: "[\\(]"
  128. }, {
  129. token: "paren.rparen",
  130. regex: "[\\)]"
  131. }, {
  132. token: "punctuation",
  133. regex: ",|;"
  134. }, {
  135. token: "text",
  136. regex: "\\s+"
  137. }],
  138. comment: [
  139. DocCommentHighlightRules.getTagRule(), {
  140. token: "comment",
  141. regex: "\\*\\/",
  142. next: "no_regex"
  143. }, {
  144. defaultToken: "comment",
  145. caseInsensitive: true
  146. }]
  147. };
  148. for (var i = 0; i < setStatements.length; i++) {
  149. this.$rules.start.unshift({
  150. token: "set.statement",
  151. regex: setStatements[i]
  152. });
  153. }
  154. this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
  155. this.normalizeRules();
  156. var completions = [];
  157. var addCompletions = function(arr, meta) {
  158. arr.forEach(function(v) {
  159. completions.push({
  160. name: v,
  161. value: v,
  162. score: 0,
  163. meta: meta
  164. });
  165. });
  166. };
  167. addCompletions(builtInStoredProcedures.split('|'), 'procedure');
  168. addCompletions(logicalOperators.split('|'), 'operator');
  169. addCompletions(builtinFunctions.split('|'), 'function');
  170. addCompletions(dataTypes.split('|'), 'type');
  171. addCompletions(setStatements, 'statement');
  172. addCompletions(keywords.split('|'), 'keyword');
  173. this.completions = completions;
  174. };
  175. oop.inherits(SqlServerHighlightRules, TextHighlightRules);
  176. exports.SqlHighlightRules = SqlServerHighlightRules;
  177. });
  178. ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"], function(require, exports, module) {
  179. "use strict";
  180. var oop = require("../../lib/oop");
  181. var Range = require("../../range").Range;
  182. var BaseFoldMode = require("./fold_mode").FoldMode;
  183. var FoldMode = exports.FoldMode = function(commentRegex) {
  184. if (commentRegex) {
  185. this.foldingStartMarker = new RegExp(
  186. this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
  187. );
  188. this.foldingStopMarker = new RegExp(
  189. this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
  190. );
  191. }
  192. };
  193. oop.inherits(FoldMode, BaseFoldMode);
  194. (function() {
  195. this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
  196. this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
  197. this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
  198. this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
  199. this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/;
  200. this._getFoldWidgetBase = this.getFoldWidget;
  201. this.getFoldWidget = function(session, foldStyle, row) {
  202. var line = session.getLine(row);
  203. if (this.singleLineBlockCommentRe.test(line)) {
  204. if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
  205. return "";
  206. }
  207. var fw = this._getFoldWidgetBase(session, foldStyle, row);
  208. if (!fw && this.startRegionRe.test(line))
  209. return "start"; // lineCommentRegionStart
  210. return fw;
  211. };
  212. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  213. var line = session.getLine(row);
  214. if (this.startRegionRe.test(line))
  215. return this.getCommentRegionBlock(session, line, row);
  216. var match = line.match(this.foldingStartMarker);
  217. if (match) {
  218. var i = match.index;
  219. if (match[1])
  220. return this.openingBracketBlock(session, match[1], row, i);
  221. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  222. if (range && !range.isMultiLine()) {
  223. if (forceMultiline) {
  224. range = this.getSectionRange(session, row);
  225. } else if (foldStyle != "all")
  226. range = null;
  227. }
  228. return range;
  229. }
  230. if (foldStyle === "markbegin")
  231. return;
  232. var match = line.match(this.foldingStopMarker);
  233. if (match) {
  234. var i = match.index + match[0].length;
  235. if (match[1])
  236. return this.closingBracketBlock(session, match[1], row, i);
  237. return session.getCommentFoldRange(row, i, -1);
  238. }
  239. };
  240. this.getSectionRange = function(session, row) {
  241. var line = session.getLine(row);
  242. var startIndent = line.search(/\S/);
  243. var startRow = row;
  244. var startColumn = line.length;
  245. row = row + 1;
  246. var endRow = row;
  247. var maxRow = session.getLength();
  248. while (++row < maxRow) {
  249. line = session.getLine(row);
  250. var indent = line.search(/\S/);
  251. if (indent === -1)
  252. continue;
  253. if (startIndent > indent)
  254. break;
  255. var subRange = this.getFoldWidgetRange(session, "all", row);
  256. if (subRange) {
  257. if (subRange.start.row <= startRow) {
  258. break;
  259. } else if (subRange.isMultiLine()) {
  260. row = subRange.end.row;
  261. } else if (startIndent == indent) {
  262. break;
  263. }
  264. }
  265. endRow = row;
  266. }
  267. return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
  268. };
  269. this.getCommentRegionBlock = function(session, line, row) {
  270. var startColumn = line.search(/\s*$/);
  271. var maxRow = session.getLength();
  272. var startRow = row;
  273. var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/;
  274. var depth = 1;
  275. while (++row < maxRow) {
  276. line = session.getLine(row);
  277. var m = re.exec(line);
  278. if (!m) continue;
  279. if (m[1]) depth--;
  280. else depth++;
  281. if (!depth) 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) {
  291. "use strict";
  292. var oop = require("../../lib/oop");
  293. var Range = require("../../range").Range;
  294. var BaseFoldMode = require("./cstyle").FoldMode;
  295. var FoldMode = exports.FoldMode = function() {};
  296. oop.inherits(FoldMode, BaseFoldMode);
  297. (function() {
  298. this.foldingStartMarker = /(\bCASE\b|\bBEGIN\b)|^\s*(\/\*)/i;
  299. this.startRegionRe = /^\s*(\/\*|--)#?region\b/;
  300. this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
  301. var line = session.getLine(row);
  302. if (this.startRegionRe.test(line)) 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]) return this.getBeginEndBlock(session, row, i, match[1]);
  307. var range = session.getCommentFoldRange(row, i + match[0].length, 1);
  308. if (range && !range.isMultiLine()) {
  309. if (forceMultiline) {
  310. range = this.getSectionRange(session, row);
  311. }
  312. else if (foldStyle != "all") range = null;
  313. }
  314. return range;
  315. }
  316. if (foldStyle === "markbegin") return;
  317. return;
  318. };
  319. this.getBeginEndBlock = function(session, row, column, matchSequence) {
  320. var start = {
  321. row: row,
  322. column: column + matchSequence.length
  323. };
  324. var maxRow = session.getLength();
  325. var line;
  326. var depth = 1;
  327. var re = /(\bCASE\b|\bBEGIN\b)|(\bEND\b)/i;
  328. while (++row < maxRow) {
  329. line = session.getLine(row);
  330. var m = re.exec(line);
  331. if (!m) continue;
  332. if (m[1]) depth++;
  333. else depth--;
  334. if (!depth) break;
  335. }
  336. var endRow = row;
  337. if (endRow > start.row) {
  338. return new Range(start.row, start.column, endRow, line.length);
  339. }
  340. };
  341. }).call(FoldMode.prototype);
  342. });
  343. 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) {
  344. "use strict";
  345. var oop = require("../lib/oop");
  346. var TextMode = require("./text").Mode;
  347. var SqlServerHighlightRules = require("./sqlserver_highlight_rules").SqlHighlightRules;
  348. var SqlServerFoldMode = require("./folding/sqlserver").FoldMode;
  349. var Mode = function() {
  350. this.HighlightRules = SqlServerHighlightRules;
  351. this.foldingRules = new SqlServerFoldMode();
  352. this.$behaviour = this.$defaultBehaviour;
  353. };
  354. oop.inherits(Mode, TextMode);
  355. (function() {
  356. this.lineCommentStart = "--";
  357. this.blockComment = {start: "/*", end: "*/"};
  358. this.getCompletions = function(state, session, pos, prefix) {
  359. return session.$mode.$highlightRules.completions;
  360. };
  361. this.$id = "ace/mode/sql";
  362. }).call(Mode.prototype);
  363. exports.Mode = Mode;
  364. });