| Index: third_party/WebKit/Source/devtools/front_end/cm_web_modes/javascript.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/cm_web_modes/javascript.js b/third_party/WebKit/Source/devtools/front_end/cm_web_modes/javascript.js
|
| index a717745897415d1cc465d8c9382dce0a620a00b2..3f614cc2c5f1617d993409a81dbd02bd46a18d60 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/cm_web_modes/javascript.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/cm_web_modes/javascript.js
|
| @@ -12,7 +12,7 @@
|
| "use strict";
|
|
|
| function expressionAllowed(stream, state, backUp) {
|
| - return /^(?:operator|sof|keyword c|case|new|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
| + return /^(?:operator|sof|keyword c|case|new|export|default|[\[{}\(,;:]|=>)$/.test(state.lastType) ||
|
| (state.lastType == "quasi" && /\{\s*$/.test(stream.string.slice(0, stream.pos - (backUp || 0))))
|
| }
|
|
|
| @@ -146,7 +146,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| stream.skipToEnd();
|
| return ret("error", "error");
|
| } else if (isOperatorChar.test(ch)) {
|
| - stream.eatWhile(isOperatorChar);
|
| + if (ch != ">" || !state.lexical || state.lexical.type != ">")
|
| + stream.eatWhile(isOperatorChar);
|
| return ret("operator", "operator", stream.current());
|
| } else if (wordRE.test(ch)) {
|
| stream.eatWhile(wordRE);
|
| @@ -504,9 +505,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| if (type == ":") return cont(expressionNoComma);
|
| if (type == "(") return pass(functiondef);
|
| }
|
| - function commasep(what, end) {
|
| + function commasep(what, end, sep) {
|
| function proceed(type, value) {
|
| - if (type == ",") {
|
| + if (sep ? sep.indexOf(type) > -1 : type == ",") {
|
| var lex = cx.state.lexical;
|
| if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
| return cont(function(type, value) {
|
| @@ -539,16 +540,19 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| }
|
| function typeexpr(type) {
|
| if (type == "variable") {cx.marked = "variable-3"; return cont(afterType);}
|
| - if (type == "{") return cont(commasep(typeprop, "}"))
|
| + if (type == "string" || type == "number" || type == "atom") return cont(afterType);
|
| + if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex)
|
| if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType)
|
| }
|
| function maybeReturnType(type) {
|
| if (type == "=>") return cont(typeexpr)
|
| }
|
| - function typeprop(type) {
|
| + function typeprop(type, value) {
|
| if (type == "variable" || cx.style == "keyword") {
|
| cx.marked = "property"
|
| return cont(typeprop)
|
| + } else if (value == "?") {
|
| + return cont(typeprop)
|
| } else if (type == ":") {
|
| return cont(typeexpr)
|
| }
|
| @@ -558,7 +562,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| else if (type == ":") return cont(typeexpr)
|
| }
|
| function afterType(type, value) {
|
| - if (value == "<") return cont(commasep(typeexpr, ">"), afterType)
|
| + if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, afterType)
|
| + if (value == "|" || type == ".") return cont(typeexpr)
|
| if (type == "[") return cont(expect("]"), afterType)
|
| }
|
| function vardef() {
|
| @@ -629,12 +634,14 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| if (type == "variable") {register(value); return cont(classNameAfter);}
|
| }
|
| function classNameAfter(type, value) {
|
| - if (value == "extends" || value == "implements") return cont(isTS ? typeexpr : expression, classNameAfter);
|
| + if (value == "<") return cont(pushlex(">"), commasep(typeexpr, ">"), poplex, classNameAfter)
|
| + if (value == "extends" || value == "implements" || (isTS && type == ","))
|
| + return cont(isTS ? typeexpr : expression, classNameAfter);
|
| if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
| }
|
| function classBody(type, value) {
|
| if (type == "variable" || cx.style == "keyword") {
|
| - if ((value == "static" || value == "get" || value == "set" ||
|
| + if ((value == "async" || value == "static" || value == "get" || value == "set" ||
|
| (isTS && (value == "public" || value == "private" || value == "protected" || value == "readonly" || value == "abstract"))) &&
|
| cx.stream.match(/^\s+[\w$\xa1-\uffff]/, false)) {
|
| cx.marked = "keyword";
|
| @@ -643,6 +650,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| cx.marked = "property";
|
| return cont(isTS ? classfield : functiondef, classBody);
|
| }
|
| + if (type == "[")
|
| + return cont(expression, expect("]"), isTS ? classfield : functiondef, classBody)
|
| if (value == "*") {
|
| cx.marked = "keyword";
|
| return cont(classBody);
|
| @@ -653,16 +662,22 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| function classfield(type, value) {
|
| if (value == "?") return cont(classfield)
|
| if (type == ":") return cont(typeexpr, maybeAssign)
|
| + if (value == "=") return cont(expressionNoComma)
|
| return pass(functiondef)
|
| }
|
| - function afterExport(_type, value) {
|
| + function afterExport(type, value) {
|
| if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
| if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
| + if (type == "{") return cont(commasep(exportField, "}"), maybeFrom, expect(";"));
|
| 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) {
|
| if (type == "string") return cont();
|
| - return pass(importSpec, maybeFrom);
|
| + return pass(importSpec, maybeMoreImports, maybeFrom);
|
| }
|
| function importSpec(type, value) {
|
| if (type == "{") return contCommasep(importSpec, "}");
|
| @@ -670,6 +685,9 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
| if (value == "*") cx.marked = "keyword";
|
| return cont(maybeAs);
|
| }
|
| + function maybeMoreImports(type) {
|
| + if (type == ",") return cont(importSpec, maybeMoreImports)
|
| + }
|
| function maybeAs(_type, value) {
|
| if (value == "as") { cx.marked = "keyword"; return cont(importSpec); }
|
| }
|
|
|