Function list lists each of my PHP functions twice!?

Syntax highlighting, code folding, brace matching, code indenting, and function list

Function list lists each of my PHP functions twice!?

Postby anonymous718 » Wed May 13, 2009 10:51 pm

Hi folks,

I'm a long time UltraEdit user and I just installed v15. Here's the problem I can't figure out.

I have a functions.inc file that contains many of my custom PHP functions which I use in other files. I've always typed my functions like this:
Code: Select all
function example($param)
{
   // do magic here..
}

But now in UltraEdit v15, the example() function shows up twice in the Functions List:
    example
    example($param)
If I change my code to look like this (the starting open-bracket on the same line as the function name):
Code: Select all
function example($param) {
  // do magic here..
}

Then it only shows up once in the Function List (but without the parameters list!!):
    example

This was never a problem in earlier versions of UltraEdit and I really cannot change my coding style. I looked into the syntax highlighting file (php.uew), but couldn't figure out the problem.

Any one have any ideas? Any help would be appreciated!

Thanks.

Sean
anonymous718
Basic User
Basic User
 
Posts: 10
Joined: Wed May 13, 2009 10:40 pm

Re: Function list lists each of my PHP functions twice!?

Postby Mofi » Thu May 14, 2009 4:39 am

In php.uew installed with UltraEdit v15.00.0.1046 are the function strings:

/Function String = "%[^t ]++function[^t ]+^([a-z0-9_&]+^)"
/Function String 1 = "%[^t ]++function[^t ]+^([~{]+^)"
/Function String 2 = "%[^t ]++^{public^}^{private^}[^t ]++function[^t ]+^([a-z0-9_&]+^)"
/Function String 3 = "%[^t ]++protected[^t ]++function[^t ]+^([a-z0-9_&]+^)"


The first one finds for your coding style the function example and ignores everything after the function name.

The second one finds for your coding style the function example and everything till { is found anywhere (same line or anywhere below) and shows you everything after function on the same line till { or end of line.

It is interesting that with your second example with { on the function definition line example($param) is not listed in the function list although also found by the regular expression string correct. It looks like there is a built-in function in UltraEdit which filters duplicate entries. But this filtering fails for your first example because the second function string finds the function line with the line ending. If I change the second function string to

/Function String 1 = "%[^t ]++function[^t ]+^([~{^p]+^)"

the second line with the parameter also shown is filtered out by UltraEdit. It looks like UltraEdit compares internally the entire lines where a string is found without the line ending characters. But because of second function string finds also blocks (found strings with line ending characters) this filtering of duplicate function definition lines fails in such cases.

The other 2 function strings are for PHP functions with public, private or protected before word function and show also only the function name in the function list.

Now for your coding style it depends on whether you want to see also the parameters (on the function definition line) in the function list or only the function names.

For function names only use following in php.uew:

/Function String = "%[^t ]++function[^t ]+^([a-z0-9_&]+^)"
/Function String 1 = "%[^t ]++^{public^}^{private^}[^t ]++function[^t ]+^([a-z0-9_&]+^)"
/Function String 2 = "%[^t ]++protected[^t ]++function[^t ]+^([a-z0-9_&]+^)"


For function names with parameters use for your coding style:

/Function String = "%[^t ]++function[^t ]+^([~{/#^p]+^)"
/Function String 1 = "%[^t ]++^{public^}^{private^}[^t ]++function[^t ]+^([~{/#^p]+^)"
/Function String 2 = "%[^t ]++protected[^t ]++function[^t ]+^([~{/#^p]+^)"


[~{/#^p]+ means capture all characters until one of the following characters is found

{ ... start of the code block of this function
/ ... start of a line or block comment; don't use a block comment inside the parameter list
# ... start of a line comment
^p ... any kind of line ending character
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4066
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Function list lists each of my PHP functions twice!?

Postby rhapdog » Thu May 14, 2009 7:53 am

Thanks, Mofi. I haven't had the time to look into this. I don't utilize the function list on every project, only where I have a file with a large number of functions, which is not always the case in web development.

This will certainly come in handy.
User avatar
rhapdog
Master
Master
 
Posts: 272
Joined: Tue Apr 01, 2008 10:02 am
Location: Mississippi, USA

Re: Function list lists each of my PHP functions twice!?

Postby anonymous718 » Thu May 14, 2009 6:03 pm

Thank you Mofi! Your solution worked. I also got a similar solution from Ben at UltraEdit support:

Hello Sean,

Thanks for your message. I am able to reproduce this with the latest PHP wordfile in v15. I will ask our developers to investigate this further. I apologize for the inconvenience.

I do think I can provide a workaround for this. Please go to Advanced -> Configuration -> Editor Display -> Syntax Highlighting. Select the "PHP" language from the syntax highlighting drop down box and click "Open". You should see 4 function strings underneath /Delimiters; do you see these? If so, comment out the 2nd function string with an extra forward slash so you have the following:

//Function String 1 = "%[^t ]++function[^t ]+^([~{]+^)"

Save your changes and go back to your PHP file then press F8. Do you now see the correct data in the function list?

Thanks,

Ben
anonymous718
Basic User
Basic User
 
Posts: 10
Joined: Wed May 13, 2009 10:40 pm


Return to Syntax Highlighting