Skip to content

Commit b8c8a3e

Browse files
committed
[javascript mode] Remove support for array/iterator comprehension
1 parent 31eb1b2 commit b8c8a3e

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

mode/javascript/javascript.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
387387
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
388388
if (type == "function") return cont(functiondef, maybeop);
389389
if (type == "keyword c" || type == "async") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
390-
if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
390+
if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeop);
391391
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
392392
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
393393
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
@@ -641,16 +641,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
641641
}
642642
function arrayLiteral(type) {
643643
if (type == "]") return cont();
644-
return pass(expressionNoComma, maybeArrayComprehension);
645-
}
646-
function maybeArrayComprehension(type) {
647-
if (type == "for") return pass(comprehension, expect("]"));
648-
if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
649-
return pass(commasep(expressionNoComma, "]"));
650-
}
651-
function comprehension(type) {
652-
if (type == "for") return cont(forspec, comprehension);
653-
if (type == "if") return cont(expression, comprehension);
644+
return pass(expressionNoComma, commasep(expressionNoComma, "]"));
654645
}
655646

656647
function isContinuedStatement(state, textAfter) {

mode/javascript/test.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@
7878
" [variable something]([variable-2 a], [meta ...][variable-2 b]);",
7979
"}");
8080

81-
MT("comprehension",
82-
"[keyword function] [def f]() {",
83-
" [[([variable x] [operator +] [number 1]) [keyword for] ([keyword var] [def x] [keyword in] [variable y]) [keyword if] [variable pred]([variable-2 x]) ]];",
84-
" ([variable u] [keyword for] ([keyword var] [def u] [keyword of] [variable generateValues]()) [keyword if] ([variable-2 u].[property color] [operator ===] [string 'blue']));",
85-
"}");
86-
8781
MT("quasi",
8882
"[variable re][string-2 `fofdlakj${][variable x] [operator +] ([variable re][string-2 `foo`]) [operator +] [number 1][string-2 }fdsa`] [operator +] [number 2]");
8983

0 commit comments

Comments
 (0)