(defun dojo-js-inspect-print-inspect-path-at-point () (interactive) (let ((inspect-path (dojo-js-inspect-get-inspect-path-at-point))) (dojo-js-inspect-print-inspect-path inspect-path))) (defun dojo-js-inspect-get-inspect-path-at-point () (dojo-js-inspect-get-inspect-path (point))) (defun dojo-js-inspect-get-inspect-path (position) "Returns the inspect path for the given position. The inspect path is a list of dojo-inspect-token instances. The node of a dojo-inspect-token matches the respective item of the ancestor-path." (log-inspect (format "Called get-inspect-path for position [%s]" position)) (let* ((workspace dojo-current-workspace) (resource (dojo-core-util-get-current-resource)) (class (dojo-core-util-get-or-load-class workspace resource)) (ancestor-path (dojo-get-ancestor-path)) (ancestor-index 0) (inspect-path ())) ; Debug (dojo-js-inspect-print-ancestor-path ancestor-path) (dolist (ancestor-token ancestor-path) (push (construct-dojo-inspect-token ancestor-token nil) inspect-path)) (setq inspect-path (nreverse inspect-path)) (cond ((null resource) (log-inspect "[WARNING] resource is nil, will do nothing.")) ((null class) (log-inspect (format "[WARNING] Class for resource [%s:%s] is nil, will do nothing." (dojo-resource-project resource) (dojo-resource-path resource))) nil) (; Dive down the ancestor path by recursively calling appropriate functions. (and class (dojo-is-ancestor-of-type ancestor-path ancestor-index "js2-ast-root")) (log-inspect (format "Will inspect for class [%s]" (dojo-class-id class))) (log-inspect (format "... [prj:path] = [%s:%s]" (dojo-resource-project resource) (dojo-resource-path resource))) (log-inspect "=============================") (dojo-js-inspect-inspect-root inspect-path ancestor-path ancestor-index class) inspect-path) (t (log-inspect "[WARNING] No class found, or head of ancestor-path is no [js2-ast-root], will do nothing."))))) (defun dojo-js-inspect-inspect-root (inspect-path ancestor-path ancestor-index class) (log-inspect (format "[%s] Called inspect-root" ancestor-index)) (cond ((dojo-is-call-expr-in-ancestor-path ancestor-path (1+ ancestor-index) "define") (dojo-js-inspect-inspect-define-call inspect-path ancestor-path (+ ancestor-index 2) class)) (t (log-inspect "[WARNING] Did not find the define call.")))) (defun dojo-js-inspect-inspect-define-call (inspect-path ancestor-path ancestor-index class) (log-inspect (format "[%s] Called inspect-define-call" ancestor-index)) (let* ((next-ancestor-node (nth (1+ ancestor-index) ancestor-path))) ; According to the define function specification (see https://github.com/amdjs/amdjs-api/blob/master/AMD.md), ; the first parameter is an (optional) string literal, the second a (optional) array, and the third a function. ; Thus, the node type is sufficient for deciding what to do here. (cond ((dojo-has-node-type next-ancestor-node "js2-array-node") (dojo-js-inspect-inspect-import-path inspect-path ancestor-path (1+ ancestor-index) class)) ((dojo-has-node-type next-ancestor-node "js2-function-node") (dojo-js-inspect-inspect-define-function inspect-path ancestor-path (1+ ancestor-index) class)) (t (log-inspect (format "[WARNING] Unsupported case of inspect-define-call, next-ancestor-node is [%s]" (js2-node-short-name next-ancestor-node))))))) (defun dojo-js-inspect-inspect-import-path (inspect-path ancestor-path ancestor-index class) (log-inspect (format "[%s] Called inspect-import-path" ancestor-index)) (let* ((next-ancestor-node (nth (1+ ancestor-index) ancestor-path))) (cond ((dojo-has-node-type next-ancestor-node "js2-string-node") (let* ((path (dojo-get-string-from-string-node next-ancestor-node)) (define-symbol (dojo-class-define-symbol class)) (argument-symbols (if define-symbol (dojo-symbol-get-function-arguments define-symbol) nil))) (dolist (argument-symbol argument-symbols) (let ((arg-symbol-path (dojo-symbol-get-import-path argument-symbol))) (if (string= arg-symbol-path path) (progn (dojo-js-inspect-set-inspect-path-symbol inspect-path (1+ ancestor-index) argument-symbol) (return nil))))))) (t (log-inspect (format "[WARNING] inspect-import-path called for unsupported node [%s]" (js2-node-short-name next-ancestor-node))))))) (defun dojo-js-inspect-inspect-define-function (inspect-path ancestor-path ancestor-index class) (log-inspect (format "[%s] Called inspect-define-function" ancestor-index)) (let* ((define-symbol (dojo-class-define-symbol class)) (next-ancestor-node (nth (1+ ancestor-index) ancestor-path)) (define-function-node (nth ancestor-index ancestor-path)) (body-node (js2-function-node-body define-function-node)) (param-nodes (js2-function-node-params define-function-node))) (if (null define-symbol) (log-inspect (format "[WARNING] define-symbol of class [%s:%s:%s:%s] is nil." (dojo-class-id class) (dojo-class-project class) (dojo-class-path class) (dojo-class-is-api-class class)))) (dojo-js-inspect-set-inspect-path-symbol inspect-path ancestor-index define-symbol) (cond ((eq next-ancestor-node body-node) (let ((define-symbol (dojo-class-define-symbol class)) (scopes ()) (defined-symbols (make-hash-table :test 'equal))) ; Deliberately call with ancestor-index, as we need to do some function-general work first (dojo-js-inspect-inspect-function inspect-path define-symbol nil ancestor-path ancestor-index defined-symbols scopes class))) (t (dolist (param-node param-nodes) (if (eq next-ancestor-node param-node) (progn (cond ((dojo-has-node-type param-node "js2-name-node") (let* ((param-name (dojo-get-name-from-name-node param-node)) (argument-symbols (if define-symbol (dojo-symbol-get-function-arguments define-symbol) nil))) (dolist (argument-symbol argument-symbols) (if (string= param-name (dojo-symbol-name argument-symbol)) (progn (dojo-js-inspect-set-inspect-path-symbol inspect-path (1+ ancestor-index) argument-symbol) (return nil)))))) (t (log-inspect (format "[WARNING] inspect-define-function found unsupported parameter type [%s]" (js2-node-short-name param-node))))) (return nil)))))))) (defvar dojo-js-inspect-call-table #s(hash-table test equal data ( "js2-assign-node" dojo-js-inspect-move-forward "js2-array-node" dojo-js-inspect-move-forward "js2-block-node" dojo-js-inspect-inspect-block "js2-call-node" dojo-js-inspect-inspect-call "js2-cond-node" dojo-js-inspect-move-forward "js2-expr-stmt-node" dojo-js-inspect-inspect-expr-stmt "js2-for-node" dojo-js-inspect-inspect-for ; "js2-function-node" dojo-js-inspect-inspect-function "js2-function-node" dojo-js-inspect-move-forward ; TODO: Properly recognize parameters of anonymous functions "js2-if-node" dojo-js-inspect-move-forward "js2-infix-node" dojo-js-inspect-move-forward "js2-name-node" dojo-js-inspect-inspect-name "js2-new-node" dojo-js-inspect-inspect-new "js2-object-node" dojo-js-inspect-inspect-object-without-symbol "js2-prop-get-node" dojo-js-inspect-inspect-prop-get "js2-return-node" dojo-js-inspect-move-forward "js2-scope" dojo-js-inspect-inspect-block "js2-var-decl-node" dojo-js-inspect-inspect-var-decl))) (defun dojo-js-inspect-inspect-node (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (let ((node (nth ancestor-index ancestor-path))) (cond ((null node) (log-inspect (format "[WARNING] Did not find a node at ancestor-index [%s] of ancestor-path." ancestor-index))) (t (let* ((fct (gethash (js2-node-short-name node) dojo-js-inspect-call-table))) (if fct (funcall fct inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[WARNING] dojo-inspect-inspect-node found unsupported node type [%s]" (js2-node-short-name node))))))))) (defun dojo-js-inspect-move-forward (inspect-path ancestor-path ancestor-index defined-symbols scopes class) "Default function to be called by dojo-js-inspect-inspect-node if for some particular node type no special work at all needs to be done." (log-inspect (format "[%s] Called move-forward for node type [%s]" ancestor-index (js2-node-short-name (nth ancestor-index ancestor-path)))) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)) (defun dojo-js-inspect-inspect-assign (inspect-path ancestor-path ancestor-index defined-symbols scopes class) ) (defun dojo-js-inspect-inspect-block (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-block" ancestor-index)) (let* ((block-node (nth ancestor-index ancestor-path)) (child-nodes (js2-block-node-kids block-node)) (ref-child (nth (1+ ancestor-index) ancestor-path))) ; Step over nodes in range [, [. ; Add all variable names defined here to defined-symbols. ; This is to allow subsequent code to decide wether a particular symbol was defined before point, or ; at some point later in source code. In the latter case, the symbol might still be in the function ; scope set up while parsing the class. (dojo-js-completion-add-defined-symbols defined-symbols child-nodes ref-child 0) ; Proceed to higher ancestor-index of ancestor-path (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class))) (defun dojo-js-inspect-inspect-call (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-call" ancestor-index)) (let* ((next-ancestor-node (nth (1+ ancestor-index) ancestor-path)) (call-node (nth ancestor-index ancestor-path)) (target-node (js2-call-node-target call-node)) (arg-nodes (js2-call-node-args call-node))) (cond ((and (dojo-has-node-type target-node "js2-name-node") (string= (dojo-get-name-from-name-node target-node) "declare")) (cond ((eq next-ancestor-node (nth 0 arg-nodes)) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)) ((eq next-ancestor-node (nth 1 arg-nodes)) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)) ((eq next-ancestor-node (nth 2 arg-nodes)) (cond ((dojo-has-node-type next-ancestor-node "js2-object-node") (let ((this-symbol (dojo-class-this-symbol class))) (dojo-js-inspect-inspect-object inspect-path this-symbol ancestor-path (1+ ancestor-index) defined-symbols scopes class))) (t (log-inspect (format "[WARNING] Unsupported node type [%s] of third argument of declare call node." (js2-node-short-name next-ancestor-node)))))) (t (log-inspect (format "[WARNING] Unsupported case when processing the declare node; (length arg-nodes) is [%s]" (length arg-nodes)))))) (t (let* ((fct-symbol (dojo-js-completion-get-node-symbol defined-symbols scopes 0 target-node nil))) (log-inspect (format "... Resolved fct-symbol [%s] for target-node ([%s] to [%s]) of type [%s]" (dojo-core-util-symbol-to-short-string fct-symbol) (if target-node (js2-node-abs-pos target-node) "---") (if target-node (js2-node-abs-end target-node) "---") (if target-node (js2-node-short-name target-node) "---"))) (dojo-js-inspect-set-inspect-path-symbol inspect-path ancestor-index fct-symbol) (cond ((eq next-ancestor-node target-node) (dojo-js-inspect-set-inspect-path-symbol inspect-path (1+ ancestor-index) fct-symbol) (dojo-js-inspect-inspect-node inspect-path ancestor-path (+ ancestor-index 2) defined-symbols scopes class)) (t (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)))))))) (defun dojo-js-inspect-inspect-expr-stmt (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-expr-stmt" ancestor-index)) (let* ((child-node (nth (1+ ancestor-index) ancestor-path))) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class))) (defun dojo-js-inspect-inspect-for (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-for" ancestor-index)) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)) (defun dojo-js-inspect-inspect-function (inspect-path function-symbol this-symbol ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-function" ancestor-index)) (let* ((next-ancestor-node (nth (1+ ancestor-index) ancestor-path)) (function-node (nth ancestor-index ancestor-path)) (body-node (js2-function-node-body function-node))) (cond ((eq next-ancestor-node body-node) (if this-symbol (puthash "this" t defined-symbols)) (let* ((argument-scope (if function-symbol (dojo-js-completion-construct-function-arguments-scope function-symbol this-symbol) nil)) (body-scope (if function-symbol (dojo-js-completion-construct-function-body-scope function-symbol 0) nil)) (argument-scopes (if argument-scope (append (list argument-scope) scopes) scopes)) (body-scopes (if body-scope (append (list body-scope) argument-scopes) argument-scopes))) ; Add all symbols from the function arguments to the defined-symbols set. (if function-symbol (progn (dojo-js-completion-add-defined-scope-symbols 1 defined-symbols argument-scope) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols body-scopes class)) (log-inspect (format "[WARNING] Found no function-symbol for function-node (%s to %s)" (js2-node-abs-pos function-node) (js2-node-abs-end function-node)))))) (t (log-inspect (format "[WARNING] Unsupported child node [%s] of function-node." (js2-node-short-name next-ancestor-node))))))) (defun dojo-js-inspect-inspect-if (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-if" ancestor-index)) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)) (defun dojo-js-inspect-inspect-name (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-name" ancestor-index)) (let* ((before-node (nth (1- ancestor-index) ancestor-path)) (name-node (nth ancestor-index ancestor-path))) (cond ((dojo-has-node-type before-node "js2-new-node") (let ((name-symbol (dojo-js-completion-get-node-symbol defined-symbols scopes 0 name-node))) (if (and name-symbol (dojo-core-util-is-import-symbol name-symbol)) (progn (dojo-js-api-get-class-by-import-symbol name-symbol) (let* ((constructor-symbol (dojo-core-util-get-member-by-import-symbol dojo-current-workspace name-symbol "constructor")) (this-symbol (if constructor-symbol nil (dojo-core-util-get-this-by-import-symbol dojo-current-workspace name-symbol)))) (if constructor-symbol (dojo-js-inspect-set-inspect-path-symbol inspect-path ancestor-index constructor-symbol) (dojo-js-inspect-set-inspect-path-symbol inspect-path ancestor-index this-symbol))))))) ((dojo-has-node-type before-node "js2-prop-get-node") (let ((prop-get-right-node (js2-infix-node-right before-node))) (cond ((eq name-node prop-get-right-node) (let* ((before-token (nth (1- ancestor-index) inspect-path)) (before-symbol (if before-token (dojo-inspect-token-symbol before-token) nil)) (before-hint (if before-token (dojo-inspect-token-hint before-token) nil))) (if before-symbol (dojo-js-inspect-set-inspect-path-symbol inspect-path ancestor-index before-symbol before-hint))))))) (t (let ((name-symbol (dojo-js-completion-get-node-symbol defined-symbols scopes 0 name-node))) (dojo-js-inspect-set-inspect-path-symbol inspect-path ancestor-index name-symbol)))))) (defun dojo-js-inspect-inspect-new (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-new" ancestor-index)) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)) (defun dojo-js-inspect-inspect-object-without-symbol (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (dojo-js-inspect-inspect-object inspect-path nil ancestor-path ancestor-index defined-symbols scopes class)) (defun dojo-js-inspect-inspect-object (inspect-path object-symbol ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-object" ancestor-index)) (if (and object-symbol (not (dojo-core-util-is-object-symbol object-symbol))) (progn (log-inspect (format "[WARNING] inspect-object received non-object symbol %s; will ignore it." (dojo-core-util-symbol-to-short-string object-symbol))) (setq object-symbol nil))) (let ((next-ancestor-node (nth (1+ ancestor-index) ancestor-path))) (cond ((dojo-has-node-type next-ancestor-node "js2-object-prop-node") (dojo-js-inspect-inspect-object-prop inspect-path object-symbol ancestor-path (1+ ancestor-index) defined-symbols scopes class)) (t (log-inspect (format "[WARNING] Unsupported child node [%s] of object-node." (js2-node-short-name next-ancestor-node))))))) (defun dojo-js-inspect-inspect-object-prop (inspect-path object-symbol ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-object-prop" ancestor-index)) (let* ((next-ancestor-node (nth (1+ ancestor-index) ancestor-path)) (object-prop-node (nth ancestor-index ancestor-path)) (left-node (js2-infix-node-left object-prop-node)) (right-node (js2-infix-node-right object-prop-node))) (cond ((eq right-node next-ancestor-node) (cond ((dojo-has-node-type next-ancestor-node "js2-name-node") (dojo-js-completion-add-candidates-if-prefix (1+ level) prefix (list "function" "new")) (dojo-js-completion-add-defined-symbols-candidates-if-prefix defined-symbols scopes level prefix)) ((dojo-has-node-type next-ancestor-node "js2-function-node") (let ((function-symbol (if object-symbol (dojo-js-completion-get-object-prop-symbol object-symbol object-prop-node) nil))) (cond ((and function-symbol (dojo-core-util-is-function-symbol function-symbol)) (dojo-js-inspect-inspect-function inspect-path function-symbol object-symbol ancestor-path (1+ ancestor-index) defined-symbols scopes class)) (t (log-inspect (format "[WARNING] inspect-object-prop, case function: Did not receive a function-symbol, but %s" (dojo-core-util-symbol-to-short-string function-symbol))))))) (t (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)))) (t (log-inspect (format "[WARNING] Unsupported case in inspect-object-prop")))))) (defun dojo-js-inspect-inspect-prop-get (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-prop-get" ancestor-index)) (let* ((prop-get-node (nth ancestor-index ancestor-path)) (prop-get-symbol-with-hint (dojo-js-inspect-get-prop-get-symbol defined-symbols scopes 0 prop-get-node)) (prop-get-symbol (nth 0 prop-get-symbol-with-hint)) (hint (nth 1 prop-get-symbol-with-hint))) (dojo-js-inspect-set-inspect-path-symbol inspect-path ancestor-index prop-get-symbol hint) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class))) (defun dojo-js-inspect-get-prop-get-symbol (defined-symbols scopes level node &optional max-abs-pos) (let* ((left-node (js2-infix-node-left node)) (left-symbol (dojo-js-completion-get-node-symbol defined-symbols scopes (1+ level) left-node max-abs-pos)) (right-node (js2-infix-node-right node))) (if (null left-symbol) (log-completion 0 (format "[WARNING] dojo-js-inspect-get-prop-get-symbol found no symbol")) (progn (log-completion level (format "dojo-js-inspect-get-prop-get-symbol found left-symbol [%s]" (dojo-core-util-symbol-to-short-string left-symbol))) (if (or (null max-abs-pos) (< (js2-node-abs-pos right-node) max-abs-pos)) (let ((found-right-symbol (dojo-js-completion-get-child-symbol left-symbol (1+ level) right-node))) (if (null found-right-symbol) (progn (log-completion level (format "Found no right-symbol although its node is within search range.")) (if (dojo-has-node-type right-node "js2-name-node") (progn (log-completion level (format "... right-node is [js2-name-node], returning left-symbol %s together with its name [%s] for future use." (dojo-core-util-symbol-to-short-string left-symbol) (dojo-get-name-from-name-node right-node))) (list left-symbol (dojo-get-name-from-name-node right-node))) (log-completion level (format "... returning plain left-symbol %s" (dojo-core-util-symbol-to-short-string left-symbol))) (list left-symbol nil))) (log-completion level (format "Found right-symbol %s" (dojo-core-util-symbol-to-short-string found-right-symbol))) (list found-right-symbol (dojo-get-name-from-name-node right-node)))) (log-completion level (format "Right-node is after max-abs-pos, returning left-symbol %s" (dojo-core-util-symbol-to-short-string left-symbol))) (list left-symbol nil)))))) (defun dojo-js-inspect-inspect-var-decl (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-var-decl" ancestor-index)) (let ((var-init-node (nth (1+ ancestor-index) ancestor-path))) (cond ((dojo-has-node-type var-init-node "js2-var-init-node") (dojo-js-inspect-inspect-var-init inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)) (t (log-inspect (format "[WARNING] Child of js2-var-decl-node doesn't have type js2-var-init-node as expected; will ignore it. Found type: [%s]" (if var-init-node (js2-node-short-name var-init-node) nil))))))) (defun dojo-js-inspect-inspect-var-init (inspect-path ancestor-path ancestor-index defined-symbols scopes class) (log-inspect (format "[%s] Called inspect-var-init" ancestor-index)) (let* ((var-init-node (nth ancestor-index ancestor-path)) (next-ancestor-node (nth (1+ ancestor-index) ancestor-path)) (target-node (js2-var-init-node-target var-init-node)) (initializer-node (js2-var-init-node-initializer var-init-node))) (cond ((eq next-ancestor-node target-node) (log-inspect "[WARNING] ancestor-path points to the target-node of a var-init-node; this is not supported yet.")) ((eq next-ancestor-node initializer-node) (let* ((initialized-symbol (if (dojo-has-node-type target-node "js2-name-node") (dojo-js-completion-get-name-symbol defined-symbols scopes 0 target-node t) nil))) (if (and initialized-symbol (dojo-has-node-type initializer-node "js2-object-node") (dojo-core-util-is-object-symbol initialized-symbol)) (dojo-js-inspect-inspect-object inspect-path initialized-symbol ancestor-path (1+ ancestor-index) defined-symbols scopes class) (dojo-js-inspect-inspect-node inspect-path ancestor-path (1+ ancestor-index) defined-symbols scopes class)))) ; ((dojo-has-node-type initializer-node "js2-call-node") ; (dojo-add-call-candidates ancestor-path (1+ ancestor-index) scopes level prefix current-class this-symbol)) ; ((dojo-has-node-type initializer-node "js2-object-node") ; (let* ((var-name (dojo-get-name-from-var-init-node var-init-node)) ; (object-scope (dojo-construct-object-scope initializer-node (list "this" var-name) level current-class)) ; (new-scopes (append (list object-scope) scopes)) ; ) ; (dojo-add-object-candidates ancestor-path (1+ ancestor-index) new-scopes (1+ level) prefix current-class this-symbol) ; )) (t (log-inspect (format "[WARNING] ancestor-path points to an unknown child node of a js2-var-init-node; something is strange. Node type is [%s]") (js2-node-short-name next-ancestor-node)))))) (defun dojo-js-inspect-set-inspect-path-symbol (inspect-path ancestor-index symbol &optional hint) (log-inspect (format "[%s] ... setting inspect-path[%s] to %s%s" ancestor-index ancestor-index (dojo-core-util-symbol-to-short-string symbol) (if hint (format " with hint [%s]" hint) ""))) (setf (dojo-inspect-token-symbol (nth ancestor-index inspect-path)) symbol) (setf (dojo-inspect-token-hint (nth ancestor-index inspect-path)) hint)) (defun dojo-js-inspect-print-ancestor-path (ancestor-path) (log-inspect "===== Ancestor path =====") (let ((n 0)) (dolist (node ancestor-path) (log-inspect (format "[%s]: Node [%s]" n (js2-node-short-name node))) (incf n))) (log-inspect "=========================")) (defun dojo-js-inspect-print-inspect-path (inspect-path) (log-inspect "===== Inspect path ======") (let ((inspect-index 0)) (dolist (inspect-token inspect-path) (let* ((node (dojo-inspect-token-node inspect-token)) (symbol (dojo-inspect-token-symbol inspect-token)) (hint (dojo-inspect-token-hint inspect-token))) (log-inspect (format "[%s] Node [%s] --> Symbol %s%s" inspect-index (js2-node-short-name node) (dojo-core-util-symbol-to-short-string symbol) (if hint (format " (with hint [%s])" hint) ""))) (incf inspect-index)))) (log-inspect "=========================")) (provide 'dojo-js-inspect)