]> code.delx.au - gnu-emacs-elpa/blobdiff - js2-mode.el
Remove js2-current-indent
[gnu-emacs-elpa] / js2-mode.el
index 0975854315fae67128c726cbdd6b39aa3f39c3ab..348b0d1e853e0f99c0b6cc434ff8f5d090fba118 100644 (file)
@@ -2465,12 +2465,11 @@ NAME can be a Lisp symbol or string.  SYMBOL is a `js2-symbol'."
                                                      len
                                                      buffer)))
   "The root node of a js2 AST."
-  buffer             ; the source buffer from which the code was parsed
-  comments           ; a Lisp list of comments, ordered by start position
-  errors             ; a Lisp list of errors found during parsing
-  warnings           ; a Lisp list of warnings found during parsing
-  node-count         ; number of nodes in the tree, including the root
-  in-strict-mode)    ; t if the script is running under strict mode
+  buffer         ; the source buffer from which the code was parsed
+  comments       ; a Lisp list of comments, ordered by start position
+  errors         ; a Lisp list of errors found during parsing
+  warnings       ; a Lisp list of warnings found during parsing
+  node-count)    ; number of nodes in the tree, including the root
 
 (put 'cl-struct-js2-ast-root 'js2-visitor 'js2-visit-ast-root)
 (put 'cl-struct-js2-ast-root 'js2-printer 'js2-print-script)
@@ -3347,8 +3346,7 @@ The `params' field is a Lisp list of nodes.  Each node is either a simple
   ignore-dynamic   ; ignore value of the dynamic-scope flag (interpreter only)
   needs-activation ; t if we need an activation object for this frame
   generator-type   ; STAR, LEGACY, COMPREHENSION or nil
-  member-expr      ; nonstandard Ecma extension from Rhino
-  in-strict-mode)  ; t if the function is running under strict mode
+  member-expr)     ; nonstandard Ecma extension from Rhino
 
 (put 'cl-struct-js2-function-node 'js2-visitor 'js2-visit-function-node)
 (put 'cl-struct-js2-function-node 'js2-printer 'js2-print-function-node)
@@ -7984,8 +7982,7 @@ Scanner should be initialized."
            ((null directive)
             (setq in-directive-prologue nil))
            ((string= directive "use strict")
-            (setq js2-in-use-strict-directive t)
-            (setf (js2-ast-root-in-strict-mode root) t)))))
+            (setq js2-in-use-strict-directive t)))))
       ;; add function or statement to script
       (setq end (js2-node-end n))
       (js2-block-node-push root n))
@@ -8027,8 +8024,6 @@ Scanner should be initialized."
         not-in-directive-prologue
         node
         directive)
-    ;; Inherit strict mode.
-    (setf (js2-function-node-in-strict-mode fn-node) js2-in-use-strict-directive)
     (cl-incf js2-nesting-of-function)
     (unwind-protect
         (while (not (or (= (setq tt (js2-peek-token)) js2-ERROR)
@@ -8049,8 +8044,7 @@ Scanner should be initialized."
                    ;; to the function name and parameters.
                    (when (not js2-in-use-strict-directive)
                      (setq js2-in-use-strict-directive t)
-                     (throw 'reparse t))
-                   (setf (js2-function-node-in-strict-mode fn-node) t)))
+                     (throw 'reparse t))))
                  node)
              (js2-get-token)
              (js2-parse-function-stmt))))
@@ -8103,8 +8097,7 @@ NODE is either `js2-array-node', `js2-object-node', or `js2-name-node'.
 
 Return a list of `js2-name-node' nodes representing the symbols
 declared; probably to check them for errors."
-  (funcall #'js2-define-destruct-symbols-internal
-           node decl-type face ignore-not-in-block))
+  (js2-define-destruct-symbols-internal node decl-type face ignore-not-in-block))
 
 (defvar js2-illegal-strict-identifiers
   '("eval" "arguments")
@@ -8133,14 +8126,7 @@ for strict mode errors caused by PARAMS."
 
 (defun js2-parse-function-params (function-type fn-node pos)
   "Parse the parameters of a function of FUNCTION-TYPE
-represented by FN-NODE at POS.
-
-Return a list of lists of arguments to apply many times to
-`js2-check-strict-function-params' to retroactively check for
-strict mode errors that occurred.  Because the function body is
-parsed after its parameters, and the body might activate strict
-mode for that function, the check has to occur after the body is
-parsed."
+represented by FN-NODE at POS."
   (if (js2-match-token js2-RP)
       (setf (js2-function-node-rp fn-node) (- (js2-current-token-beg) pos))
     (let ((paren-free-arrow (and (eq function-type 'FUNCTION_ARROW)
@@ -9682,7 +9668,10 @@ If NODE is non-nil, it is the AST node associated with the symbol."
         ;; tt express assignment (=, |=, ^=, ..., %=)
         (setq op-pos (- (js2-current-token-beg) pos)  ; relative
               left pn)
-        (js2-check-strict-identifier left)
+        ;; The assigned node could be a js2-prop-get-node (foo.bar = 0), we only
+        ;; care about assignment to strict variable names.
+        (when (js2-name-node-p left)
+          (js2-check-strict-identifier left))
         (setq right (js2-parse-assign-expr)
               pn (make-js2-assign-node :type tt
                                        :pos pos
@@ -11316,15 +11305,6 @@ indentation is aligned to that column."
   (interactive)
   (while (forward-comment 1)))
 
-(defun js2-current-indent (&optional pos)
-  "Return column of indentation on current line.
-If POS is non-nil, go to that point and return indentation for that line."
-  (save-excursion
-    (if pos
-        (goto-char pos))
-    (back-to-indentation)
-    (current-column)))
-
 (defun js2-arglist-close ()
   "Return non-nil if we're on a line beginning with a close-paren/brace."
   (save-excursion
@@ -11379,7 +11359,7 @@ of the buffer to the current point.  NORMAL-COL is the indentation
 column computed by the heuristic guesser based on current paren,
 bracket, brace and statement nesting.  If BACKWARDS, cycle positions
 in reverse."
-  (let ((cur-indent (js2-current-indent))
+  (let ((cur-indent (current-indentation))
         (old-buffer-undo-list buffer-undo-list)
         ;; Emacs 21 only has `count-lines', not `line-number-at-pos'
         (current-line (save-excursion