Fix indentation/fontification of Java enum with "implements"/generic.

* progmodes/cc-engine.el (c-backward-over-enum-header): Extracted from
the three other places and enhanced to handle generics.
(c-inside-bracelist-p): Uses new function above.
* progmodes/cc-fonts.el (c-font-lock-declarations): Uses new function
above.
(c-font-lock-enum-tail): Uses new function above.
This commit is contained in:
Alan Mackenzie 2013-10-13 19:54:46 +00:00
parent 3ccc2d283e
commit 7a06871716
3 changed files with 47 additions and 48 deletions

View file

@ -1,3 +1,15 @@
2013-10-13 Alan Mackenzie <acm@muc.de>
Fix indentation/fontification of Java enum with
"implements"/generic.
* progmodes/cc-engine.el (c-backward-over-enum-header): Extracted
from the three other places and enhanced to handle generics.
(c-inside-bracelist-p): Uses new function above.
* progmodes/cc-fonts.el (c-font-lock-declarations): Uses new
function above.
(c-font-lock-enum-tail): Uses new function above.
2013-10-13 Kenichi Handa <handa@gnu.org>
* international/mule-cmds.el (select-safe-coding-system): Remove a

View file

@ -8471,6 +8471,32 @@ comment at the start of cc-engine.el for more info."
(not (looking-at "=")))))
b-pos)))
(defun c-backward-over-enum-header ()
;; We're at a "{". Move back to the enum-like keyword that starts this
;; declaration and return t, otherwise don't move and return nil.
(let ((here (point))
up-sexp-pos before-identifier)
(while
(and
(eq (c-backward-token-2) 0)
(or (not (looking-at "\\s)"))
(c-go-up-list-backward))
(cond
((and (looking-at c-symbol-key) (c-on-identifier))
(setq before-identifier t))
((and before-identifier
(looking-at c-postfix-decl-spec-key))
(setq before-identifier nil)
t)
((looking-at c-brace-list-key) nil)
((and c-recognize-<>-arglists
(eq (char-after) ?<)
(looking-at "\\s("))
t)
(t nil))))
(or (looking-at c-brace-list-key)
(progn (goto-char here) nil))))
(defun c-inside-bracelist-p (containing-sexp paren-state)
;; return the buffer position of the beginning of the brace list
;; statement if we're inside a brace list, otherwise return nil.
@ -8485,22 +8511,9 @@ comment at the start of cc-engine.el for more info."
;; This function might do hidden buffer changes.
(or
;; This will pick up brace list declarations.
(c-safe
(save-excursion
(goto-char containing-sexp)
(let (before-identifier)
(while
(progn
(c-forward-sexp -1)
(cond
((c-on-identifier) (setq before-identifier t))
((and before-identifier
(looking-at c-postfix-decl-spec-key))
(setq before-identifier nil)
t)
((looking-at c-brace-list-key) nil)
(t nil))))
(looking-at c-brace-list-key))))
(save-excursion
(goto-char containing-sexp)
(c-backward-over-enum-header))
;; this will pick up array/aggregate init lists, even if they are nested.
(save-excursion
(let ((class-key

View file

@ -1471,22 +1471,9 @@ casts and declarations are fontified. Used on level 2 and higher."
(let ((paren-state (c-parse-state)))
(and
(numberp (car paren-state))
(c-safe
(save-excursion
(goto-char (car paren-state))
(let (before-identifier)
(while
(progn
(c-forward-sexp -1)
(cond
((c-on-identifier) (setq before-identifier t))
((and before-identifier
(looking-at c-postfix-decl-spec-key))
(setq before-identifier nil)
t)
((looking-at c-brace-list-key) nil) ; "enum"
(t nil))))
(looking-at c-brace-list-key)))))))
(save-excursion
(goto-char (car paren-state))
(c-backward-over-enum-header)))))
(c-forward-token-2)
nil)
@ -1574,22 +1561,9 @@ casts and declarations are fontified. Used on level 2 and higher."
(when (and
encl-pos
(eq (char-after encl-pos) ?\{)
(c-safe
(save-excursion
(goto-char encl-pos)
(let (before-identifier)
(while
(progn
(c-forward-sexp -1)
(cond
((c-on-identifier) (setq before-identifier t))
((and before-identifier
(looking-at c-postfix-decl-spec-key))
(setq before-identifier nil)
t)
((looking-at c-brace-list-key) nil) ; "enum"
(t nil))))
(looking-at c-brace-list-key)))))
(save-excursion
(goto-char encl-pos)
(c-backward-over-enum-header)))
(c-syntactic-skip-backward "^{," nil t)
(c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)