emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master de6df33 049/110: Fix semicolons and scoping in exported de


From: Dmitry Gutov
Subject: [elpa] master de6df33 049/110: Fix semicolons and scoping in exported decls
Date: Thu, 23 Jun 2016 01:12:56 +0000 (UTC)

branch: master
commit de6df3366977b610007e126945adf8967cce83c3
Author: David Greenspan <address@hidden>
Commit: David Greenspan <address@hidden>

    Fix semicolons and scoping in exported decls
    
    In the following code, no semicolons should be considered missing,
    and all of A,B,C,D should be considered declared.
    
    ```
    export function A() {}
    export class B {}
    export default function C() {}
    export default class D {}
    
    var x = [A, B, C, D];
    ```
---
 js2-mode.el |   16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index c7af462..c98c00d 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -8842,20 +8842,30 @@ invalid export statements."
               (setq from-clause (js2-parse-from-clause)))
           (js2-unget-token))))
      ((js2-match-token js2-DEFAULT)
-      (setq default (js2-parse-expr)))
+      (setq default (cond ((js2-match-token js2-CLASS)
+                           (js2-parse-class-stmt))
+                          ((js2-match-token js2-FUNCTION)
+                           (js2-parse-function-stmt))
+                          (t (js2-parse-expr)))))
      ((or (js2-match-token js2-VAR) (js2-match-token js2-CONST) 
(js2-match-token js2-LET))
       (setq declaration (js2-parse-variables (js2-current-token-type) 
(js2-current-token-beg))))
+     ((js2-match-token js2-CLASS)
+      (setq declaration (js2-parse-class-stmt)))
+     ((js2-match-token js2-FUNCTION)
+      (setq declaration (js2-parse-function-stmt)))
      (t
       (setq declaration (js2-parse-expr))))
     (when from-clause
       (push from-clause children))
     (when declaration
       (push declaration children)
-      (when (not (js2-function-node-p declaration))
+      (when (not (or (js2-function-node-p declaration)
+                     (js2-class-node-p declaration)))
         (js2-auto-insert-semicolon declaration)))
     (when default
       (push default children)
-      (when (not (js2-function-node-p default))
+      (when (not (or (js2-function-node-p default)
+                     (js2-class-node-p default)))
         (js2-auto-insert-semicolon default)))
     (let ((node (make-js2-export-node
                   :pos beg



reply via email to

[Prev in Thread] Current Thread [Next in Thread]