progress but not working yet

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

View file

@ -3,7 +3,7 @@
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
@ -14,7 +14,7 @@
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@ -36,9 +36,9 @@ var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var SqlServerHighlightRules = function() {
/**
* each section has a link and some javacript code.
* each section has a link and some javacript code.
* go to the link, open dev tools, run code to get the string.
*
*
* Right now this code is optimized to make it easy for a developer to modify.
* Once I'm certain that this is not missing anything it can be 'compiled' into a cleaner/faster format that is not executing stuff on the fly for no reason.
*/
@ -81,7 +81,7 @@ var SqlServerHighlightRules = function() {
/* 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|" +
/* 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
//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) {
v.split(' ').forEach(function(v) {
keywords += '|' + v;
});
});
});*/
//remove any other built in things from key word list
@ -124,17 +124,35 @@ var SqlServerHighlightRules = function() {
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"keyword.set": setStatements,
"constant.language": logicalOperators,
"storage.type": dataTypes
}, "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
// 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
for (var i = 0; i < this.$keywordList.length; i++) {
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 = {
"start": [{
@ -153,10 +171,13 @@ var SqlServerHighlightRules = function() {
}, {
token: "constant.numeric", // float
regex: "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
}, {
token: statementMapper,
regex: "SET [a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {
token: keywordMapper,
regex: "@{0,2}[a-zA-Z_$][a-zA-Z0-9_$]*\\b" //up to 2 @symbols for some build in functions
}, {
},{
token: "constant.class",
regex: "@@?[a-zA-Z_$][a-zA-Z0-9_$]*\\b"
}, {