]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge branch 'dgreensp-object-rest-spread'
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 29 May 2016 00:06:57 +0000 (03:06 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 29 May 2016 00:06:57 +0000 (03:06 +0300)
1  2 
js2-mode.el
tests/parser.el

diff --cc js2-mode.el
index 238440c8f7a7f3582e44019f0ff5f8d180523e9b,22442b96f976d3b7608e16e2c2e4d91251598481..4d9bbf8da02e85ea35cb873dcb0bb879874c4951
@@@ -8098,21 -8069,20 +8099,25 @@@ declared; probably to check them for er
          (list node)))
       ((js2-object-node-p node)
        (dolist (elem (js2-object-node-elems node))
-         ;; js2-infix-node-p catches both object prop node and initialized
-         ;; binding element (which is directly an infix node).
-         (cond
-          ((js2-object-prop-node-p elem)
-           (push (js2-define-destruct-symbols
-                  ;; In abbreviated destructuring {a, b}, right == left.
-                  (js2-object-prop-node-right elem)
-                  decl-type face ignore-not-in-block)
-                 name-nodes))
-          ;; Destructuring with default argument.
-          ((js2-infix-node-p elem)
-           (push (js2-define-destruct-symbols
-                  (js2-infix-node-left elem)
-                  decl-type face ignore-not-in-block)
-                 name-nodes))))
+         (let ((subexpr (cond
+                         ((and (js2-infix-node-p elem)
+                               (= js2-ASSIGN (js2-infix-node-type elem)))
++                         ;; Destructuring with default argument.
+                          (js2-infix-node-left elem))
+                         ((and (js2-infix-node-p elem)
+                               (= js2-COLON (js2-infix-node-type elem)))
++                         ;; In regular destructuring {a: aa, b: bb},
++                         ;; the var is on the right.  In abbreviated
++                         ;; destructuring {a, b}, right == left.
+                          (js2-infix-node-right elem))
+                         ((and (js2-unary-node-p elem)
+                               (= js2-TRIPLEDOT (js2-unary-node-type elem)))
++                         ;; Destructuring with spread.
+                          (js2-unary-node-operand elem)))))
+           (when subexpr
+             (push (js2-define-destruct-symbols
+                    subexpr decl-type face ignore-not-in-block)
+                   name-nodes))))
        (apply #'append (nreverse name-nodes)))
       ((js2-array-node-p node)
        (dolist (elem (js2-array-node-elems node))
@@@ -10782,10 -10755,16 +10790,16 @@@ expression).
            (setq previous-token (js2-current-token)
                  tt (js2-get-prop-name-token))))
        (cond
-        ;; Found a property (of any sort)
+        ;; Rest/spread (...expr)
+        ((and (>= js2-language-version 200)
+              (not class-p) (not static) (not previous-token)
+              (= js2-TRIPLEDOT tt))
+         (setq after-comma nil
+               elem (js2-make-unary js2-TRIPLEDOT 'js2-parse-assign-expr)))
+        ;; Found a key/value property (of any sort)
         ((member tt (list js2-NAME js2-STRING js2-NUMBER js2-LB))
          (setq after-comma nil
 -              elem (js2-parse-named-prop tt pos previous-token))
 +              elem (js2-parse-named-prop tt previous-token))
          (if (and (null elem)
                   (not js2-recover-from-parse-errors))
              (setq continue nil)))
diff --cc tests/parser.el
Simple merge