]> code.delx.au - gnu-emacs-elpa/commitdiff
Merge branch 'let-temporal-dz'
authorDmitry Gutov <dgutov@yandex.ru>
Mon, 2 Feb 2015 03:25:10 +0000 (05:25 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Mon, 2 Feb 2015 03:25:10 +0000 (05:25 +0200)
1  2 
js2-mode.el

diff --combined js2-mode.el
index 6ab7cb90b6a8889a2b992a5b7b815b5d506b0704,bef5e617f757794d3182fe95956df6a975c9b3dd..2fd0630192c3fc12746970924ad889d651ecc117
@@@ -1,13 -1,13 +1,13 @@@
  ;;; js2-mode.el --- Improved JavaScript editing mode
  
 -;; Copyright (C) 2009, 2011-2014  Free Software Foundation, Inc.
 +;; Copyright (C) 2009, 2011-2015  Free Software Foundation, Inc.
  
  ;; Author: Steve Yegge <steve.yegge@gmail.com>
  ;;         mooz <stillpedant@gmail.com>
  ;;         Dmitry Gutov <dgutov@yandex.ru>
  ;; URL:  https://github.com/mooz/js2-mode/
  ;;       http://code.google.com/p/js2-mode/
 -;; Version: 20141118
 +;; Version: 20150202
  ;; Keywords: languages, javascript
  ;; Package-Requires: ((emacs "24.1") (cl-lib "0.5"))
  
@@@ -2313,19 -2313,25 +2313,25 @@@ Returns nil if there is no enclosing sc
        (setq parent (js2-node-parent parent)))
      parent))
  
- (defun js2-get-defining-scope (scope name)
+ (defun js2-get-defining-scope (scope name &optional point)
    "Search up scope chain from SCOPE looking for NAME, a string or symbol.
- Returns `js2-scope' in which NAME is defined, or nil if not found."
+ Returns `js2-scope' in which NAME is defined, or nil if not found.
+ If POINT is non-nil, and if the found declaration type is
+ `js2-LET', also check that the declaration node is before POINT."
    (let ((sym (if (symbolp name)
                   name
                 (intern name)))
-         table
          result
          (continue t))
      (while (and scope continue)
        (if (or
-            (and (setq table (js2-scope-symbol-table scope))
-                 (assq sym table))
+            (let ((entry (cdr (assq sym (js2-scope-symbol-table scope)))))
+              (and entry
+                   (or (not point)
+                       (not (eq js2-LET (js2-symbol-decl-type entry)))
+                       (>= point
+                           (js2-node-abs-pos (js2-symbol-ast-node entry))))))
             (and (eq sym 'arguments)
                  (js2-function-node-p scope)))
            (setq continue nil
@@@ -7034,7 -7040,7 +7040,7 @@@ it is considered declared.
          (unless (or (member name js2-global-externs)
                      (member name js2-default-externs)
                      (member name js2-additional-externs)
-                     (js2-get-defining-scope scope name))
+                     (js2-get-defining-scope scope name pos))
            (js2-report-warning "msg.undeclared.variable" name pos (- end pos)
                                'js2-external-variable))))
      (setq js2-recorded-identifiers nil)))