(function(a){if(typeof exports=="object"&&typeof module=="object"){a(require("../../lib/codemirror"),require("../../mode/sql/sql"))}else{if(typeof define=="function"&&define.amd){define(["../../lib/codemirror","../../mode/sql/sql"],a)}else{a(CodeMirror)}}})(function(p){var h;var s;var i;var j={QUERY_DIV:";",ALIAS_KEYWORD:"AS"};var n=p.Pos,o=p.cmpPos;function l(v){return Object.prototype.toString.call(v)=="[object Array]"}function d(v){var w=v.doc.modeOption;if(w==="sql"){w="text/x-sql"}return p.resolveMode(w).keywords}function a(v){return typeof v=="string"?v:v.text}function b(v,w){if(l(w)){w={columns:w}}if(!w.text){w.text=v}return w}function q(w){var v={};if(l(w)){for(var y=w.length-1;y>=0;y--){var z=w[y];v[a(z).toUpperCase()]=b(a(z),z)}}else{if(w){for(var x in w){v[x.toUpperCase()]=b(x,w[x])}}}return v}function c(v){return h[v.toUpperCase()]}function g(w){var v={};for(var x in w){if(w.hasOwnProperty(x)){v[x]=w[x]}}return v}function e(w,y){var v=w.length;var x=a(y).substr(0,v);return w.toUpperCase()===x.toUpperCase()}function f(v,y,z,x){if(l(z)){for(var w=0;w0)&&o(D,z[x])<=0){H={start:G,end:z[x]};break}G=z[x]}var E=I.getRange(H.start,H.end,false);for(var x=0;xB.ch){x.end=B.ch;x.string=x.string.slice(0,B.ch-x.start)}if(x.string.match(/^[.`\w@]\w*$/)){C=x.string;v=x.start;y=x.end}else{v=y=B.ch;C=""}if(C.charAt(0)=="."||C.charAt(0)=="`"){v=t(B,x,E,z)}else{f(E,C,h,function(F){return F});f(E,C,s,function(F){return F});if(!A){f(E,C,i,function(F){return F.toUpperCase()})}}return{list:E,from:n(B.line,v),to:n(B.line,y)}})});