regexps are allowed after case statements
This commit is contained in:
parent
ed308a539b
commit
86344d92b7
2 changed files with 11 additions and 0 deletions
|
|
@ -51,6 +51,9 @@ var JavaScriptHighlightRules = function() {
|
||||||
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
|
"if|in|instanceof|new|return|switch|throw|try|typeof|let|var|while|with|" +
|
||||||
"const|yield|import|get|set").split("|")
|
"const|yield|import|get|set").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// keywords which can be followed by regular expressions
|
||||||
|
var kwBeforeRe = "case|do|else|finally|in|instanceof|return|throw|try|typeof|yield";
|
||||||
|
|
||||||
var buildinConstants = lang.arrayToMap(
|
var buildinConstants = lang.arrayToMap(
|
||||||
("null|Infinity|NaN|undefined").split("|")
|
("null|Infinity|NaN|undefined").split("|")
|
||||||
|
|
@ -111,6 +114,10 @@ var JavaScriptHighlightRules = function() {
|
||||||
}, {
|
}, {
|
||||||
token : "constant.language.boolean",
|
token : "constant.language.boolean",
|
||||||
regex : "(?:true|false)\\b"
|
regex : "(?:true|false)\\b"
|
||||||
|
}, {
|
||||||
|
token : "keyword",
|
||||||
|
regex : kwBeforeRe,
|
||||||
|
next : "regex_allowed"
|
||||||
}, {
|
}, {
|
||||||
token : function(value) {
|
token : function(value) {
|
||||||
if (value == "this")
|
if (value == "this")
|
||||||
|
|
|
||||||
|
|
@ -136,6 +136,10 @@ module.exports = {
|
||||||
assert.equal(7, tokens.length);
|
assert.equal(7, tokens.length);
|
||||||
assert.equal("string.regexp", tokens[2].type);
|
assert.equal("string.regexp", tokens[2].type);
|
||||||
assert.equal("string.regexp", tokens[6].type);
|
assert.equal("string.regexp", tokens[6].type);
|
||||||
|
|
||||||
|
var tokens = this.tokenizer.getLineTokens("case /a/.test(c)", "start").tokens;
|
||||||
|
assert.equal(8, tokens.length);
|
||||||
|
assert.equal("string.regexp", tokens[2].type);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue