changeset 106105:7e681be660d6

(cc-imenu-java-generic-expression): A new, more accurate version of the regexp. Contributed by Nathaniel Flath.
author Alan Mackenzie <acm@muc.de>
date Wed, 18 Nov 2009 21:13:07 +0000
parents 682bede83101
children a3ea15b56766
files lisp/progmodes/cc-menus.el
diffstat 1 files changed, 36 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/cc-menus.el	Wed Nov 18 21:11:40 2009 +0000
+++ b/lisp/progmodes/cc-menus.el	Wed Nov 18 21:13:07 2009 +0000
@@ -149,22 +149,45 @@
 (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
-       ;; matching e.g. "else if (foo)".
-       (concat "([ \t\n\r]*"
-	       "\\([\]\[.," c-alnum "_]+"
-	       "[ \t\n\r]+"
-	       "[\]\[.," c-alnum "_]"
-	       "[\]\[.," c-alnum "_ \t\n\r]*"
-	       "\\)?)")
-       "[.," c-alnum "_ \t\n\r]*"
+       ;; An argument list htat is either empty or contains any number
+       ;; of arguments.  An argument is any number of annotations
+       ;; followed by a type spec followed by a word.  A word is an
+       ;; identifier.  A type spec is an identifier, possibly followed
+       ;; by < typespec > possibly followed by [].
+       (concat "("
+               "\\("
+                  "[ \t\n\r]*"
+                  "\\("
+                     "@"
+                     "[" c-alpha "_]"
+                     "[" c-alnum "._]""*"
+                     "[ \t\n\r]+"
+                  "\\)*"
+                  "\\("
+                     "[" c-alpha "_]"
+                     "[\]\[" c-alnum "_.]*"
+                     "\\("
+                        "<"
+                        "[ \t\n\r]*"
+                        "[\]\[.," c-alnum "_<> \t\n\r]*"
+                        ">"
+                     "\\)?"
+                     "\\(\\[\\]\\)?"
+                     "[ \t\n\r]+"
+                  "\\)"
+                 "[" c-alpha "_]"
+                 "[" c-alnum "_]*"
+                 "[ \t\n\r,]*"
+               "\\)*"
+              ")"
+           "[ \t\n\r]*"
        "{"
-       ) 1))
-  "Imenu generic expression for Java mode.  See `imenu-generic-expression'.")
+       )) 1))
+  "Imenu generic expression for Java mode.  See
+`imenu-generic-expression'.")
 
 ;;                        *Warning for cc-mode developers*
 ;;