The same problem existed in csharp mode until the last week. The way I fixed this was to add new matches in the c-basic-matchers-after setting for csharp. The new match is as follows:
;; Case 2: declaration of enum with or without an explicit base type ,@(when t `((,(byte-compile `(lambda (limit) (let ((parse-sexp-lookup-properties (cc-eval-when-compile (boundp 'parse-sexp-lookup-properties)))) (while (re-search-forward ,(concat csharp-enum-decl-re "[ \t\n\r\f\v]*" "{") limit t) (unless (progn (goto-char (match-beginning 0)) (c-skip-comments-and-strings limit)) (progn (save-match-data (goto-char (match-end 0)) (c-put-char-property (1- (point)) 'c-type 'c-decl-id-start) (c-forward-syntactic-ws)) (save-match-data (c-font-lock-declarators limit t nil)) (goto-char (match-end 0)) ) ))) nil)) )))
where csharp-enum-decl-re is defined as
(defconst csharp-enum-decl-re (concat "\\<enum[ \t\n\r\f\v]+" "\\([[:alpha:]_][[:alnum:]_]*\\)" "[ \t\n\r\f\v]*" "\\(:[ \t\n\r\f\v]*" "\\(" (c-make-keywords-re nil (list "sbyte" "byte" "short" "ushort" "int" "uint" "long" "ulong")) "\\)" "\\)?") "Regex that captures an enum declaration in C#" )
In this case, the text property is set in parenthesis after the enum declaration line. This text property tells cc-mode to put the contents of the brackets list differently. Like a โbrackets listโ. Setting this property gets brace-list-open on the next line.
Perhaps something like this will work for you.
You can configure the java helpers yourself, with something like this, and if you open an error, you can send this as a recommended fix.
In C #, enums can be inferred from any integer type. so
public enum MyEnumType : uint { ONE = 1, TWO, THREE, }
I think that in Java there is no such possibility. If so, the Java regular expression will be much simpler than the regular expression I used for C #.
Whoops! It just occurred to me that with the simpler Java syntax, there is also the possibility of including parenthesis lists by simply setting the enum keyword in the correct language constant. If so, then the solution for you may be as simple as:
(c-lang-defconst c-inexpr-brace-list-kwds java '("enum"))
This did not work for C # due to its more complex syntax.
EDIT - No, that didn't work. It is harder than that.