fix error in objectivec_highlight_rules when Array.prototype is modified

This commit is contained in:
nightwing 2012-12-25 19:39:33 +04:00
commit 8f6f6c6e3d

View file

@ -17,12 +17,10 @@ var ObjectiveCHighlightRules = function() {
"222|" + "222|" +
"x[a-zA-Z0-9]+)"; "x[a-zA-Z0-9]+)";
var specialVariables = [ var specialVariables = [{
{
"regex": "\\b_cmd\\b", "regex": "\\b_cmd\\b",
"token": "variable.other.selector.objc" "token": "variable.other.selector.objc"
}, }, {
{
"regex": "\\b(?:self|super)\\b", "regex": "\\b(?:self|super)\\b",
"token": "variable.language.objc" "token": "variable.language.objc"
} }
@ -31,8 +29,7 @@ var ObjectiveCHighlightRules = function() {
var cObj = new CHighlightRules(); var cObj = new CHighlightRules();
var cRules = cObj.getRules(); var cRules = cObj.getRules();
this.$rules = this.$rules = {
{
"start": [ "start": [
{ {
token : "comment", token : "comment",
@ -312,24 +309,17 @@ var ObjectiveCHighlightRules = function() {
// copy in C-Rules directly // copy in C-Rules directly
for (var r in cRules) { for (var r in cRules) {
if (r == "start") { if (this.$rules[r]) {
for (var key in cRules[r]) { if (this.$rules[r].push)
this.$rules.start.push(cRules[r][key]) this.$rules[r].push.apply(this.$rules[r], cRules[r]);
} } else {
}
else {
this.$rules[r] = cRules[r]; this.$rules[r] = cRules[r];
} }
} }
var startRules = this.$rules.start; this.$rules.bracketed_content = this.$rules.bracketed_content.concat(
for (var s in startRules) { this.$rules.start, specialVariables
this.$rules.bracketed_content.push(startRules[s]); );
}
for (var s in specialVariables) {
this.$rules.bracketed_content.push(specialVariables[s]);
}
this.embedRules(DocCommentHighlightRules, "doc-", this.embedRules(DocCommentHighlightRules, "doc-",
[ DocCommentHighlightRules.getEndRule("start") ]); [ DocCommentHighlightRules.getEndRule("start") ]);