From: Nathaniel Flath <flat0103@gmail.com>
To: Chong Yidong <cyd@stupidchicken.com>
Cc: Alan Mackenzie <acm@muc.de>, emacs-devel@gnu.org
Subject: Re: Minor bug in cc-menus.el: cc-imenu-java-generic-expression does not match all Java 1.5+ function definitions.
Date: Tue, 28 Jul 2009 21:46:40 -0700 [thread overview]
Message-ID: <5e3a506e0907282146x549f9f8bt3412603ec86b7691@mail.gmail.com> (raw)
In-Reply-To: <871vo05fsl.fsf@cyd.mit.edu>
[-- Attachment #1: Type: text/plain, Size: 3449 bytes --]
There did turn out to be a few problems with that regexp - the updated one
is:
(defvar cc-imenu-java-generic-expression
`((nil
,(concat
"[" c-alpha "_][\]\[." c-alnum "_<> ]+[ \t\n\r]+" ; type spec
"\\([" c-alpha "_][" c-alnum "_]+\\)" ; method name
"[ \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'.")
I ended up just splitting out the annotations from the type from the
identifier name to make it easier in the argument list. A file that
displays some of the matches/non-matches is:
//(setq imenu-generic-expression cc-imenu-java-generic-expression)
public class Test {
void fun1() { }
void fun2( int a ) { }
void fun3( int a, int b ) { }
List<String > fun4() { }
Map< String,String > fun5() { }
void fun6( @NonNull int a ) { }
void fun7( @NonNull int b, @NonNull int c ) { }
void fun8( @NonNull List<String> a ) { }
void fun9( @NonNull List<List<String >> a ) { }
void fun10( @NonNull int[] a) { }
void fun11( List< class.innerclass > foo ) { }
voif fun12( class.innerclass< Integer> foof ) { }
else if( a ) { }
else if( a < b ) { }
else if( a < b && b > a ) { }
else if( a ) { }
else if( a.b ) { }
}
the 'funX' should all be matched, with no 'else if's
On Tue, Jul 28, 2009 at 8:28 PM, Chong Yidong <cyd@stupidchicken.com> wrote:
> Alan Mackenzie <acm@muc.de> writes:
>
> > OK. I've not looked at it in all that great detail, and haven't tried
> > it out yet. I'm not actually a Java hacker.
> >
> > How confident are you that your proposed regexp won't spuriously match
> > things with "less than" or "greater than" tokens? Or, if it will, would
> > these matches be rare enough that we needn't worry too much?
> >
> > Is there any chance you could send me a test file showing a typical
> > generic construct that the new regexp would match, and possibly
> > constructs with "less/greater than" which it "doesn't quite" match?
>
> By the way, it might be good to accumulate a test suite for CC mode,
> along the lines of etc/compilation.txt. I don't know if you already
> have something like that; if so, we can put it in the new test/
> directory.
>
> (We should probably move etc/compilation into test/ also.)
>
[-- Attachment #2: Type: text/html, Size: 4727 bytes --]
next prev parent reply other threads:[~2009-07-29 4:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-18 15:27 Minor bug in cc-menus.el: cc-imenu-java-generic-expression does not match all Java 1.5+ function definitions Nathaniel Flath
2009-07-21 20:18 ` Nathaniel Flath
2009-07-24 3:58 ` Glenn Morris
2009-07-28 10:19 ` Alan Mackenzie
2009-07-28 11:42 ` David Kastrup
2009-07-29 3:28 ` Chong Yidong
2009-07-29 4:46 ` Nathaniel Flath [this message]
2009-08-07 14:32 ` Nathaniel Flath
[not found] ` <5e3a506e0908162232h192a3c28o42e1745f4444b911@mail.gmail.com>
2009-08-17 5:33 ` Fwd: " Nathaniel Flath
2009-08-22 14:17 ` Alan Mackenzie
2009-08-22 16:48 ` Nathaniel Flath
[not found] ` <jwvr5v3b9ke.fsf-monnier+emacs@gnu.org>
[not found] ` <5e3a506e0909291146w607168e7l578858a741cfa19a@mail.gmail.com>
2009-10-17 16:59 ` Nathaniel Flath
2009-10-17 23:43 ` Chong Yidong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5e3a506e0907282146x549f9f8bt3412603ec86b7691@mail.gmail.com \
--to=flat0103@gmail.com \
--cc=acm@muc.de \
--cc=cyd@stupidchicken.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.