Function list lists each of my PHP functions twice!?

Function list lists each of my PHP functions twice!?

10
Basic UserBasic User
10

    May 14, 2009#1

    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

    6,603548
    Grand MasterGrand Master
    6,603548

      May 14, 2009#2

      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
      Best regards from an UC/UE/UES for Windows user from Austria

      2362
      MasterMaster
      2362

        May 14, 2009#3

        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.
        “Don’t document the problem, fix it.” – Atli Björgvin Oddsson

        10
        Basic UserBasic User
        10

          May 14, 2009#4

          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