Updated client/utils/javascript.js
to reflect changes in the CodeMirror's repository (#805)
* Updated client/utils/p5-javascript.js to reflect the latest one in CodeMirror's repository * Template string bug fixed (#773)
This commit is contained in:
parent
65c1c35d10
commit
772a7c9370
1 changed files with 259 additions and 98 deletions
|
@ -1,7 +1,7 @@
|
||||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||||
/* eslint-disable */
|
|
||||||
|
|
||||||
|
/*eslint-disable*/
|
||||||
(function(mod) {
|
(function(mod) {
|
||||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||||
mod(require("codemirror"));
|
mod(require("codemirror"));
|
||||||
|
@ -12,11 +12,6 @@
|
||||||
})(function(CodeMirror) {
|
})(function(CodeMirror) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function expressionAllowed(stream, state, backUp) {
|
|
||||||
return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
|
||||||
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
|
||||||
}
|
|
||||||
|
|
||||||
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
var indentUnit = config.indentUnit;
|
var indentUnit = config.indentUnit;
|
||||||
var statementIndent = parserConfig.statementIndent;
|
var statementIndent = parserConfig.statementIndent;
|
||||||
|
@ -26,13 +21,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;
|
||||||
|
|
||||||
// Tokenizer
|
// Tokenizer
|
||||||
|
|
||||||
var keywords = function(){
|
var keywords = function(){
|
||||||
function kw(type) {return {type: type, style: "keyword"};}
|
function kw(type) {return {type: type, style: "keyword"};}
|
||||||
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
||||||
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
||||||
var p5Function = {type: "p5-function", style: "p5-function"};
|
var p5Function = {type: "variable", style: "p5-function"};
|
||||||
var p5Variable = {type: "p5-variable", style: "p5-variable"};
|
var p5Variable = {type: "variable", style: "p5-variable"};
|
||||||
|
|
||||||
var jsKeywords = {
|
var jsKeywords = {
|
||||||
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
||||||
|
@ -151,7 +145,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
return jsKeywords;
|
return jsKeywords;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
var isOperatorChar = /[+\-*&%=<>!?|~^@]/;
|
||||||
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
||||||
|
|
||||||
function readRegexp(stream) {
|
function readRegexp(stream) {
|
||||||
|
@ -186,17 +180,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
return ret(ch);
|
return ret(ch);
|
||||||
} else if (ch == "=" && stream.eat(">")) {
|
} else if (ch == "=" && stream.eat(">")) {
|
||||||
return ret("=>", "operator");
|
return ret("=>", "operator");
|
||||||
} else if (ch == "0" && stream.eat(/x/i)) {
|
} else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
|
||||||
stream.eatWhile(/[\da-f]/i);
|
|
||||||
return ret("number", "number");
|
|
||||||
} else if (ch == "0" && stream.eat(/o/i)) {
|
|
||||||
stream.eatWhile(/[0-7]/i);
|
|
||||||
return ret("number", "number");
|
|
||||||
} else if (ch == "0" && stream.eat(/b/i)) {
|
|
||||||
stream.eatWhile(/[01]/i);
|
|
||||||
return ret("number", "number");
|
return ret("number", "number");
|
||||||
} else if (/\d/.test(ch)) {
|
} else if (/\d/.test(ch)) {
|
||||||
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
|
||||||
return ret("number", "number");
|
return ret("number", "number");
|
||||||
} else if (ch == "/") {
|
} else if (ch == "/") {
|
||||||
if (stream.eat("*")) {
|
if (stream.eat("*")) {
|
||||||
|
@ -207,10 +194,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
return ret("comment", "comment");
|
return ret("comment", "comment");
|
||||||
} else if (expressionAllowed(stream, state, 1)) {
|
} else if (expressionAllowed(stream, state, 1)) {
|
||||||
readRegexp(stream);
|
readRegexp(stream);
|
||||||
stream.match(/^\b(([gimyu])(?![gimyu]*\2))+\b/);
|
stream.match(/^\b(([gimyus])(?![gimyus]*\2))+\b/);
|
||||||
return ret("regexp", "string-2");
|
return ret("regexp", "string-2");
|
||||||
} else {
|
} else {
|
||||||
stream.eatWhile(isOperatorChar);
|
stream.eat("=");
|
||||||
return ret("operator", "operator", stream.current());
|
return ret("operator", "operator", stream.current());
|
||||||
}
|
}
|
||||||
} else if (ch == "`") {
|
} else if (ch == "`") {
|
||||||
|
@ -220,13 +207,27 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
stream.skipToEnd();
|
stream.skipToEnd();
|
||||||
return ret("error", "error");
|
return ret("error", "error");
|
||||||
} else if (isOperatorChar.test(ch)) {
|
} else if (isOperatorChar.test(ch)) {
|
||||||
stream.eatWhile(isOperatorChar);
|
if (ch != ">" || !state.lexical || state.lexical.type != ">") {
|
||||||
|
if (stream.eat("=")) {
|
||||||
|
if (ch == "!" || ch == "=") stream.eat("=")
|
||||||
|
} else if (/[<>*+\-]/.test(ch)) {
|
||||||
|
stream.eat(ch)
|
||||||
|
if (ch == ">") stream.eat(ch)
|
||||||
|
}
|
||||||
|
}
|
||||||
return ret("operator", "operator", stream.current());
|
return ret("operator", "operator", stream.current());
|
||||||
} else if (wordRE.test(ch)) {
|
} else if (wordRE.test(ch)) {
|
||||||
stream.eatWhile(wordRE);
|
stream.eatWhile(wordRE);
|
||||||
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
var word = stream.current()
|
||||||
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
if (state.lastType != ".") {
|
||||||
ret("variable", "variable", word);
|
if (keywords.propertyIsEnumerable(word)) {
|
||||||
|
var kw = keywords[word]
|
||||||
|
return ret(kw.type, kw.style, word)
|
||||||
|
}
|
||||||
|
if (word == "async" && stream.match(/^(\s|\/\*.*?\*\/)*[\[\(\w]/, false))
|
||||||
|
return ret("async", "keyword", word)
|
||||||
|
}
|
||||||
|
return ret("variable", "variable", word)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,35 +363,69 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
pass.apply(null, arguments);
|
pass.apply(null, arguments);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
function register(varname) {
|
function inList(name, list) {
|
||||||
function inList(list) {
|
for (var v = list; v; v = v.next) if (v.name == name) return true
|
||||||
for (var v = list; v; v = v.next)
|
|
||||||
if (v.name == varname) return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
function register(varname) {
|
||||||
var state = cx.state;
|
var state = cx.state;
|
||||||
cx.marked = "def";
|
cx.marked = "def";
|
||||||
if (state.context) {
|
if (state.context) {
|
||||||
if (inList(state.localVars)) return;
|
if (state.lexical.info == "var" && state.context && state.context.block) {
|
||||||
state.localVars = {name: varname, next: state.localVars};
|
// FIXME function decls are also not block scoped
|
||||||
} else {
|
var newContext = registerVarScoped(varname, state.context)
|
||||||
if (inList(state.globalVars)) return;
|
if (newContext != null) {
|
||||||
if (parserConfig.globalVars)
|
state.context = newContext
|
||||||
state.globalVars = {name: varname, next: state.globalVars};
|
return
|
||||||
}
|
}
|
||||||
|
} else if (!inList(varname, state.localVars)) {
|
||||||
|
state.localVars = new Var(varname, state.localVars)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.register = register;
|
||||||
|
// Fall through means this is global
|
||||||
|
if (parserConfig.globalVars && !inList(varname, state.globalVars))
|
||||||
|
state.globalVars = new Var(varname, state.globalVars)
|
||||||
|
}
|
||||||
|
function registerVarScoped(varname, context) {
|
||||||
|
if (!context) {
|
||||||
|
return null
|
||||||
|
} else if (context.block) {
|
||||||
|
var inner = registerVarScoped(varname, context.prev)
|
||||||
|
if (!inner) return null
|
||||||
|
if (inner == context.prev) return context
|
||||||
|
return new Context(inner, context.vars, true)
|
||||||
|
} else if (inList(varname, context.vars)) {
|
||||||
|
return context
|
||||||
|
} else {
|
||||||
|
return new Context(context.prev, new Var(varname, context.vars), false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isModifier(name) {
|
||||||
|
return name == "public" || name == "private" || name == "protected" || name == "abstract" || name == "readonly"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Combinators
|
// Combinators
|
||||||
|
|
||||||
var defaultVars = {name: "this", next: {name: "arguments"}};
|
function Context(prev, vars, block) { this.prev = prev; this.vars = vars; this.block = block }
|
||||||
|
function Var(name, next) { this.name = name; this.next = next }
|
||||||
|
|
||||||
|
var defaultVars = new Var("this", new Var("arguments", null))
|
||||||
function pushcontext() {
|
function pushcontext() {
|
||||||
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
cx.state.context = new Context(cx.state.context, cx.state.localVars, false)
|
||||||
cx.state.localVars = defaultVars;
|
cx.state.localVars = defaultVars
|
||||||
|
}
|
||||||
|
function pushblockcontext() {
|
||||||
|
cx.state.context = new Context(cx.state.context, cx.state.localVars, true)
|
||||||
|
cx.state.localVars = null
|
||||||
}
|
}
|
||||||
function popcontext() {
|
function popcontext() {
|
||||||
cx.state.localVars = cx.state.context.vars;
|
cx.state.localVars = cx.state.context.vars
|
||||||
cx.state.context = cx.state.context.prev;
|
cx.state.context = cx.state.context.prev
|
||||||
}
|
}
|
||||||
|
popcontext.lex = true
|
||||||
function pushlex(type, info) {
|
function pushlex(type, info) {
|
||||||
var result = function() {
|
var result = function() {
|
||||||
var state = cx.state, indent = state.indented;
|
var state = cx.state, indent = state.indented;
|
||||||
|
@ -415,17 +450,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
function expect(wanted) {
|
function expect(wanted) {
|
||||||
function exp(type) {
|
function exp(type) {
|
||||||
if (type == wanted) return cont();
|
if (type == wanted) return cont();
|
||||||
else if (wanted == ";") return pass();
|
else if (wanted == ";" || type == "}" || type == ")" || type == "]") return pass();
|
||||||
else return cont(exp);
|
else return cont(exp);
|
||||||
};
|
};
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function statement(type, value) {
|
function statement(type, value) {
|
||||||
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
if (type == "var") return cont(pushlex("vardef", value), vardef, expect(";"), poplex);
|
||||||
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
if (type == "keyword a") return cont(pushlex("form"), parenExpr, statement, poplex);
|
||||||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
if (type == "keyword d") return cx.stream.match(/^\s*$/, false) ? cont() : cont(pushlex("stat"), maybeexpression, expect(";"), poplex);
|
||||||
|
if (type == "debugger") return cont(expect(";"));
|
||||||
|
if (type == "{") return cont(pushlex("}"), pushblockcontext, block, poplex, popcontext);
|
||||||
if (type == ";") return cont();
|
if (type == ";") return cont();
|
||||||
if (type == "if") {
|
if (type == "if") {
|
||||||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
||||||
|
@ -434,59 +471,78 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
}
|
}
|
||||||
if (type == "function") return cont(functiondef);
|
if (type == "function") return cont(functiondef);
|
||||||
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
||||||
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
if (type == "class" || (isTS && value == "interface")) {
|
||||||
if (type == "switch") return cont(pushlex("form"), parenExpr, pushlex("}", "switch"), expect("{"),
|
cx.marked = "keyword"
|
||||||
block, poplex, poplex);
|
return cont(pushlex("form", type == "class" ? type : value), className, poplex)
|
||||||
|
}
|
||||||
|
if (type == "variable") {
|
||||||
|
if (isTS && value == "declare") {
|
||||||
|
cx.marked = "keyword"
|
||||||
|
return cont(statement)
|
||||||
|
} else if (isTS && (value == "module" || value == "enum" || value == "type") && cx.stream.match(/^\s*\w/, false)) {
|
||||||
|
cx.marked = "keyword"
|
||||||
|
if (value == "enum") return cont(enumdef);
|
||||||
|
else if (value == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
||||||
|
else return cont(pushlex("form"), pattern, expect("{"), pushlex("}"), block, poplex, poplex)
|
||||||
|
} else if (isTS && value == "namespace") {
|
||||||
|
cx.marked = "keyword"
|
||||||
|
return cont(pushlex("form"), expression, statement, poplex)
|
||||||
|
} else if (isTS && value == "abstract") {
|
||||||
|
cx.marked = "keyword"
|
||||||
|
return cont(statement)
|
||||||
|
} else {
|
||||||
|
return cont(pushlex("stat"), maybelabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type == "switch") return cont(pushlex("form"), parenExpr, expect("{"), pushlex("}", "switch"), pushblockcontext,
|
||||||
|
block, poplex, poplex, popcontext);
|
||||||
if (type == "case") return cont(expression, expect(":"));
|
if (type == "case") return cont(expression, expect(":"));
|
||||||
if (type == "default") return cont(expect(":"));
|
if (type == "default") return cont(expect(":"));
|
||||||
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
if (type == "catch") return cont(pushlex("form"), pushcontext, maybeCatchBinding, statement, poplex, popcontext);
|
||||||
statement, poplex, popcontext);
|
|
||||||
if (type == "class") return cont(pushlex("form"), className, poplex);
|
|
||||||
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
if (type == "export") return cont(pushlex("stat"), afterExport, poplex);
|
||||||
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
if (type == "import") return cont(pushlex("stat"), afterImport, poplex);
|
||||||
if (type == "module") return cont(pushlex("form"), pattern, pushlex("}"), expect("{"), block, poplex, poplex)
|
|
||||||
if (type == "type") return cont(typeexpr, expect("operator"), typeexpr, expect(";"));
|
|
||||||
if (type == "async") return cont(statement)
|
if (type == "async") return cont(statement)
|
||||||
|
if (value == "@") return cont(expression, statement)
|
||||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||||
}
|
}
|
||||||
function expression(type) {
|
function maybeCatchBinding(type) {
|
||||||
return expressionInner(type, false);
|
if (type == "(") return cont(funarg, expect(")"))
|
||||||
}
|
}
|
||||||
function expressionNoComma(type) {
|
function expression(type, value) {
|
||||||
return expressionInner(type, true);
|
return expressionInner(type, value, false);
|
||||||
|
}
|
||||||
|
function expressionNoComma(type, value) {
|
||||||
|
return expressionInner(type, value, true);
|
||||||
}
|
}
|
||||||
function parenExpr(type) {
|
function parenExpr(type) {
|
||||||
if (type != "(") return pass()
|
if (type != "(") return pass()
|
||||||
return cont(pushlex(")"), expression, expect(")"), poplex)
|
return cont(pushlex(")"), expression, expect(")"), poplex)
|
||||||
}
|
}
|
||||||
function expressionInner(type, noComma) {
|
function expressionInner(type, value, noComma) {
|
||||||
if (cx.state.fatArrowAt == cx.stream.start) {
|
if (cx.state.fatArrowAt == cx.stream.start) {
|
||||||
var body = noComma ? arrowBodyNoComma : arrowBody;
|
var body = noComma ? arrowBodyNoComma : arrowBody;
|
||||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
|
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, expect("=>"), body, popcontext);
|
||||||
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
||||||
}
|
}
|
||||||
|
|
||||||
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
||||||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
||||||
if (type == "function") return cont(functiondef, maybeop);
|
if (type == "function") return cont(functiondef, maybeop);
|
||||||
if (type == "class") return cont(pushlex("form"), classExpression, poplex);
|
if (type == "class" || (isTS && value == "interface")) { cx.marked = "keyword"; return cont(pushlex("form"), classExpression, poplex); }
|
||||||
if (type == "keyword c" || type == "async") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
|
if (type == "keyword c" || type == "async") return cont(noComma ? expressionNoComma : expression);
|
||||||
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
|
||||||
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
||||||
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
||||||
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
||||||
if (type == "quasi") return pass(quasi, maybeop);
|
if (type == "quasi") return pass(quasi, maybeop);
|
||||||
if (type == "new") return cont(maybeTarget(noComma));
|
if (type == "new") return cont(maybeTarget(noComma));
|
||||||
|
if (type == "import") return cont(expression);
|
||||||
return cont();
|
return cont();
|
||||||
}
|
}
|
||||||
function maybeexpression(type) {
|
function maybeexpression(type) {
|
||||||
if (type.match(/[;\}\)\],]/)) return pass();
|
if (type.match(/[;\}\)\],]/)) return pass();
|
||||||
return pass(expression);
|
return pass(expression);
|
||||||
}
|
}
|
||||||
function maybeexpressionNoComma(type) {
|
|
||||||
if (type.match(/[;\}\)\],]/)) return pass();
|
|
||||||
return pass(expressionNoComma);
|
|
||||||
}
|
|
||||||
|
|
||||||
function maybeoperatorComma(type, value) {
|
function maybeoperatorComma(type, value) {
|
||||||
if (type == ",") return cont(expression);
|
if (type == ",") return cont(expression);
|
||||||
|
@ -497,7 +553,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
var expr = noComma == false ? expression : expressionNoComma;
|
var expr = noComma == false ? expression : expressionNoComma;
|
||||||
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
||||||
if (type == "operator") {
|
if (type == "operator") {
|
||||||
if (/\+\+|--/.test(value)) return cont(me);
|
if (/\+\+|--/.test(value) || isTS && value == "!") return cont(me);
|
||||||
|
if (isTS && value == "<" && cx.stream.match(/^([^>]|<.*?>)*>\s*\(/, false))
|
||||||
|
return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, me);
|
||||||
if (value == "?") return cont(expression, expect(":"), expr);
|
if (value == "?") return cont(expression, expect(":"), expr);
|
||||||
return cont(expr);
|
return cont(expr);
|
||||||
}
|
}
|
||||||
|
@ -506,6 +564,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
||||||
if (type == ".") return cont(property, me);
|
if (type == ".") return cont(property, me);
|
||||||
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
||||||
|
if (isTS && value == "as") { cx.marked = "keyword"; return cont(typeexpr, me) }
|
||||||
|
if (type == "regexp") {
|
||||||
|
cx.state.lastType = cx.marked = "operator"
|
||||||
|
cx.stream.backUp(cx.stream.pos - cx.stream.start - 1)
|
||||||
|
return cont(expr)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function quasi(type, value) {
|
function quasi(type, value) {
|
||||||
if (type != "quasi") return pass();
|
if (type != "quasi") return pass();
|
||||||
|
@ -530,6 +594,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
function maybeTarget(noComma) {
|
function maybeTarget(noComma) {
|
||||||
return function(type) {
|
return function(type) {
|
||||||
if (type == ".") return cont(noComma ? targetNoComma : target);
|
if (type == ".") return cont(noComma ? targetNoComma : target);
|
||||||
|
else if (type == "variable" && isTS) return cont(maybeTypeArgs, noComma ? maybeoperatorNoComma : maybeoperatorComma)
|
||||||
else return pass(noComma ? expressionNoComma : expression);
|
else return pass(noComma ? expressionNoComma : expression);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -553,18 +618,25 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
} else if (type == "variable" || cx.style == "keyword") {
|
} else if (type == "variable" || cx.style == "keyword") {
|
||||||
cx.marked = "property";
|
cx.marked = "property";
|
||||||
if (value == "get" || value == "set") return cont(getterSetter);
|
if (value == "get" || value == "set") return cont(getterSetter);
|
||||||
|
var m // Work around fat-arrow-detection complication for detecting typescript typed arrow params
|
||||||
|
if (isTS && cx.state.fatArrowAt == cx.stream.start && (m = cx.stream.match(/^\s*:\s*/, false)))
|
||||||
|
cx.state.fatArrowAt = cx.stream.pos + m[0].length
|
||||||
return cont(afterprop);
|
return cont(afterprop);
|
||||||
} else if (type == "number" || type == "string") {
|
} else if (type == "number" || type == "string") {
|
||||||
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
||||||
return cont(afterprop);
|
return cont(afterprop);
|
||||||
} else if (type == "jsonld-keyword") {
|
} else if (type == "jsonld-keyword") {
|
||||||
return cont(afterprop);
|
return cont(afterprop);
|
||||||
} else if (type == "modifier") {
|
} else if (isTS && isModifier(value)) {
|
||||||
|
cx.marked = "keyword"
|
||||||
return cont(objprop)
|
return cont(objprop)
|
||||||
} else if (type == "[") {
|
} else if (type == "[") {
|
||||||
return cont(expression, expect("]"), afterprop);
|
return cont(expression, maybetype, expect("]"), afterprop);
|
||||||
} else if (type == "spread") {
|
} else if (type == "spread") {
|
||||||
return cont(expression);
|
return cont(expressionNoComma, afterprop);
|
||||||
|
} else if (value == "*") {
|
||||||
|
cx.marked = "keyword";
|
||||||
|
return cont(objprop);
|
||||||
} else if (type == ":") {
|
} else if (type == ":") {
|
||||||
return pass(afterprop)
|
return pass(afterprop)
|
||||||
}
|
}
|
||||||
|
@ -578,9 +650,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == ":") return cont(expressionNoComma);
|
if (type == ":") return cont(expressionNoComma);
|
||||||
if (type == "(") return pass(functiondef);
|
if (type == "(") return pass(functiondef);
|
||||||
}
|
}
|
||||||
function commasep(what, end) {
|
function commasep(what, end, sep) {
|
||||||
function proceed(type, value) {
|
function proceed(type, value) {
|
||||||
if (type == ",") {
|
if (sep ? sep.indexOf(type) > -1 : type == ",") {
|
||||||
var lex = cx.state.lexical;
|
var lex = cx.state.lexical;
|
||||||
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
||||||
return cont(function(type, value) {
|
return cont(function(type, value) {
|
||||||
|
@ -589,6 +661,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
}, proceed);
|
}, proceed);
|
||||||
}
|
}
|
||||||
if (type == end || value == end) return cont();
|
if (type == end || value == end) return cont();
|
||||||
|
if (sep && sep.indexOf(";") > -1) return pass(what)
|
||||||
return cont(expect(end));
|
return cont(expect(end));
|
||||||
}
|
}
|
||||||
return function(type, value) {
|
return function(type, value) {
|
||||||
|
@ -611,38 +684,79 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (value == "?") return cont(maybetype);
|
if (value == "?") return cont(maybetype);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function typeexpr(type) {
|
function mayberettype(type) {
|
||||||
if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
|
if (isTS && type == ":") {
|
||||||
if (type == "{") return cont(commasep(typeprop, "}"))
|
if (cx.stream.match(/^\s*\w+\s+is\b/, false)) return cont(expression, isKW, typeexpr)
|
||||||
|
else return cont(typeexpr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function isKW(_, value) {
|
||||||
|
if (value == "is") {
|
||||||
|
cx.marked = "keyword"
|
||||||
|
return cont()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function typeexpr(type, value) {
|
||||||
|
if (value == "keyof" || value == "typeof") {
|
||||||
|
cx.marked = "keyword"
|
||||||
|
return cont(value == "keyof" ? typeexpr : expressionNoComma)
|
||||||
|
}
|
||||||
|
if (type == "variable" || value == "void") {
|
||||||
|
cx.marked = "type"
|
||||||
|
return cont(afterType)
|
||||||
|
}
|
||||||
|
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
||||||
|
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType)
|
||||||
|
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType)
|
||||||
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
||||||
|
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr)
|
||||||
}
|
}
|
||||||
function maybeReturnType(type) {
|
function maybeReturnType(type) {
|
||||||
if (type == "=>") return cont(typeexpr)
|
if (type == "=>") return cont(typeexpr)
|
||||||
}
|
}
|
||||||
function typeprop(type) {
|
function typeprop(type, value) {
|
||||||
if (type == "variable" || cx.style == "keyword") {
|
if (type == "variable" || cx.style == "keyword") {
|
||||||
cx.marked = "property"
|
cx.marked = "property"
|
||||||
return cont(typeprop)
|
return cont(typeprop)
|
||||||
|
} else if (value == "?") {
|
||||||
|
return cont(typeprop)
|
||||||
} else if (type == ":") {
|
} else if (type == ":") {
|
||||||
return cont(typeexpr)
|
return cont(typeexpr)
|
||||||
|
} else if (type == "[") {
|
||||||
|
return cont(expression, maybetype, expect("]"), typeprop)
|
||||||
|
} else if (type == "(") {
|
||||||
|
return cont(pushlex(")"), commasep(funarg, ")"), poplex, typeprop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function typearg(type) {
|
function typearg(type, value) {
|
||||||
if (type == "variable") return cont(typearg)
|
if (type == "variable" && cx.stream.match(/^\s*[?:]/, false) || value == "?") return cont(typearg)
|
||||||
else if (type == ":") return cont(typeexpr)
|
if (type == ":") return cont(typeexpr)
|
||||||
|
return pass(typeexpr)
|
||||||
}
|
}
|
||||||
function afterType(type, value) {
|
function afterType(type, value) {
|
||||||
if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
|
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
||||||
|
if (value == "|" || type == "." || value == "&") return cont(typeexpr)
|
||||||
if (type == "[") return cont(expect("]"), afterType)
|
if (type == "[") return cont(expect("]"), afterType)
|
||||||
|
if (value == "extends" || value == "implements") { cx.marked = "keyword"; return cont(typeexpr) }
|
||||||
}
|
}
|
||||||
function vardef() {
|
function maybeTypeArgs(_, value) {
|
||||||
|
if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
||||||
|
}
|
||||||
|
function typeparam() {
|
||||||
|
return pass(typeexpr, maybeTypeDefault)
|
||||||
|
}
|
||||||
|
function maybeTypeDefault(_, value) {
|
||||||
|
if (value == "=") return cont(typeexpr)
|
||||||
|
}
|
||||||
|
function vardef(_, value) {
|
||||||
|
if (value == "enum") {cx.marked = "keyword"; return cont(enumdef)}
|
||||||
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
||||||
}
|
}
|
||||||
function pattern(type, value) {
|
function pattern(type, value) {
|
||||||
if (type == "modifier") return cont(pattern)
|
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(pattern) }
|
||||||
if (type == "variable") { register(value); return cont(); }
|
if (type == "variable") { register(value); return cont(); }
|
||||||
if (type == "spread") return cont(pattern);
|
if (type == "spread") return cont(pattern);
|
||||||
if (type == "[") return contCommasep(pattern, "]");
|
if (type == "[") return contCommasep(eltpattern, "]");
|
||||||
if (type == "{") return contCommasep(proppattern, "}");
|
if (type == "{") return contCommasep(proppattern, "}");
|
||||||
}
|
}
|
||||||
function proppattern(type, value) {
|
function proppattern(type, value) {
|
||||||
|
@ -653,8 +767,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "variable") cx.marked = "property";
|
if (type == "variable") cx.marked = "property";
|
||||||
if (type == "spread") return cont(pattern);
|
if (type == "spread") return cont(pattern);
|
||||||
if (type == "}") return pass();
|
if (type == "}") return pass();
|
||||||
|
if (type == "[") return cont(expression, expect(']'), expect(':'), proppattern);
|
||||||
return cont(expect(":"), pattern, maybeAssign);
|
return cont(expect(":"), pattern, maybeAssign);
|
||||||
}
|
}
|
||||||
|
function eltpattern() {
|
||||||
|
return pass(pattern, maybeAssign)
|
||||||
|
}
|
||||||
function maybeAssign(_type, value) {
|
function maybeAssign(_type, value) {
|
||||||
if (value == "=") return cont(expressionNoComma);
|
if (value == "=") return cont(expressionNoComma);
|
||||||
}
|
}
|
||||||
|
@ -664,7 +782,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
function maybeelse(type, value) {
|
function maybeelse(type, value) {
|
||||||
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
||||||
}
|
}
|
||||||
function forspec(type) {
|
function forspec(type, value) {
|
||||||
|
if (value == "await") return cont(forspec);
|
||||||
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
||||||
}
|
}
|
||||||
function forspec1(type) {
|
function forspec1(type) {
|
||||||
|
@ -688,10 +807,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
function functiondef(type, value) {
|
function functiondef(type, value) {
|
||||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
||||||
if (type == "variable") {register(value); return cont(functiondef);}
|
if (type == "variable") {register(value); return cont(functiondef);}
|
||||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, maybetype, statement, popcontext);
|
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, statement, popcontext);
|
||||||
|
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondef)
|
||||||
}
|
}
|
||||||
function funarg(type) {
|
function functiondecl(type, value) {
|
||||||
|
if (value == "*") {cx.marked = "keyword"; return cont(functiondecl);}
|
||||||
|
if (type == "variable") {register(value); return cont(functiondecl);}
|
||||||
|
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, mayberettype, popcontext);
|
||||||
|
if (isTS && value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, functiondecl)
|
||||||
|
}
|
||||||
|
function funarg(type, value) {
|
||||||
|
if (value == "@") cont(expression, funarg)
|
||||||
if (type == "spread") return cont(funarg);
|
if (type == "spread") return cont(funarg);
|
||||||
|
if (isTS && isModifier(value)) { cx.marked = "keyword"; return cont(funarg); }
|
||||||
return pass(pattern, maybetype, maybeAssign);
|
return pass(pattern, maybetype, maybeAssign);
|
||||||
}
|
}
|
||||||
function classExpression(type, value) {
|
function classExpression(type, value) {
|
||||||
|
@ -703,40 +831,56 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "variable") {register(value); return cont(classNameAfter);}
|
if (type == "variable") {register(value); return cont(classNameAfter);}
|
||||||
}
|
}
|
||||||
function classNameAfter(type, value) {
|
function classNameAfter(type, value) {
|
||||||
if (value == "extends" || value == "implements") return cont(isTS ? typeexpr : expression, classNameAfter);
|
if (value == "<") return cont(pushlex(">"), commasep(typeparam, ">"), poplex, classNameAfter)
|
||||||
|
if (value == "extends" || value == "implements" || (isTS && type == ",")) {
|
||||||
|
if (value == "implements") cx.marked = "keyword";
|
||||||
|
return cont(isTS ? typeexpr : expression, classNameAfter);
|
||||||
|
}
|
||||||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||||
}
|
}
|
||||||
function classBody(type, value) {
|
function classBody(type, value) {
|
||||||
if (type == "variable" || cx.style == "keyword") {
|
if (type == "async" ||
|
||||||
if ((value == "static" || value == "get" || value == "set" ||
|
(type == "variable" &&
|
||||||
(isTS && (value == "public" || value == "private" || value == "protected" || value == "readonly" || value == "abstract"))) &&
|
(value == "static" || value == "get" || value == "set" || (isTS && isModifier(value))) &&
|
||||||
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
|
cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false))) {
|
||||||
cx.marked = "keyword";
|
cx.marked = "keyword";
|
||||||
return cont(classBody);
|
return cont(classBody);
|
||||||
}
|
}
|
||||||
|
if (type == "variable" || cx.style == "keyword") {
|
||||||
cx.marked = "property";
|
cx.marked = "property";
|
||||||
return cont(isTS ? classfield : functiondef, classBody);
|
return cont(isTS ? classfield : functiondef, classBody);
|
||||||
}
|
}
|
||||||
|
if (type == "[")
|
||||||
|
return cont(expression, maybetype, expect("]"), isTS ? classfield : functiondef, classBody)
|
||||||
if (value == "*") {
|
if (value == "*") {
|
||||||
cx.marked = "keyword";
|
cx.marked = "keyword";
|
||||||
return cont(classBody);
|
return cont(classBody);
|
||||||
}
|
}
|
||||||
if (type == ";") return cont(classBody);
|
if (type == ";") return cont(classBody);
|
||||||
if (type == "}") return cont();
|
if (type == "}") return cont();
|
||||||
|
if (value == "@") return cont(expression, classBody)
|
||||||
}
|
}
|
||||||
function classfield(type, value) {
|
function classfield(type, value) {
|
||||||
if (value == "?") return cont(classfield)
|
if (value == "?") return cont(classfield)
|
||||||
if (type == ":") return cont(typeexpr, maybeAssign)
|
if (type == ":") return cont(typeexpr, maybeAssign)
|
||||||
return pass(functiondef)
|
if (value == "=") return cont(expressionNoComma)
|
||||||
|
var context = cx.state.lexical.prev, isInterface = context && context.info == "interface"
|
||||||
|
return pass(isInterface ? functiondecl : functiondef)
|
||||||
}
|
}
|
||||||
function afterExport(_type, value) {
|
function afterExport(type, value) {
|
||||||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
||||||
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
||||||
|
if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
|
||||||
return pass(statement);
|
return pass(statement);
|
||||||
}
|
}
|
||||||
|
function exportField(type, value) {
|
||||||
|
if (value == "as") { cx.marked = "keyword"; return cont(expect("variable")); }
|
||||||
|
if (type == "variable") return pass(expressionNoComma, exportField);
|
||||||
|
}
|
||||||
function afterImport(type) {
|
function afterImport(type) {
|
||||||
if (type == "string") return cont();
|
if (type == "string") return cont();
|
||||||
return pass(importSpec, maybeFrom);
|
if (type == "(") return pass(expression);
|
||||||
|
return pass(importSpec, maybeMoreImports, maybeFrom);
|
||||||
}
|
}
|
||||||
function importSpec(type, value) {
|
function importSpec(type, value) {
|
||||||
if (type == "{") return contCommasep(importSpec, "}");
|
if (type == "{") return contCommasep(importSpec, "}");
|
||||||
|
@ -744,6 +888,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (value == "*") cx.marked = "keyword";
|
if (value == "*") cx.marked = "keyword";
|
||||||
return cont(maybeAs);
|
return cont(maybeAs);
|
||||||
}
|
}
|
||||||
|
function maybeMoreImports(type) {
|
||||||
|
if (type == ",") return cont(importSpec, maybeMoreImports)
|
||||||
|
}
|
||||||
function maybeAs(_type, value) {
|
function maybeAs(_type, value) {
|
||||||
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
||||||
}
|
}
|
||||||
|
@ -754,6 +901,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
if (type == "]") return cont();
|
if (type == "]") return cont();
|
||||||
return pass(commasep(expressionNoComma, "]"));
|
return pass(commasep(expressionNoComma, "]"));
|
||||||
}
|
}
|
||||||
|
function enumdef() {
|
||||||
|
return pass(pushlex("form"), pattern, expect("{"), pushlex("}"), commasep(enummember, "}"), poplex, poplex)
|
||||||
|
}
|
||||||
|
function enummember() {
|
||||||
|
return pass(pattern, maybeAssign);
|
||||||
|
}
|
||||||
|
|
||||||
function isContinuedStatement(state, textAfter) {
|
function isContinuedStatement(state, textAfter) {
|
||||||
return state.lastType == "operator" || state.lastType == "," ||
|
return state.lastType == "operator" || state.lastType == "," ||
|
||||||
|
@ -761,6 +914,12 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
/[,.]/.test(textAfter.charAt(0));
|
/[,.]/.test(textAfter.charAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function expressionAllowed(stream, state, backUp) {
|
||||||
|
return state.tokenize == tokenBase &&
|
||||||
|
/^(?:operator|sof|keyword [bcd]|case|new|export|default|spread|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
||||||
|
(state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
||||||
|
}
|
||||||
|
|
||||||
// Interface
|
// Interface
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -771,7 +930,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
cc: [],
|
cc: [],
|
||||||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||||
localVars: parserConfig.localVars,
|
localVars: parserConfig.localVars,
|
||||||
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
context: parserConfig.localVars && new Context(null, null, false),
|
||||||
indented: basecolumn || 0
|
indented: basecolumn || 0
|
||||||
};
|
};
|
||||||
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
||||||
|
@ -812,7 +971,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
lexical = lexical.prev;
|
lexical = lexical.prev;
|
||||||
var type = lexical.type, closing = firstChar == type;
|
var type = lexical.type, closing = firstChar == type;
|
||||||
|
|
||||||
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
|
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info.length + 1 : 0);
|
||||||
else if (type == "form" && firstChar == "{") return lexical.indented;
|
else if (type == "form" && firstChar == "{") return lexical.indented;
|
||||||
else if (type == "form") return lexical.indented + indentUnit;
|
else if (type == "form") return lexical.indented + indentUnit;
|
||||||
else if (type == "stat")
|
else if (type == "stat")
|
||||||
|
@ -826,6 +985,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
|
||||||
blockCommentStart: jsonMode ? null : "/*",
|
blockCommentStart: jsonMode ? null : "/*",
|
||||||
blockCommentEnd: jsonMode ? null : "*/",
|
blockCommentEnd: jsonMode ? null : "*/",
|
||||||
|
blockCommentContinue: jsonMode ? null : " * ",
|
||||||
lineComment: jsonMode ? null : "//",
|
lineComment: jsonMode ? null : "//",
|
||||||
fold: "brace",
|
fold: "brace",
|
||||||
closeBrackets: "()[]{}''\"\"``",
|
closeBrackets: "()[]{}''\"\"``",
|
||||||
|
@ -835,6 +995,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||||
jsonMode: jsonMode,
|
jsonMode: jsonMode,
|
||||||
|
|
||||||
expressionAllowed: expressionAllowed,
|
expressionAllowed: expressionAllowed,
|
||||||
|
|
||||||
skipExpression: function(state) {
|
skipExpression: function(state) {
|
||||||
var top = state.cc[state.cc.length - 1]
|
var top = state.cc[state.cc.length - 1]
|
||||||
if (top == expression || top == expressionNoComma) state.cc.pop()
|
if (top == expression || top == expressionNoComma) state.cc.pop()
|
||||||
|
|
Loading…
Reference in a new issue