Function: rust-ts-mode--fontify-number-literal

rust-ts-mode--fontify-number-literal is a byte-compiled function defined in rust-ts-mode.el.gz.

Signature

(rust-ts-mode--fontify-number-literal NODE OVERRIDE START STOP &rest _)

Documentation

Fontify number literals, highlighting the optional type suffix.

If rust-ts-mode-fontify-number-suffix-as-type is non-nil, use font-lock-type-face to highlight the suffix.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/rust-ts-mode.el.gz
(defun rust-ts-mode--fontify-number-literal (node override start stop &rest _)
  "Fontify number literals, highlighting the optional type suffix.
If `rust-ts-mode-fontify-number-suffix-as-type' is non-nil, use
`font-lock-type-face' to highlight the suffix."
  (let* ((beg (treesit-node-start node))
         (end (treesit-node-end node)))
    (save-excursion
      (goto-char end)
      (if (and rust-ts-mode-fontify-number-suffix-as-type
               (looking-back rust-ts-mode--number-types beg))
          (let* ((ty (match-beginning 0))
                 (nb (if (eq (char-before ty) ?_) (1- ty) ty)))
            (treesit-fontify-with-override
             ty end 'font-lock-type-face override start stop)
            (treesit-fontify-with-override
             beg nb 'font-lock-number-face override start stop))
          (treesit-fontify-with-override
           beg end 'font-lock-number-face override start stop)))))