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

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

[elpa] master 9a8aaa9 28/49: Fix length of name in namespace-import node


From: Dmitry Gutov
Subject: [elpa] master 9a8aaa9 28/49: Fix length of name in namespace-import nodes
Date: Mon, 16 Jan 2017 15:35:48 +0000 (UTC)

branch: master
commit 9a8aaa9c5ddc8f1bdef40446c45db1e218327406
Author: Mihai Bazon <address@hidden>
Commit: Mihai Bazon <address@hidden>

    Fix length of name in namespace-import nodes
    
    Should be `(- (js2-current-token-end) (js2-current-token-beg))` rather
    than just `(js2-current-token-end)`.
    
    Also change `if` to `cond` (seems easier to read in this case).
---
 js2-mode.el |   29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/js2-mode.el b/js2-mode.el
index dc86321..8fdfb0e 100644
--- a/js2-mode.el
+++ b/js2-mode.el
@@ -8654,19 +8654,22 @@ imports or a namespace import that follows it.
   "Parse a namespace import expression such as  '* as bar'.
 The current token must be js2-MUL."
   (let ((beg (js2-current-token-beg)))
-    (if (js2-match-contextual-kwd "as")
-        (when (js2-must-match-prop-name "msg.syntax")
-          (let ((node (make-js2-namespace-import-node
-                       :pos beg
-                       :len (- (js2-current-token-end) beg)
-                       :name (make-js2-name-node
-                              :pos (js2-current-token-beg)
-                              :len (js2-current-token-end)
-                              :name (js2-current-token-string)))))
-            (js2-node-add-children node (js2-namespace-import-node-name node))
-            node))
-      (js2-unget-token)
-      (js2-report-error "msg.syntax"))))
+    (cond
+      ((and (js2-match-contextual-kwd "as")
+            (js2-must-match-prop-name "msg.syntax"))
+       (let ((node (make-js2-namespace-import-node
+                    :pos beg
+                    :len (- (js2-current-token-end) beg)
+                    :name (make-js2-name-node
+                           :pos (js2-current-token-beg)
+                           :len (- (js2-current-token-end)
+                                   (js2-current-token-beg))
+                           :name (js2-current-token-string)))))
+         (js2-node-add-children node (js2-namespace-import-node-name node))
+         node))
+      (t
+       (js2-unget-token)
+       (js2-report-error "msg.syntax")))))
 
 
 (defun js2-parse-from-clause ()



reply via email to

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