From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Nathaniel Flath Newsgroups: gmane.emacs.devel Subject: Re: Fwd: Minor bug in cc-menus.el: cc-imenu-java-generic-expression does not match all Java 1.5+ function definitions. Date: Sat, 22 Aug 2009 09:48:55 -0700 Message-ID: <5e3a506e0908220948s4b3bb58bwf0c11cc98fb1f163@mail.gmail.com> References: <5e3a506e0907180827k148fe0d1x34b89f1fedf6c79d@mail.gmail.com> <20090728101959.GA2295@muc.de> <871vo05fsl.fsf@cyd.mit.edu> <5e3a506e0907282146x549f9f8bt3412603ec86b7691@mail.gmail.com> <5e3a506e0908070732yc0095d5gfe72101b8843037e@mail.gmail.com> <5e3a506e0908162232h192a3c28o42e1745f4444b911@mail.gmail.com> <5e3a506e0908162233x47fe9544kcd8fda1738c28e84@mail.gmail.com> <20090822141711.GA3512@muc.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000e0cd11360b0bb150471bdc204 X-Trace: ger.gmane.org 1250959756 7259 80.91.229.12 (22 Aug 2009 16:49:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 22 Aug 2009 16:49:16 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Aug 22 18:49:09 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Metm7-0006Pg-Gx for ged-emacs-devel@m.gmane.org; Sat, 22 Aug 2009 18:49:08 +0200 Original-Received: from localhost ([127.0.0.1]:53041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Metm6-00047g-IB for ged-emacs-devel@m.gmane.org; Sat, 22 Aug 2009 12:49:06 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Metm2-00047Q-JV for emacs-devel@gnu.org; Sat, 22 Aug 2009 12:49:02 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Metly-00046o-QV for emacs-devel@gnu.org; Sat, 22 Aug 2009 12:49:02 -0400 Original-Received: from [199.232.76.173] (port=46527 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Metly-00046e-KH for emacs-devel@gnu.org; Sat, 22 Aug 2009 12:48:58 -0400 Original-Received: from mail-pz0-f182.google.com ([209.85.222.182]:58712) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Metly-0005cL-0n for emacs-devel@gnu.org; Sat, 22 Aug 2009 12:48:58 -0400 Original-Received: by pzk12 with SMTP id 12so305429pzk.14 for ; Sat, 22 Aug 2009 09:48:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=29/RYhNpvBJXPimVifHVJlPjHpNfcbe3M5oXp8nRoU8=; b=lSMo8z3q9/dT+zq0PXcAnpjCElRQipCSHEIJbZD4ZZ+ojHHqrzeHihMyv2ZvUZFw9+ vrfpq6JRvgg2hiwJDcGnf91dvU47nYyQ4qtG9myxGpn1XmMNEolFLVqUlVLUcajovmnH wm08bW0NQ4Yfh6xt+Gj6cVgh597vo6PVw5NLE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=IQbKLPt+H6zWU3veK8b9dz9SvLhwT13f75Ycf7DbS0efmZHUKefzOv8qxg7BnPTLxZ 4EFL8V3NGnYQQA0tV7C99KQ/Hr1YHNDS3E+GSn1dbt6lxcT3An9BmqQ/7K+du8rut1Jk YMkyV3mWooGIn5wb+Ob5gGWZUoSHRA21hvRRw= Original-Received: by 10.141.3.15 with SMTP id f15mr1661324rvi.2.1250959735962; Sat, 22 Aug 2009 09:48:55 -0700 (PDT) In-Reply-To: <20090822141711.GA3512@muc.de> X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:114517 Archived-At: --000e0cd11360b0bb150471bdc204 Content-Type: text/plain; charset=ISO-8859-1 Don't worry about the long delay- I understand that nobody's being paid for Emacs, I just wanted to make sure that my patch hasdn't been lost. I hope the personal stuff that came up ends up OK for you. Good luck! I have not signed any copyright assignment forms to the FSF - I'll print them out and mail them in on Monday. The problems with the initial regexp was that it could count whitespace as a type in variables inside words, so it would accept else if( a ) { .... as a function, even though it would reject else if( a ) { ... I fixed this by modifying the regexp to split out checking for annotations, types, and variable name seperately, while the original essentially had the mashed together(It was probably based too closely of the regexp I was modifying). I'm pretty sure the new regexp works for expressions with < and > tokens - I have the test file that I sent, and have been using this regexp since I last emailed it without any false positives or missed functions. Thanks for taking the time reviewing this patch! Thanks, Nathaniel Flath On Sat, Aug 22, 2009 at 7:17 AM, Alan Mackenzie wrote: > Hi, Nathaniel, > > On Sun, Aug 16, 2009 at 10:33:03PM -0700, Nathaniel Flath wrote: > > ---------- Forwarded message ---------- > > From: Nathaniel Flath > > Date: Sun, Aug 16, 2009 at 10:32 PM > > Subject: Re: Minor bug in cc-menus.el: cc-imenu-java-generic-expression > does > > not match all Java 1.5+ function definitions. > > To: Chong Yidong > > > > And again. > > Sorry. I've had some heavy personal stuff to deal with in the last few > weeks. None of us actually gets paid for maintaining Emacs. I'm still > not fully up to scratch for doing software. > > Also, it looks like your change is quite a substantial one, so I'll have > to ask you to sign (paper) copyright assignment forms (to the Free > Software Foundation) before installing it into CC Mode. Or have you > already been through this? This is standard FSF policy, and though > ostensibly you're giving something away, in reality you're not. You > retain the right to do as you wish with your own stuff, but you get the > protection of FSF's lawyers should anybody ever violate your copyright. > > > There did turn out to be a few problems with that regexp - the updated > > one is: > > Could you tell me please what those problems were (perhaps with a > fragment of Java source where the problems became apparent). > > > (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 fun4() { } > > Map< String,String > fun5() { } > > void fun6( @NonNull int a ) { } > > void fun7( @NonNull int b, @NonNull int c ) { } > > void fun8( @NonNull List a ) { } > > void fun9( @NonNull List> 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 > > OK. Again, how sure are you that the new regexp won't spuriously match > things with "less than" or "greater than" tokens? > > Thanks for taking the trouble with this patch, despite all the tedium > I've been causing you. > > -- > Alan Mackenzie (Nuremberg, Germany). > --000e0cd11360b0bb150471bdc204 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Don't worry about the long delay- I understand that nobody's being = paid for Emacs, I just wanted to make sure that my patch hasdn't been l= ost.=A0 I hope the personal stuff that came up ends up OK for you.=A0 Good = luck!

I have not signed any copyright assignment forms to the FSF - I'll = print them out and mail them in on Monday.=A0

The problems with the= initial regexp was that it could count whitespace as a type in variables i= nside words, so it would accept
=A0=A0=A0 else if(=A0 a ) {
=A0=A0=A0=A0=A0=A0=A0 ....

as a func= tion, even though it would reject
=A0=A0=A0 else if( a ) {
=A0=A0=A0= =A0=A0=A0=A0 ...

I fixed this by modifying the regexp to split out c= hecking for annotations, types, and variable name seperately, while the ori= ginal essentially had the mashed together(It was probably based too closely= of the regexp I was modifying).

I'm pretty sure the new regexp works for expressions with < and >= tokens - I have the test file that I sent, and have been using this regexp= since I last emailed it without any false positives or missed functions.
Thanks for taking the time reviewing this patch!

Thanks,
Nath= aniel Flath
On Sat, Aug 22, 2009 at 7:17 AM, Alan Mackenzie <acm@muc.de> wrote:
Hi, Nathaniel,

On Sun, Aug 16, 2009 at 10:33:03PM -0700, Nathaniel Flath wrote:
> ---------- Forwarded message ----------
> From: Nathaniel Flath <flat01= 03@gmail.com>
> Date: Sun, Aug 16, 2009 at 10:32 PM
> Subject: Re: Minor bug in cc-menus.el: cc-imenu-java-generic-expressio= n does
> not match all Java 1.5+ function definitions.
> To: Chong Yidong <cyd@stup= idchicken.com>


> And again.

Sorry. =A0I've had some heavy personal stuff to deal with in the = last few
weeks. =A0None of us actually gets paid for maintaining Emacs. =A0I'm s= till
not fully up to scratch for doing software.

Also, it looks like your change is quite a substantial one, so I'll hav= e
to ask you to sign (paper) copyright assignment forms (to the Free
Software Foundation) before installing it into CC Mode. =A0Or have you
already been through this? =A0This is standard FSF policy, and though
ostensibly you're giving something away, in reality you're not. =A0= You
retain the right to do as you wish with your own stuff, but you get the
protection of FSF's lawyers should anybody ever violate your copyright.=

> There did turn out to be a few problems with that regexp - the updated=
> one is:

Could you tell me please what those problems were (perhaps with a
fragment of Java source where the problems became apparent).

> (defvar cc-imenu-java-generic-expression
> =A0 `((nil
> =A0 =A0 =A0,(concat
> =A0 =A0 =A0 =A0"[" c-alpha "_][\]\[." c-alnum &quo= t;_<> ]+[ \t\n\r]+" ; type spec
> =A0 =A0 =A0 =A0"\\([" c-alpha "_][" c-alnum "= _]+\\)" ; method name
> =A0 =A0 =A0 =A0"[ \t\n\r]*"
> =A0 =A0 =A0 =A0;; An argument list htat is either empty or contains an= y number
> =A0 =A0 =A0 =A0;; of arguments. =A0An argument is any number of annota= tions
> =A0 =A0 =A0 =A0;; followed by a type spec followed by a word. =A0A wor= d is an
> =A0 =A0 =A0 =A0;; identifier. =A0A type spec is an identifier, possibl= y followed
> =A0 =A0 =A0 =A0;; by < typespec > possibly followed by [].
> =A0 =A0 =A0 =A0(concat "("
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"\\("
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "[ \t\n\r]*"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 "\\("
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"@"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"[" c-alpha "= ;_]"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"[" c-alnum "= ;._]""*"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0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0 =A0 =A0)) 1))
> =A0 "Imenu generic expression for Java mode. =A0See
> `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. =A0A file that=
> displays some of the matches/non-matches is:

> //(setq imenu-generic-expression cc-imenu-java-generic-expression)

> public class Test {

> =A0 =A0 void fun1() { }
> =A0 =A0 void fun2( int a ) { }
> =A0 =A0 void fun3( int a, int b ) { }
> =A0 =A0 List<String > fun4() { }
> =A0 =A0 Map< String,String > fun5() { }
> =A0 =A0 void fun6( @NonNull int a ) { }
> =A0 =A0 void fun7( @NonNull int b, @NonNull int c ) { }
> =A0 =A0 void fun8( @NonNull List<String> a ) { }
> =A0 =A0 void fun9( @NonNull List<List<String >> a ) { } > =A0 =A0 void fun10( @NonNull int[] a) { }
> =A0 =A0 void fun11( List< class.innerclass > foo ) { }
> =A0 =A0 voif fun12( class.innerclass< Integer> foof ) { }

> =A0 =A0 else if( a ) { }
> =A0 =A0 else if( a < b ) { }
> =A0 =A0 else if( a < b && b > a ) { }
> =A0 =A0 else if( =A0a ) { }
> =A0 =A0 else if( a.b ) { }
> }

> the 'funX' should all be matched, with no 'else if's
OK. =A0Again, how sure are you that the new regexp won't sp= uriously match
things with "less than" or "greater than&q= uot; tokens?

Thanks for taking the trouble with this patch, despite all the tedium=
I've been causing you.

--
Alan Mackenzie (Nuremberg, Germany).

--000e0cd11360b0bb150471bdc204--