Function: c-font-lock-declarators
c-font-lock-declarators is a byte-compiled function defined in
cc-fonts.el.gz.
Signature
(c-font-lock-declarators LIMIT LIST TYPES NOT-TOP &optional TEMPLATE-CLASS)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-fonts.el.gz
(defun c-font-lock-declarators (limit list types not-top
&optional template-class)
;; Assuming the point is at the start of a declarator in a declaration,
;; fontify the identifier it declares. (If TYPES is t, it does this via the
;; macro `c-fontify-types-and-refs'.)
;;
;; If LIST is non-nil, also fontify the ids in any following declarators in
;; a comma separated list (e.g. "foo" and "*bar" in "int foo = 17, *bar;");
;; additionally, mark the commas with c-type property 'c-decl-id-start or
;; 'c-decl-type-start (according to TYPES). Stop at LIMIT.
;;
;; If TYPES is t, fontify all identifiers as types, if it is nil fontify as
;; either variables or functions, otherwise TYPES is a face to use. If
;; NOT-TOP is non-nil, we are not at the top-level ("top-level" includes
;; being directly inside a class or namespace, etc.).
;;
;; TEMPLATE-CLASS is non-nil when the declaration is in template delimiters
;; and was introduced by, e.g. "typename" or "class", such that if there is
;; a default (introduced by "="), it will be fontified as a type.
;; E.g. "<class X = Y>".
;;
;; Nil is always returned. The function leaves point at the delimiter after
;; the last declarator it processes.
;;
;; This function might do hidden buffer changes.
;;(message "c-font-lock-declarators from %s to %s" (point) limit)
(c-fontify-types-and-refs
()
(c-do-declarators
limit list not-top
(cond ((eq types t) 'c-decl-type-start)
((null types) 'c-decl-id-start))
(lambda (id-start _id-end end-pos _not-top is-function init-char)
(if (eq types t)
;; Register and fontify the identifier as a type.
(let ((c-promote-possible-types t))
(goto-char id-start)
(c-forward-type))
;; The following doesn't work properly (yet, 2018-09-22).
;; (c-put-font-lock-face id-start id-end
;; (if is-function
;; 'font-lock-function-name-face
;; 'font-lock-variable-name-face))
(when (and c-last-identifier-range
(not (get-text-property (car c-last-identifier-range)
'face)))
;; We use `c-last-identifier-range' rather than `id-start' and
;; `id-end', since the latter two can be erroneous. E.g. in
;; "~Foo", `id-start' is at the tilde. This is a bug in
;; `c-forward-declarator'.
(c-put-font-lock-face (car c-last-identifier-range)
(cdr c-last-identifier-range)
(cond
((not (memq types '(nil t))) types)
(is-function 'font-lock-function-name-face)
(t 'font-lock-variable-name-face)))))
(and template-class
(eq init-char ?=) ; C++ "<class X = Y>"?
(progn
(goto-char end-pos)
(c-forward-token-2 1 nil limit) ; Over "="
(let ((c-promote-possible-types t))
(c-forward-type t))))))
nil))