New Perl function strings for Actionscript/Javascript

New Perl function strings for Actionscript/Javascript

16
Basic UserBasic User
16

    Jun 15, 2007#1

    Im having troubles getting the new Perl RE's for function strings to work.

    For Actionscript/Javascript I use the following line(s):

    /Regexp Type = Perl
    /Function String = "^\s*(?:(?:private|public)\s*)?function\s+([^(]+\s*\(.*\))[^)]*$"

    But no function is found. If I test the regexp seperately from UE it finds all occurences of any function string, so the regexp is ok.

    Also, how do you get to see a part from the found string in your function list. Logic tells me it's done with the normal capturing parentheses like I have here around the functionname and it's parameters, but using:

    /Function String = "^(.*)$"

    tells me it's not. I only get a lot of blank lines doing that.

    262
    MasterMaster
    262

      Jun 15, 2007#2

      You are of course using UE 13.10 as I am?

      I created a "dummy" word file section for an imaginary QZX extension:

      Code: Select all

      /L20"QZX" JSCRIPT_LANG Line Comment = // Block Comment On = /* Block Comment Off = */ Escape Char = \ String Chars = '" File Extensions = QZX
      /Delimiters = ~!@%^&*()-+=|\/{}[]:;"'<> ,	.?
      /Regexp Type = Perl
      /Function String = "^\s*(?:(?:private|public)\s*)?function\s+([^(]+\s*\(.*\))[^)]*$"
      using your exact function string.

      Then I created a dummy qzx-file:

      Code: Select all

       private function acme (asdasd, asds)
       public function acme2(asdasd(), asds)
      and the function list nicely displayed:
      acme (asdasd, asds)
      acme2(asdasd(), asds)


      Can you see where your way differs from my way of doing this?

      Btw, how do I make the function list refresh itself when new functions are added? It doesn't even refresh after a "Revert to Saved". I have to close the file and open it again. Am I missing something? - or are we missing a "refresh" option when right clicking in the function list? (If this is the case I will write an enhancement request to IDM).

      16
      Basic UserBasic User
      16

        Jun 15, 2007#3

        Hmm, this is my full header. There is a tab character left of : in the line with the delimiters.

        Code: Select all

        /L14"Flash ActionScript 2" Line Comment = // Block Comment On = /* Block Comment Off = */ Escape Char = \ File Extensions = AS
        /Delimiters = ~!@%^&*()-+=|\/{}[];"'<> ,.	:
        /Regexp Type = Perl
        /Function String = "^\s*(?:(?:private|public)\s*)?function\s+([^(]+\s*\(.*\))[^)]*$"
        As you can see, except for some small differences they are pretty equal. But ok, so the idea works, just not on my installation. At least I know where to look for now.

        As for the refreshing, I noticed that too. You don't need to close the file though. Tabbing to another file and than back also refreshes the list. Would be nice if there was a little button / JS call for it tough

        6,683583
        Grand MasterGrand Master
        6,683583

          Jun 15, 2007#4

          Refreshing the function list can be done with default key mapping by pressing key F8 which runs command Search - Function List.

          The command View - Views/Lists - Function List is a different command which only toggles visibility of the function list view.
          Best regards from an UC/UE/UES for Windows user from Austria

          16
          Basic UserBasic User
          16

            Jun 15, 2007#5

            thank you mofi

            262
            MasterMaster
            262

              Jun 15, 2007#6

              Doh, can't believe I haven't realized this with F8 before. Thanks Mofi.

              I adapted Jurriaan's exact wordfile and it still works fine on my example. So either it is your installation or your data. Perhaps we should see a small excerpt of your code ?

              It could also be interesting to know if some of the other Perl stuff for function list in 13.10 will work for you.

              Wordfile for HTML has this definition:

              Code: Select all

              /Regexp Type = Perl
              /Function String = "<(form)(.*)>"
              Try a simple html file with a form and see if the form appears in the function list. For example:

              Code: Select all

              <html><head><title>test</test></head>
              <body>
              	<form action="http://dummy.nop/adduser" method="post">
              	</form>
              </body></html>

              16
              Basic UserBasic User
              16

                Jun 15, 2007#7

                I can't explain how, but I got it working. While trying to bring down all the code to all smaller file to share here, I suddenly had the function names on the right. So, I figured.. there must be something strange in the file. I copied the contents to a new document, to start deleting line by line, named the document test.as and there it was. All the names are there.

                But with the origional file it still doesn't work, while the contents of the file is identical. Also when renaming the original file, the function names won't show up, only when I copy it's contents to a new file.

                Most likely UE has some kind of cache for documents it has opened before, which doesnt look for the new syntax settings.

                Anyway, it seems to work on any new file I make and that is good enough for me now. If I have done some more testing I will make a bug report for it. Thank you for your trouble help jorrasdk!

                  Jun 15, 2007#8

                  Mofi wrote:Are you sure the contents are identical and also the extension is identical?

                  Maybe the existing file uses a different file format (UTF-8, Unicode, DOS or UNIX) than the new file. I suggest to make a binary file compare with UltraCompare (Lite) to test, if both files are really identical.
                  Your suggestion was right on the spot though. Although the contents are identical, the original file is UTF-8 encoded (as it was first made in the Flash IDE itself) and the files I copied the content to are not. And indeed when I convert one of the newer files to UTF8 the function list disappears.

                  6,683583
                  Grand MasterGrand Master
                  6,683583

                    Jun 15, 2007#9

                    Okay, now you can report this problem to IDM support per email. If your Perl function strings works when used with the Find dialog on your UTF-8 file, then there is maybe really a bug in the implementation of the new Perl regexp function string feature. I have not tested this new feature because I don't need it.

                    But before you report this problem, check first what exactly is tagged by your search string. Run a replace with your search string and use \1 in the replace field. Run and look what remains after the replace. If nothing remains from a function, then you are maybe closer to find out what is the problem. Replaces can be undone. That's the method I use to find a regular expression for the function list.
                    Best regards from an UC/UE/UES for Windows user from Austria

                    16
                    Basic UserBasic User
                    16

                      Jun 15, 2007#10

                      Doing a search and replace on the UTF8 encoded file gives the expected result. All 'function lines' are replaced by just the function name and it's parameters.

                      I will report the error to IDM

                      119
                      Power UserPower User
                      119

                        Jun 21, 2007#11

                        Tip: The engine used for Perl-compatible regular expressions seems to have some performance issues. For example, while "\s+" is probably the strictly correct expression for most places where you can have whitespace it is much slower than " +" or "[ \t]+" which are likely to be acceptable replacements.

                        6,683583
                        Grand MasterGrand Master
                        6,683583

                          Jun 22, 2007#12

                          Info about fixed issues with hotfix 1 for UE v13.10 and UES v6.30 available since 21 Jun 2007 contains the line:
                          • Function list not displaying functions from UTF-8 files when Perl regular expressions enabled
                          Can you confirm that the problem is fixed?

                          And Perl search string \s+ is surely slower than [ \t]+ because \s matches also \r and \n and not only spaces and tabs and therefore must be slower.
                          Best regards from an UC/UE/UES for Windows user from Austria

                          16
                          Basic UserBasic User
                          16

                            Jun 22, 2007#13

                            Yes, the problem is fixed. Thanks everybody.