progress but not working yet

This commit is contained in:
Morgan Yarbrough 2015-04-17 11:17:31 -04:00
commit 7ae5c862c2

View file

@ -81,7 +81,7 @@ var SqlServerHighlightRules = function() {
/* https://msdn.microsoft.com/en-us/library/ms177520.aspx */ /* https://msdn.microsoft.com/en-us/library/ms177520.aspx */
"@@CONNECTIONS|@@CPU_BUSY|@@IDLE|@@IO_BUSY|@@PACKET_ERRORS|@@PACK_RECEIVED|@@PACK_SENT|@@TIMETICKS|@@TOTAL_ERRORS|@@TOTAL_READ|@@TOTAL_WRITE|FN_VIRTUALFILESTATS|" + "@@CONNECTIONS|@@CPU_BUSY|@@IDLE|@@IO_BUSY|@@PACKET_ERRORS|@@PACK_RECEIVED|@@PACK_SENT|@@TIMETICKS|@@TOTAL_ERRORS|@@TOTAL_READ|@@TOTAL_WRITE|FN_VIRTUALFILESTATS|" +
/* https://msdn.microsoft.com/en-us/library/ms188353.aspx */ /* https://msdn.microsoft.com/en-us/library/ms188353.aspx */
"PATINDEX|TEXTPTR|TEXTVALID|" "PATINDEX|TEXTPTR|TEXTVALID"
); );
@ -106,12 +106,12 @@ var SqlServerHighlightRules = function() {
//add each part of set statement to keywords for highlighting, yet keep set statements as is for code completion //add each part of set statement to keywords for highlighting, yet keep set statements as is for code completion
//NOTE: there is likely a better way to do this but I don't fully understand the syntax highlighting part yet //NOTE: there is likely a better way to do this but I don't fully understand the syntax highlighting part yet
var eachSet = setStatements.split('|'); /*var eachSet = setStatements.split('|');
eachSet.forEach(function(v) { eachSet.forEach(function(v) {
v.split(' ').forEach(function(v) { v.split(' ').forEach(function(v) {
keywords += '|' + v; keywords += '|' + v;
}); });
}); });*/
//remove any other built in things from key word list //remove any other built in things from key word list
@ -124,11 +124,22 @@ var SqlServerHighlightRules = function() {
var keywordMapper = this.createKeywordMapper({ var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions, "support.function": builtinFunctions,
"keyword": keywords, "keyword": keywords,
"keyword.set": setStatements,
"constant.language": logicalOperators, "constant.language": logicalOperators,
"storage.type": dataTypes "storage.type": dataTypes
}, "identifier", true); }, "identifier", true);
//store keywordList created by createKeywordMapper so we can merge it with second call
var keywordList = this.$keywordList;
var statementMapper = this.createKeywordMapper({
"keyword.set": setStatements,
}, "identifier", true);
//merge first keyword list back in
for (var i = 0; i < keywordList.length; i++) {
this.$keywordList.push(keywordList[i]);
}
// createKeywordMapper ignores case which we want because SqlServer keywords are not case sensitive which // createKeywordMapper ignores case which we want because SqlServer keywords are not case sensitive which
// causes our keywords to get changed to lowercase. // causes our keywords to get changed to lowercase.
// However, the preferred standard for keywords is uppercase, so this transforms them back to uppercase for code completion // However, the preferred standard for keywords is uppercase, so this transforms them back to uppercase for code completion
@ -136,6 +147,13 @@ var SqlServerHighlightRules = function() {
this.$keywordList[i] = this.$keywordList[i].toUpperCase(); this.$keywordList[i] = this.$keywordList[i].toUpperCase();
} }
var originalStatementMapper = statementMapper;
statementMapper= function(value){
var r = originalStatementMapper(value);
console.log('value: ' + value + '\tresult: ' + r);
return r;
};
this.$rules = { this.$rules = {
"start": [{ "start": [{
token: "comment", token: "comment",
@ -153,6 +171,9 @@ var SqlServerHighlightRules = function() {
}, { }, {
token: "constant.numeric", // float token: "constant.numeric", // float
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token: statementMapper,
regex: "SET [a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, { }, {
token: keywordMapper, token: keywordMapper,
regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b" //up to 2 @symbols for some build in functions regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b" //up to 2 @symbols for some build in functions