| 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|is|in|" + |
| 8 |
"all|alter|any|array|at|authorization|between|both|cast|check|collate|column|commit|constraint|" + |
| 9 |
"cube|current|current_date|current_time|current_timestamp|current_user|describe|escape|except|" + |
| 10 |
"exists|external|extract|fetch|filter|for|full|function|global|grouping|intersect|interval|" + |
| 11 |
"into|leading|like|local|no|of|only|out|overlaps|partition|position|range|revoke|rollback|rollup|" + |
| 12 |
"row|rows|session_user|set|some|start|tablesample|time|to|trailing|truncate|unique|unknown|" + |
| 13 |
"user|using|values|window|with"); |
| 14 |
var builtinConstants = ("true|false"); |
| 15 |
var builtinFunctions = ("avg|count|first|last|max|min|sum|ucase|lcase|mid|len|round|rank|now|format|" + |
| 16 |
"coalesce|ifnull|isnull|nvl"); |
| 17 |
var dataTypes = ("int|numeric|decimal|date|varchar|char|bigint|float|double|bit|binary|text|set|timestamp|" + |
| 18 |
"money|real|number|integer|string"); |
| 19 |
var keywordMapper = this.createKeywordMapper({ |
| 20 |
"support.function": builtinFunctions, |
| 21 |
"keyword": keywords, |
| 22 |
"constant.language": builtinConstants, |
| 23 |
"storage.type": dataTypes |
| 24 |
}, "identifier", true); |
| 25 |
this.$rules = { |
| 26 |
"start": [{ |
| 27 |
token: "comment", |
| 28 |
regex: "--.*$" |
| 29 |
}, { |
| 30 |
token: "comment", |
| 31 |
start: "/\\*", |
| 32 |
end: "\\*/" |
| 33 |
}, { |
| 34 |
token: "string", |
| 35 |
regex: '".*?"' |
| 36 |
}, { |
| 37 |
token: "string", |
| 38 |
regex: "'.*?'" |
| 39 |
}, { |
| 40 |
token: "string", |
| 41 |
regex: "`.*?`" |
| 42 |
}, { |
| 43 |
token: "constant.numeric", |
| 44 |
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" |
| 45 |
}, { |
| 46 |
token: keywordMapper, |
| 47 |
regex: "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" |
| 48 |
}, { |
| 49 |
token: "keyword.operator", |
| 50 |
regex: "\\+|\\-|\\/|\\/\\/|%|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" |
| 51 |
}, { |
| 52 |
token: "paren.lparen", |
| 53 |
regex: "[\\(]" |
| 54 |
}, { |
| 55 |
token: "paren.rparen", |
| 56 |
regex: "[\\)]" |
| 57 |
}, { |
| 58 |
token: "text", |
| 59 |
regex: "\\s+" |
| 60 |
}] |
| 61 |
}; |
| 62 |
this.normalizeRules(); |
| 63 |
}; |
| 64 |
oop.inherits(SqlHighlightRules, TextHighlightRules); |
| 65 |
exports.SqlHighlightRules = SqlHighlightRules; |
| 66 |
|
| 67 |
}); |
| 68 |
|
| 69 |
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"; |
| 70 |
var oop = require("../../lib/oop"); |
| 71 |
var Range = require("../../range").Range; |
| 72 |
var BaseFoldMode = require("./fold_mode").FoldMode; |
| 73 |
var FoldMode = exports.FoldMode = function (commentRegex) { |
| 74 |
if (commentRegex) { |
| 75 |
this.foldingStartMarker = new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)); |
| 76 |
this.foldingStopMarker = new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)); |
| 77 |
} |
| 78 |
}; |
| 79 |
oop.inherits(FoldMode, BaseFoldMode); |
| 80 |
(function () { |
| 81 |
this.foldingStartMarker = /([\{\[\(])[^\}\]\)]*$|^\s*(\/\*)/; |
| 82 |
this.foldingStopMarker = /^[^\[\{\(]*([\}\]\)])|^[\s\*]*(\*\/)/; |
| 83 |
this.singleLineBlockCommentRe = /^\s*(\/\*).*\*\/\s*$/; |
| 84 |
this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/; |
| 85 |
this.startRegionRe = /^\s*(\/\*|\/\/)#?region\b/; |
| 86 |
this._getFoldWidgetBase = this.getFoldWidget; |
| 87 |
this.getFoldWidget = function (session, foldStyle, row) { |
| 88 |
var line = session.getLine(row); |
| 89 |
if (this.singleLineBlockCommentRe.test(line)) { |
| 90 |
if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line)) |
| 91 |
return ""; |
| 92 |
} |
| 93 |
var fw = this._getFoldWidgetBase(session, foldStyle, row); |
| 94 |
if (!fw && this.startRegionRe.test(line)) |
| 95 |
return "start"; |
| 96 |
return fw; |
| 97 |
}; |
| 98 |
this.getFoldWidgetRange = function (session, foldStyle, row, forceMultiline) { |
| 99 |
var line = session.getLine(row); |
| 100 |
if (this.startRegionRe.test(line)) |
| 101 |
return this.getCommentRegionBlock(session, line, row); |
| 102 |
var match = line.match(this.foldingStartMarker); |
| 103 |
if (match) { |
| 104 |
var i = match.index; |
| 105 |
if (match[1]) |
| 106 |
return this.openingBracketBlock(session, match[1], row, i); |
| 107 |
var range = session.getCommentFoldRange(row, i + match[0].length, 1); |
| 108 |
if (range && !range.isMultiLine()) { |
| 109 |
if (forceMultiline) { |
| 110 |
range = this.getSectionRange(session, row); |
| 111 |
} |
| 112 |
else if (foldStyle != "all") |
| 113 |
range = null; |
| 114 |
} |
| 115 |
return range; |
| 116 |
} |
| 117 |
if (foldStyle === "markbegin") |
| 118 |
return; |
| 119 |
var match = line.match(this.foldingStopMarker); |
| 120 |
if (match) { |
| 121 |
var i = match.index + match[0].length; |
| 122 |
if (match[1]) |
| 123 |
return this.closingBracketBlock(session, match[1], row, i); |
| 124 |
return session.getCommentFoldRange(row, i, -1); |
| 125 |
} |
| 126 |
}; |
| 127 |
this.getSectionRange = function (session, row) { |
| 128 |
var line = session.getLine(row); |
| 129 |
var startIndent = line.search(/\S/); |
| 130 |
var startRow = row; |
| 131 |
var startColumn = line.length; |
| 132 |
row = row + 1; |
| 133 |
var endRow = row; |
| 134 |
var maxRow = session.getLength(); |
| 135 |
while (++row < maxRow) { |
| 136 |
line = session.getLine(row); |
| 137 |
var indent = line.search(/\S/); |
| 138 |
if (indent === -1) |
| 139 |
continue; |
| 140 |
if (startIndent > indent) |
| 141 |
break; |
| 142 |
var subRange = this.getFoldWidgetRange(session, "all", row); |
| 143 |
if (subRange) { |
| 144 |
if (subRange.start.row <= startRow) { |
| 145 |
break; |
| 146 |
} |
| 147 |
else if (subRange.isMultiLine()) { |
| 148 |
row = subRange.end.row; |
| 149 |
} |
| 150 |
else if (startIndent == indent) { |
| 151 |
break; |
| 152 |
} |
| 153 |
} |
| 154 |
endRow = row; |
| 155 |
} |
| 156 |
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length); |
| 157 |
}; |
| 158 |
this.getCommentRegionBlock = function (session, line, row) { |
| 159 |
var startColumn = line.search(/\s*$/); |
| 160 |
var maxRow = session.getLength(); |
| 161 |
var startRow = row; |
| 162 |
var re = /^\s*(?:\/\*|\/\/|--)#?(end)?region\b/; |
| 163 |
var depth = 1; |
| 164 |
while (++row < maxRow) { |
| 165 |
line = session.getLine(row); |
| 166 |
var m = re.exec(line); |
| 167 |
if (!m) |
| 168 |
continue; |
| 169 |
if (m[1]) |
| 170 |
depth--; |
| 171 |
else |
| 172 |
depth++; |
| 173 |
if (!depth) |
| 174 |
break; |
| 175 |
} |
| 176 |
var endRow = row; |
| 177 |
if (endRow > startRow) { |
| 178 |
return new Range(startRow, startColumn, endRow, line.length); |
| 179 |
} |
| 180 |
}; |
| 181 |
}).call(FoldMode.prototype); |
| 182 |
|
| 183 |
}); |
| 184 |
|
| 185 |
ace.define("ace/mode/folding/sql",["require","exports","module","ace/lib/oop","ace/mode/folding/cstyle"], function(require, exports, module){"use strict"; |
| 186 |
var oop = require("../../lib/oop"); |
| 187 |
var BaseFoldMode = require("./cstyle").FoldMode; |
| 188 |
var FoldMode = exports.FoldMode = function () { }; |
| 189 |
oop.inherits(FoldMode, BaseFoldMode); |
| 190 |
(function () { |
| 191 |
}).call(FoldMode.prototype); |
| 192 |
|
| 193 |
}); |
| 194 |
|
| 195 |
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"; |
| 196 |
var oop = require("../lib/oop"); |
| 197 |
var TextMode = require("./text").Mode; |
| 198 |
var SqlHighlightRules = require("./sql_highlight_rules").SqlHighlightRules; |
| 199 |
var SqlFoldMode = require("./folding/sql").FoldMode; |
| 200 |
var Mode = function () { |
| 201 |
this.HighlightRules = SqlHighlightRules; |
| 202 |
this.foldingRules = new SqlFoldMode(); |
| 203 |
this.$behaviour = this.$defaultBehaviour; |
| 204 |
}; |
| 205 |
oop.inherits(Mode, TextMode); |
| 206 |
(function () { |
| 207 |
this.lineCommentStart = "--"; |
| 208 |
this.blockComment = { start: "/*", end: "*/" }; |
| 209 |
this.$id = "ace/mode/sql"; |
| 210 |
this.snippetFileId = "ace/snippets/sql"; |
| 211 |
}).call(Mode.prototype); |
| 212 |
exports.Mode = Mode; |
| 213 |
|
| 214 |
}); (function() { |
| 215 |
ace.require(["ace/mode/sql"], function(m) { |
| 216 |
if (typeof module == "object" && typeof exports == "object" && module) { |
| 217 |
module.exports = m; |
| 218 |
} |
| 219 |
}); |
| 220 |
})(); |
| 221 |
|