Function: claude-code-ide-mcp-treesit--format-tree

claude-code-ide-mcp-treesit--format-tree is a natively compiled function defined in claude-code-ide-emacs-tools.el.

Signature

(claude-code-ide-mcp-treesit--format-tree NODE LEVEL MAX-DEPTH)

Documentation

Format NODE and its children as a tree string.

LEVEL is the current indentation level. MAX-DEPTH is the maximum depth to traverse.

Source Code

;; Defined in /nix/store/yjvbhwl7p6zrbw9xlnni7y4hra8sa3pl-emacs-packages-deps/share/emacs/site-lisp/claude-code-ide-emacs-tools.el
(defun claude-code-ide-mcp-treesit--format-tree (node level max-depth)
  "Format NODE and its children as a tree string.
LEVEL is the current indentation level.
MAX-DEPTH is the maximum depth to traverse."
  (if (or (not node) (>= level max-depth))
      ""
    (let* ((indent (make-string (* level 2) ?\s))
           (type (treesit-node-type node))
           (named (if (treesit-node-check node 'named) " (named)" ""))
           (start (treesit-node-start node))
           (end (treesit-node-end node))
           (field-name (treesit-node-field-name node))
           (field-str (if field-name (format " [%s]" field-name) ""))
           (text (treesit-node-text node t))
           (text-preview (if (and (< (length text) 40)
                                  (not (string-match-p "\n" text)))
                             (format " \"%s\"" text)
                           ""))
           (result (format "%s%s%s%s (%d-%d)%s\n"
                           indent type named field-str
                           start end text-preview))
           (child-count (treesit-node-child-count node)))
      ;; Add children
      (dotimes (i child-count)
        (when-let* ((child (treesit-node-child node i)))
          (setq result (concat result
                               (claude-code-ide-mcp-treesit--format-tree
                                child (1+ level) max-depth)))))
      result)))