[Geany-devel] [Patch] - Improve PHP parser (call tips)

Dominic Hopf dmaphy at xxxxx
Sun Apr 18 01:05:53 UTC 2010


Am Samstag, den 17.04.2010, 18:14 +0200 schrieb Enrico Tröger:
> On Mon, 8 Mar 2010 23:40:08 +0100, Enrico wrote:
> 
> >On Mon, 8 Mar 2010 12:18:39 +0000, Nick wrote:
> >
> >>On Sun, 7 Mar 2010 19:20:37 +0100
> >>Enrico Tröger <enrico.troeger at uvena.de> wrote:
> >>
> >>> >You put a weird pattern:
> >>> >[public|protected|private|static]*
> >>> >If you wanted to group, you should use ()
> >>> 
> >>> I didn't want to group, we don't need to know the actual modifier,
> >>> we just want to allow only this subset. And yes, it was a group
> >>> before but there is just no need to.
> >>
> >>I think Can is right, [] brackets are only for character ranges, not
> >>string matching. So () brackets are necessary for matching even when
> >>ignoring the group.
> >
> >Just for the records:
> >
> >Yup, we talked about that yesterday afterwards on IRC and once he told
> >me about that mistake, it was clear.
> 
> I spent a little more time on this again hoping to get it fixed.
> In SVN r4828, I adjusted the regular expression for parsing PHP
> functions a bit and I think it works now as expected or at least better
> than before. All function definitions I tried (with static,
> public, ... modifiers and some without and so on) worked and I got the
> expected argument list as calltip.
> 
> Though, as muliple times mentioned before, I'm not a PHP guy. Feedback
> is welcome.

Your pattern seems to work fine now. I've successfully tested different
cases as attached and any combination of testcase 1-3 with testcase 4.

But, I'd like to point out another issue or rather a feature request. I
don't feel it's that important, at least not for me. Also, it maybe is
very language-specific for PHP:

Since we're obviously writing object-oriented PHP here (because we're
using public static anything and so on), it would be nice, if Geany also
would parse the so called magic methods [1]. You may noted the
__construct method in the attached files. This method is called when a
new instance is created as you see in line 24. For completeness Geany
should also show calltips in that line when creating the new instance.

I can imagine, that this won't be that easy to implement, since Geany
would have to have a look into the class which is called (test) and look
if a method __construct is there (note it theoretically could be in any
place), and if yes, look for the parameters of the __construct method to
show the calltip.

Well, as I said, not that important, but I at least wanted to let you
know there is something. ;)

Regards,
Dominic


[1] http://de3.php.net/manual/en/language.oop5.magic.php


-- 
Dominic Hopf <dmaphy at googlemail.com>

http://dominichopf.de/

Key Fingerprint:
A7DF C4FC 07AE 4DDC 5CA0 BD93 AAB0 6019 CA7D 868D
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcase1.php
Type: application/x-php
Size: 330 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100418/0908bb79/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcase2.php
Type: application/x-php
Size: 323 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100418/0908bb79/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcase3.php
Type: application/x-php
Size: 316 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100418/0908bb79/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testcase4_with_array.php
Type: application/x-php
Size: 326 bytes
Desc: not available
URL: <http://lists.geany.org/pipermail/devel/attachments/20100418/0908bb79/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://lists.geany.org/pipermail/devel/attachments/20100418/0908bb79/attachment.pgp>


More information about the Devel mailing list