Commits

Alan Mackenzie committed a8f0174

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

cc-langs.el (c-postfix-decl-spec-key): New variable, a regexp which
matches "implements", etc., in Java.
cc-engine.el (c-inside-bracelist-p): Check for extra specifier clauses
coming after "enum".
cc-fonts.el (c-font-lock-declarations, c-font-lock-enum-tail): Check for
extra specifier clauses coming after "enum".
enum-7.{java,res,face}: New test case.

Comments (0)

Files changed (3)

        (if (> cfd-re-match-end (point))
 	   (goto-char cfd-re-match-end))
 
-;;;; NEW STOUGH, 2013-09-21
        ;; Each time round, the next `while' moves forward over a pseudo match
        ;; of `c-decl-prefix-or-start-re' which is either inside a literal, or
        ;; is a ":" not preceded by "public", etc..  `cfd-re-match' and
 	       ;; Found a ":" which isn't part of "public:", etc.
 	       t)
 	      (t nil)))) ;; Found a real match.  Exit the pseudo-match loop.
-;;;; END OF NEW STOUGH
 
        ;; If our match was at the decl start, we have to back up over the
        ;; preceding syntactic ws to set `cfd-match-pos' and to catch
    (c-safe
      (save-excursion
        (goto-char containing-sexp)
-       (c-forward-sexp -1)
-       (let (bracepos)
-	 (if (and (or (looking-at c-brace-list-key)
-		      (progn (c-forward-sexp -1)
-			     (looking-at c-brace-list-key)))
-		  (setq bracepos (c-down-list-forward (point)))
-		  (not (c-crosses-statement-barrier-p (point)
-						      (- bracepos 2))))
-	     (point)))))
+       (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))))
    ;; this will pick up array/aggregate init lists, even if they are nested.
    (save-excursion
      (let ((class-key
 		   (let ((paren-state (c-parse-state)))
 		     (and
 		      (numberp (car paren-state))
-		      (save-excursion
-			(goto-char (car paren-state))
-			(c-backward-token-2)
-			(or (looking-at c-brace-list-key)
-			    (progn
-			      (c-backward-token-2)
-			      (looking-at c-brace-list-key)))))))
+		      (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)))))))
 	      (c-forward-token-2)
 	      nil)
 
     (when (and
 	   encl-pos
 	   (eq (char-after encl-pos) ?\{)
-	   (save-excursion
-	     (goto-char encl-pos)
-	     (c-backward-syntactic-ws)
-	     (c-simple-skip-symbol-backward)
-	     (or (looking-at c-brace-list-key) ; "enum"
-		 (progn (c-backward-syntactic-ws)
-			(c-simple-skip-symbol-backward)
-			(looking-at c-brace-list-key)))))
+	   (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)))))
       (c-syntactic-skip-backward "^{," nil t)
       (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start)
 
 	 ;; In CORBA PSDL:
 	 "as" "const" "implements" "of" "ref"))
 
+(c-lang-defconst c-postfix-decl-spec-key
+  ;; Regexp matching the keywords in `c-postfix-decl-spec-kwds'.
+  t (c-make-keywords-re t (c-lang-const c-postfix-decl-spec-kwds)))
+(c-lang-defvar c-postfix-decl-spec-key
+  (c-lang-const c-postfix-decl-spec-key))
+
 (c-lang-defconst c-nonsymbol-sexp-kwds
   "Keywords that may be followed by a nonsymbol sexp before whatever
 construct it's part of continues."
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.