Re: [PATCH] Teach git diff about Objective-C syntax
- From
Jonathan del Strother <maillist@steelskies.com>
- Date
- Sep 17, 2008, 23:30 UTC
- Message-ID
- <57518fd10809171630v97485aalcc5089f96082c0fc@mail.gmail.com>
- In-Reply-To
- <7vljxq4i5p.fsf@gitster.siamese.dyndns.org>
On Wed, Sep 17, 2008 at 9:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Are you sure the regexp you have for Objective-C methods quotes a dot "." > correctly, by the way? It appears to match almost anything enclosed in a > pair of parentheses, as long as you have two alpha after open paren.
It could be a little more restrictive, but I'm not sure how much further it could be taken without it getting ridiculous. Just as some examples, it needs to match : +(id)someClassMethod -(id)someInstanceMethod -(NSNumber*)numberWithNumerator:(int)n denominator:(int)d -(NSString*)stringWithVariableArguments:(NSString*)format ...
(I seem to remember that if your method returns 'id' you can skip the return type, eg "- someInstanceMethod", but I don't think there's any hope for people that use that notation...)
^[ \t]*\\([-+][ \t]*([ \t]*[A-Za-z_][A-Za-z_0-9* \t]*)[ \t]*_?[A-Za-z]*\\)$ would be a small improvement - that is, a plus or minus, brackets around the return type, then at least one letter for the method name, potentially preceded by an underscore. Can anyone suggest anything better?
Also, why can't I use \s for whitespace, \w for word characters etc? I thought we were using the gnu regex library?
Show 8 quoted lines
> Also I am not sure if you can do the pattern alternates the way you did. > If you have this: > > "...\\(A\\|B\\)$" > "\\|" > "...\\(C\\|D\\)$" > > A and B will be captured as $1 but wouldn't C or D captured as $2?
Hmm, hadn't considered that. It appears to work fine, but I haven't yet had chance to track down exactly where the funcname regexp match occurs to see what the code is doing with the different matches. I'll try and take a look tomorrow, unless someone can enlighten me before then...