Subject: Minor bug in cc-menus.el: cc-imenu-java-generic-expression does not match all Java 1.5+ function definitions.

From: Nathaniel Flath <[email-masked]>
Date: Sat, 18 Jul 2009 08:27:10 -0700

Package: emacs,cc-mode

I was using Imenu, and noticed that it currently doesn't recognize Java
functions with either:
Generics e.g : public List<String> foo() { ...
or annotated arguments, e.g : public void foo( @NonNull bar ) {

The issue was the variable cc-imenu-java-generic-expression.

Attached is my patch which modifies this variables to accept all function
definitions and should fix this issue.

Thanks!
Nathaniel Flath
index b151bd0..8a87448 100644
--- a/lisp/progmodes/cc-menus.el
+++ b/lisp/progmodes/cc-menus.el
@@ -149,17 +149,18 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
 (defvar cc-imenu-java-generic-expression
   `((nil
      ,(concat
-       "[" c-alpha "_][\]\[." c-alnum "_]+[ \t\n\r]+" ; type spec
+       "[" c-alpha "_][\]\[." c-alnum "_<> ]+[ \t\n\r]+" ; type spec
        "\\([" c-alpha "_][" c-alnum "_]+\\)" ; method name
        "[ \t\n\r]*"
        ;; An argument list that is either empty or contains at least
-       ;; two identifiers with only space between them.  This avoids
+       ;; two words with whitespace in between them.  Words are
+       ;; identifiers and <>@ characers.  This prevents us from
        ;; matching e.g. "else if (foo)".
        (concat "([ \t\n\r]*"
-	       "\\([\]\[.," c-alnum "_]+"
+	       "\\([\]\[.," c-alnum "_@<> ]+"
 	       "[ \t\n\r]+"
 	       "[\]\[.," c-alnum "_]"
-	       "[\]\[.," c-alnum "_ \t\n\r]*"
+	       "[\]\[.," c-alnum "_ \t\n\r@<> ]*"
 	       "\\)?)")
        "[.," c-alnum "_ \t\n\r]*"
        "{"