lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/golang_highlight_rules.js in gollum-2.4.4 vs lib/gollum/frontend/public/gollum/livepreview/js/ace/lib/ace/mode/golang_highlight_rules.js in gollum-2.4.5

- old
+ new

@@ -1,22 +1,24 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); - var lang = require("../lib/lang"); var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var GolangHighlightRules = function() { - var keywords = lang.arrayToMap( - ("true|else|false|break|case|return|goto|if|const|" + - "continue|struct|default|switch|for|" + - "func|import|package|chan|defer|fallthrough|go|interface|map|range" + - "select|type|var").split("|") + var keywords = ( + "true|else|false|break|case|return|goto|if|const|" + + "continue|struct|default|switch|for|" + + "func|import|package|chan|defer|fallthrough|go|interface|map|range" + + "select|type|var" ); + var buildinConstants = ("nil|true|false|iota"); - var buildinConstants = lang.arrayToMap( - ("nit|true|false|iota").split("|") - ); + var keywordMapper = this.createKeywordMapper({ + "variable.language": "this", + "keyword": keywords, + "constant.language": buildinConstants + }, "identifier"); this.$rules = { "start" : [ { token : "comment", @@ -55,20 +57,11 @@ regex : "<[a-zA-Z0-9.]+>" }, { token : "keyword", // pre-compiler directivs regex : "(?:#include|#pragma|#line|#define|#undef|#ifdef|#else|#elif|#endif|#ifndef)" }, { - token : function(value) { - if (value == "this") - return "variable.language"; - else if (keywords.hasOwnProperty(value)) - return "keyword"; - else if (buildinConstants.hasOwnProperty(value)) - return "constant.language"; - else - return "identifier"; - }, + token : keywordMapper, regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { token : "keyword.operator", regex : "!|\\$|%|&|\\*|\\-\\-|\\-|\\+\\+|\\+|~|==|=|!=|<=|>=|<<=|>>=|>>>=|<>|<|>|!|&&|\\|\\||\\?\\:|\\*=|%=|\\+=|\\-=|&=|\\^=|\\b(?:in|new|delete|typeof|void)" }, { @@ -117,12 +110,12 @@ merge : true, regex : '.+' } ] }; - - this.embedRules(DocCommentHighlightRules, "doc-", - [ DocCommentHighlightRules.getEndRule("start") ]); + + this.embedRules(DocCommentHighlightRules, "doc-", + [ DocCommentHighlightRules.getEndRule("start") ]); } oop.inherits(GolangHighlightRules, TextHighlightRules); exports.GolangHighlightRules = GolangHighlightRules; });