]> code.delx.au - gnu-emacs-elpa/blobdiff - js2-mode.el
Merge pull request #332 from bolivier/master
[gnu-emacs-elpa] / js2-mode.el
index ed0ff689eef10404aafc899c4b812846240b60ec..238440c8f7a7f3582e44019f0ff5f8d180523e9b 100644 (file)
@@ -1456,7 +1456,7 @@ the correct number of ARGS must be provided."
          "Compilation produced %s syntax errors.")
 
 (js2-msg "msg.var.redecl"
-         "TypeError: redeclaration of var %s.")
+         "Redeclaration of var %s.")
 
 (js2-msg "msg.const.redecl"
          "TypeError: redeclaration of const %s.")
@@ -7264,7 +7264,7 @@ are ignored."
            when (and (eq 'block (js2-comment-node-format node))
                      (save-excursion
                        (goto-char (js2-node-abs-pos node))
-                       (looking-at "/\\*global ")))
+                       (looking-at "/\\* *global ")))
            append (js2-get-jslint-globals-in
                    (match-end 0)
                    (js2-node-abs-end node))))
@@ -8100,11 +8100,19 @@ declared; probably to check them for errors."
       (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).
-        (when (js2-infix-node-p elem)
+        (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)))
+                name-nodes))))
       (apply #'append (nreverse name-nodes)))
      ((js2-array-node-p node)
       (dolist (elem (js2-array-node-elems node))
@@ -8599,7 +8607,7 @@ imports or a namespace import that follows it.
               (js2-define-symbol
                js2-LET (js2-name-node-name name-node) name-node t))))))
      ((= (js2-peek-token) js2-NAME)
-      (let ((binding (js2-maybe-parse-export-binding)))
+      (let ((binding (js2-maybe-parse-export-binding t)))
         (let ((node-name (js2-export-binding-node-local-name binding)))
           (js2-define-symbol js2-LET (js2-name-node-name node-name) node-name t))
         (setf (js2-import-clause-node-default-binding clause) binding)
@@ -8680,7 +8688,7 @@ The current token must be js2-MUL."
 js2-LC. Return a lisp list of js2-export-binding-node"
   (let ((bindings (list)))
     (while
-        (let ((binding (js2-maybe-parse-export-binding)))
+        (let ((binding (js2-maybe-parse-export-binding import-p)))
           (when binding
             (push binding bindings))
           (js2-match-token js2-COMMA)))
@@ -8689,7 +8697,7 @@ js2-LC. Return a lisp list of js2-export-binding-node"
                                    "msg.mod.rc.after.export.spec.list"))
       (reverse bindings))))
 
-(defun js2-maybe-parse-export-binding ()
+(defun js2-maybe-parse-export-binding (&optional import-p)
   "Attempt to parse a binding expression found inside an import/export statement.
 This can take the form of either as single js2-NAME token as in 'foo' or as in a
 rebinding expression 'bar as foo'. If it matches, it will return an instance of
@@ -8722,6 +8730,9 @@ consumes no tokens."
                      node
                      (js2-export-binding-node-local-name node)
                      (js2-export-binding-node-extern-name node))
+                    (if import-p
+                        (js2-set-face (js2-current-token-beg) (js2-current-token-end)
+                                      'font-lock-variable-name-face 'record))
                     node)
                 (js2-unget-token)
                 nil))
@@ -8737,6 +8748,9 @@ consumes no tokens."
             (when is-reserved-name
               (js2-report-error "msg.mod.as.after.reserved.word" extern-name))
             (js2-node-add-children node name-node)
+            (if import-p
+                (js2-set-face (js2-current-token-beg) (js2-current-token-end)
+                              'font-lock-variable-name-face 'record))
             node))
       nil)))