+(defun js--indent-in-array-comp (bracket)
+ "Return non-nil if we think we're in an array comprehension.
+In particular, return the buffer position of the first `for' kwd."
+ (let ((end (point)))
+ (save-excursion
+ (goto-char bracket)
+ (when (looking-at "\\[")
+ (forward-char 1)
+ (js--forward-syntactic-ws)
+ (if (looking-at "[[{]")
+ (let (forward-sexp-function) ; Use Lisp version.
+ (forward-sexp) ; Skip destructuring form.
+ (js--forward-syntactic-ws)
+ (if (and (/= (char-after) ?,) ; Regular array.
+ (looking-at "for"))
+ (match-beginning 0)))
+ ;; To skip arbitrary expressions we need the parser,
+ ;; so we'll just guess at it.
+ (if (and (> end (point)) ; Not empty literal.
+ (re-search-forward "[^,]]* \\(for\\) " end t)
+ ;; Not inside comment or string literal.
+ (not (nth 8 (parse-partial-sexp bracket (point)))))
+ (match-beginning 1)))))))
+
+(defun js--array-comp-indentation (bracket for-kwd)
+ (if (js--same-line for-kwd)
+ ;; First continuation line.
+ (save-excursion
+ (goto-char bracket)
+ (forward-char 1)
+ (skip-chars-forward " \t")
+ (current-column))
+ (save-excursion
+ (goto-char for-kwd)
+ (current-column))))
+