How to get JavaScript function list with anonymous and arrow functions also listed?

How to get JavaScript function list with anonymous and arrow functions also listed?

413
Basic UserBasic User
413

    Jul 11, 2020#1

    Hello!

    Testing JavaScript functions with this:

    Code: Select all

    !function(){}()                             // test1
    !function test2(){}()                       // test2
    (function(){})()                            // test3
    (function test4(){})()                      // test4
    test5 = function(){}                        // test5
    test6 = function _test6(){}                 // test6
    let test7 = function(){}                    // test7
    let test8 = function _test8(){}             // test8
    var test9 = function(){}                    // test8
    var test10 = function _test10(){}           // test10
    myfunc(function(){})                        // test11
    myfunc(function test12(){})                 // test12
    let myobj = {test13 : function(){}}         // test13
    let myobj = {test14 : function _test14(){}} // test14
    var myobj = {test15 : function(){}}         // test15
    var myobj = {test16 : function _test16(){}} // test16
    
    The function list only shows "test13", "test15", "test5", "test7" and "test9" (in this order - not good!) with the default settings.

    I've added this regex in anonymous function list configuration:

    Code: Select all

    (?:(?:(?:(?:var|let)[ \t]+)?([\w.\-]+)[ \t]*[:=]|[(!])[ \t]*)function(?:[ \t]+([\w.\-]+))?[ \t]*\([^)]*\)
    It now added "test2" to the list even though this regex matches every test above, but UE doesn't seem to show everything it captures?
    In fact if test 1, 2, 3, 4, 11 and 12 lines removed, that single regex will match all just fine on it's own.

    Any tips how to make it display every function?

    Thank you.

    6,676579
    Grand MasterGrand Master
    6,676579

      Jul 12, 2020#2

      UltraEdit filters out all results of the regular expression finds which have as result an empty string because of listing multiple empty strings in function list view is not really helpful for any programmer. That would be just confusing in my opinion, at least I would be really confused on seeing empty lines at top of a sorted or somewhere in the middle of a non-sorted function list.

      It makes sense to display in function list just the function name and the function parameters for functions with a name. My suggestion for anonymous functions is displaying everything after leading tabs/spaces to end of the keyword function and the parameters of the anonymous functions.

      Please open the wordfile used to syntax highlight JavaScript code. This can be done by opening in UltraEdit a JavaScript file like the file with the example lines, next open Advanced - Settings or Configuration - Editor display - Syntax highlighting, then click on button Open right to the already selected installed wordfile for JavaScript syntax highlighting, and finally close the configuration dialog with a click on button Cancel or symbol X or with key ESC. These steps opens with default configuration the wordfile %APPDATA%\IDMComp\UltraEdit\wordfiles\javascript.uew.

      The wordfile javascript.uew installed with currently latest UltraEdit for Windows v27.00.0.72 contains at top the following block:

      Code: Select all

      /TGBegin "Functions"
      /TGFindStr = "^[ \t]*function[ \t]*(\w+[ \t]*)\(.*\)"
      /TGFindStr = "^[ \t]*function[ \t]*(\w+[ \t]*)\([^\)]*?\)"
      /TGBegin "Parameters"
      /TGFindStr = "[ \t\n]*([^,\s]+)"
      /TGFindBStart = "\("
      /TGFindBEnd = "\)"
      /TGEnd
      /TGEnd
      /TGBegin "Anonymous Functions"
      /TGFindStr = "(?:var[ \t]+)?((?:[\w\.]+))[ \t]*?[:=][ \t]*?function[ \t]*?\([^\)]*?\)"
      /TGEnd
      
      This block must be replaced by the following block:

      Code: Select all

      /TGBegin "Functions"
      /TGFindStr = "(?-i)^[\t ]*(?:[!(]|\w+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*=[\t ]*(?:{\w+[\t ]*:[\t ]*)?)?function[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
      /TGBegin "Parameters"
      /TGFindStr = "[\t\n ]*([^,\s]+)"
      /TGFindBStart = "(?-i)function[\t ]*[\w$]+[\t ]*\("
      /TGFindBEnd = "\)"
      /TGEnd
      /TGEnd
      /TGBegin "Anonymous Functions"
      /TGFindStr = "(?-i)^[\t ]*((?:[!(]|\w+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*=[\t ]*(?:{\w+[\t ]*:[\t ]*)?)?function)[\t ]*[\t ]*\([^\)]*?\)"
      /TGBegin "Parameters"
      /TGFindStr = "[\t\n ]*([^,\s]+)"
      /TGFindBStart = "(?-i)function[\t ]*\("
      /TGFindBEnd = "\)"
      /TGEnd
      /TGEnd
      
      UltraEdit runs the regular expression finds defined in a syntax highlighting wordfile always case-insensitive. I used the Perl regular expression flag (?-i) at beginning of the search expression strings containing JavaScript keywords like function, const, let, or var to run the finds case-sensitive for avoiding false positives.

      I added non-word character $ as this is a valid character in an identifier name in addition to the letters according to the Draft ECMA-262 / July 7, 2020 of ECMAScript® 2021 Language Specification.

      I haven't added zero width non-joiner (U+200C) and zero width joiner (U+200D) which would be valid characters in an identifier name on being not the first character as this would make the Perl regular expression search strings invalid expressions on being executed on a non-Unicode encoded JavaScript file with older versions of UltraEdit.

      The expressions above were tested by me on your example with some additions with UltraEdit for Windows v22.20 and v27.00.

      It would be also possible to use the following block:

      Code: Select all

      /TGBegin "Functions"
      /TGFindStr = "(?-i)^.*\bfunction[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
      /TGBegin "Parameters"
      /TGFindStr = "[\t\n ]*([^,\s]+)"
      /TGFindBStart = "(?-i)function[\t ]*[\w$]+[\t ]*\("
      /TGFindBEnd = "\)"
      /TGEnd
      /TGEnd
      /TGBegin "Anonymous Functions"
      /TGFindStr = "(?-i)^[\t ]*(.*\bfunction)[\t ]*[\t ]*\([^\)]*?\)"
      /TGBegin "Parameters"
      /TGFindStr = "[\t\n ]*([^,\s]+)"
      /TGFindBStart = "(?-i)function[\t ]*\("
      /TGFindBEnd = "\)"
      /TGEnd
      /TGEnd
      
      The two main case-sensitive interpreted Perl regular expression search strings are less restrictive as it can be seen quite easily. But it could happen to get false positives on using these simplified search expressions.

      Note: A user has the option to get the functions listed as found in file or sorted alphabetically via Function List context menu option Sort List. The functions are not sorted alphanumeric. Meaningful function names do not usually start all with same string and the difference is just a number at end of function name with individual number of digits. I have definitely no source file on which an entire function name is the start of another function name. I avoid in all programing and scripting languages identifier names which are included completely in another identifier name. I have learned what is a good and what is a not so good naming scheme in more than 25 years of programming when I need to search for an identifier name easily in thousands of source code files. I don't like it to be forced to use a regular expression find to find one specific identifier name in dozens, hundreds or even thousands of source code files.
      Best regards from an UC/UE/UES for Windows user from Austria

      413
      Basic UserBasic User
      413

        Jul 12, 2020#3

        Thank you very much!

        There is one issue though, it fails recognize functions inside an object on separate line. Here is more complete list of tests, including new arrow functions:

        Code: Select all

        !function(){}();                                // test1
        !function test2(){}();                          // test2
        (function(){})();                               // test3
        (function test4(){})();                         // test4
        test5 = function(){}                            // test5
        test6 = function _test6(){}                     // test6
        let test7 = function(){}                        // test7
        let test8 = function _test8(){}                 // test8
        var test9 = function(){}                        // test8
        var test10 = function _test10(){}               // test10
        const test11 = function(){}                     // test11
        const test12 = function _test12(){}             // test12
        myfunc(function(){})                            // test13
        myfunc(function test14(){})                     // test14
        let myobj15 = {test15 : function(){}}           // test15
        let myobj16 = {test16 : function _test16(){}}   // test16
        var myobj17 = {test17 : function(){}}           // test17
        var myobj18 = {test18 : function _test18(){}}   // test18
        const myobj19 = {test19 : function(){}}         // test19
        const myobj20 = {test20 : function _test20(){}} // test20
        !function(a){}();                               // test21
        !function test22(b){}();                        // test22
        (function(c){})();                              // test23
        (function test24(d){})();                       // test24
        test25 = function(e){}                          // test25
        test26 = function _test26(f){}                  // test26
        let test27 = function(g){}                      // test27
        let test28 = function _test28(h){}              // test28
        var test29 = function(i){}                      // test29
        var test30 = function _test30(j){}              // test30
        const test31 = function(k){}                    // test31
        const test32 = function _test32(l){}            // test32
        myfunc(function(m){})                           // test33
        myfunc(function test34(n){})                    // test34
        let myobj35 = {
          test35 : function(o){}                        // test35
        }
        let myobj36 = {
          test36 : function _test36(p){}                // test36
        }
        var myobj37 = {
          test37 : function(q){}                        // test37
        }
        var myobj38 = {
          test38 : function _test38(r){}                // test38
        }
        
        test39 = () => {}                               // test39
        test40 = v => {}                                // test40
        test41 = (w) => {}                              // test41
        test42 = (x,y) => {}                            // test42
        
        let test43 = v => {}                            // test43
        var myobj44 = {test44 : (w) => {}}              // test44
        const myobj45 = {
          test45 : (x,y) => {}                          // test45
        }
        myfunc(() => {})                                // test46
        myfunc(v => {})                                 // test47
        
        function test48(){}                             // test48
        function test49(s){}                            // test49
        function test50(t,u){}                          // test50
        
        And your regex with added ":" for objects and support (with some issues) for arrow functions:

        Code: Select all

        /TGBegin "Functions"
        /TGFindStr = "(?-i)^[\t ]*(?:[!(]|\w+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{\w+[\t ]*:[\t ]*)?)?function[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
        /TGBegin "Parameters"
        /TGFindStr = "[\t\n ]*([^,\s]+)"
        /TGFindBStart = "(?-i)function[\t ]*[\w$]+[\t ]*\("
        /TGFindBEnd = "\)"
        /TGEnd
        /TGEnd
        /TGBegin "Anonymous Functions"
        /TGFindStr = "(?-i)^[\t ]*((?:[!(]|\w+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{\w+[\t ]*:[\t ]*)?)?function)[\t ]*[\t ]*\([^\)]*?\)"
        /TGBegin "Parameters"
        /TGFindStr = "[\t\n ]*([^,\s]+)"
        /TGFindBStart = "(?-i)function[\t ]*\("
        /TGFindBEnd = "\)"
        /TGEnd
        /TGEnd
        /TGBegin "Arrow Functions"
        /TGFindStr = "(?-i)^[\t ]*((?:[!(]|\w+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{\w+[\t ]*:[\t ]*)?)?)((?:\([^\r\n)]*\)|\w+))[\t ]*=>"
        /TGBegin "Parameters"
        /TGFindStr = "[\t\n ]*([^,\s()\-]+)"
        /TGFindBStart = "\("
        /TGFindBEnd = "\)[\t ]*=>"
        /TGEnd
        /TGEnd
        

        6,676579
        Grand MasterGrand Master
        6,676579

          Jul 13, 2020#4

          You have done a good job.

          I played around about two hours two avoid the false positive function parameter listings for arrow functions with no parameters, but gave it up finally and decided to split up the arrow function searching into two groups, one for arrow functions without parameters and one for arrow functions with parameters.

          Here is my solution:

          Code: Select all

          /TGBegin "Named Functions"
          /TGFindStr = "(?-i)^[\t ]*(?:[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
          /TGBegin "Parameters"
          /TGFindStr = "[\t\n ]*([^,\s]+)"
          /TGFindBStart = "(?-i)function[\t ]*[\w$]+[\t ]*\("
          /TGFindBEnd = "\)"
          /TGEnd
          /TGEnd
          /TGBegin "Anonymous Functions"
          /TGFindStr = "(?-i)^[\t ]*((?:[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function)[\t ]*[\t ]*\([^\)]*?\)"
          /TGBegin "Parameters"
          /TGFindStr = "[\t\n ]*([^,\s]+)"
          /TGFindBStart = "(?-i)function[\t ]*\("
          /TGFindBEnd = "\)"
          /TGEnd
          /TGEnd
          /TGBegin "Arrow Functions (no par.)"
          /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)(?:\([\t ]*?\)|[\w$]+))[\t ]*=>"
          /TGEnd
          /TGBegin "Arrow Functions (with par.)"
          /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)\(\s*?[\w$][^\)]*?\))[\t ]*=>"
          /TGBegin "Parameters"
          /TGFindStr = "[\t\n ]*([^,\s()\-]+)"
          /TGFindBStart = "\("
          /TGFindBEnd = "\)[\t ]*=>"
          /TGEnd
          /TGEnd
          
          I decided to use [\w$]+ instead of just \w+ wherever an identifier name should be matched for a positive match of entire regular expression search string although I doubt that many JavaScript programmers use $ in function and variable/object names.

          Lines with => are ignored on having just ! or ( at beginning of the line after zero or more leading tabs or spaces like !(a,b) => {} which would be invalid when I understood correct the arrow function specification.
          Best regards from an UC/UE/UES for Windows user from Austria

          413
          Basic UserBasic User
          413

            Jul 14, 2020#5

            Awesome!
            And it seems to be working fine if Arrow functions (with par.) is combined with Anonymous section.

            Code: Select all

            /TGBegin "Named Functions"
            /TGFindStr = "(?-i)^[\t ]*(?:[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
            /TGBegin "Parameters"
            /TGFindStr = "[\t\n ]*([^,\s]+)"
            /TGFindBStart = "(?-i)function[\t ]*[\w$]+[\t ]*\("
            /TGFindBEnd = "\)"
            /TGEnd
            /TGEnd
            /TGBegin "Anonymous Functions"
            /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)\(\s*?[\w$][^\)]*?\))[\t ]*=>"
            /TGFindStr = "(?-i)^[\t ]*((?:[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function)[\t ]*[\t ]*\([^\)]*?\)"
            /TGBegin "Parameters"
            /TGFindStr = "[\t\n ]*([^,\s]+)"
            /TGFindBStart = "(?-i)function[\t ]*\("
            /TGFindBEnd = "\)"
            /TGFindStr = "[\t\n ]*([^,\s()\-]+)"
            /TGFindBStart = "\("
            /TGFindBEnd = "\)[\t ]*=>"
            /TGEnd
            /TGEnd
            /TGBegin "Arrow Functions (no par.)"
            /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)(?:\([\t ]*?\)|[\w$]+))[\t ]*=>"
            /TGEnd

            6,676579
            Grand MasterGrand Master
            6,676579

              Jul 16, 2020#6

              There is one more use case of an anonymous function with a parameter not found with the regular expressions above.

              Code: Select all

              $('.reset-store').click(function(e) {
                  e.preventDefault();
                  return window.location.reload();
              });
              
              I modified the function string block to the following block to recognize also this anonymous function with parameter e in example above.

              Code: Select all

              /TGBegin "Named Functions"
              /TGFindStr = "(?-i)^[\t ]*(?:.*?[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
              /TGBegin "Parameters"
              /TGFindStr = "[\t\n ]*([^,\s]+)"
              /TGFindBStart = "(?-i)\bfunction[\t ]*[\w$]+[\t ]*\("
              /TGFindBEnd = "\)(?=[\s{]|//|/\*)"
              /TGEnd
              /TGEnd
              /TGBegin "Anonymous Functions"
              /TGFindStr = "(?-i)^[\t ]*((?:.*?[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function)[\t ]*[\t ]*\([^\)]*?\)"
              /TGBegin "Parameters"
              /TGFindStr = "[\t\n ]*([^,\s]+)"
              /TGFindBStart = "(?-i)\bfunction[\t ]*\("
              /TGFindBEnd = "\)(?=[\s{]|//|/\*)"
              /TGEnd
              /TGEnd
              /TGBegin "Arrow Functions (no par.)"
              /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)(?:\([\t ]*?\)|[\w$]+))[\t ]*=>"
              /TGEnd
              /TGBegin "Arrow Functions (with par.)"
              /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)\(\s*?[\w$][^\)]*?\))[\t ]*=>"
              /TGBegin "Parameters"
              /TGFindStr = "[\t\n ]*([^,\s()\-]+)"
              /TGFindBStart = "\("
              /TGFindBEnd = "\)[\t ]*=>"
              /TGEnd
              /TGEnd
              
              The same modifications applied on alternative block with combined Anonymous Functions and Arrow Functions (no par.):

              Code: Select all

              /TGBegin "Named Functions"
              /TGFindStr = "(?-i)^[\t ]*(?:.*?[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
              /TGBegin "Parameters"
              /TGFindStr = "[\t\n ]*([^,\s]+)"
              /TGFindBStart = "(?-i)\bfunction[\t ]*[\w$]+[\t ]*\("
              /TGFindBEnd = "\)(?=[\s{]|//|/\*)"
              /TGEnd
              /TGEnd
              /TGBegin "Anonymous Functions"
              /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)\(\s*?[\w$][^\)]*?\))[\t ]*=>"
              /TGFindStr = "(?-i)^[\t ]*((?:.*?[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function)[\t ]*[\t ]*\([^\)]*?\)"
              /TGBegin "Parameters"
              /TGFindStr = "[\t\n ]*([^,\s]+)"
              /TGFindBStart = "(?-i)\bfunction[\t ]*\("
              /TGFindBEnd = "\)(?=[\s{]|//|/\*)"
              /TGFindStr = "[\t\n ]*([^,\s()\-]+)"
              /TGFindBStart = "\("
              /TGFindBEnd = "\)[\t ]*=>"
              /TGEnd
              /TGEnd
              /TGBegin "Arrow Functions (no par.)"
              /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)(?:\([\t ]*?\)|[\w$]+))[\t ]*=>"
              /TGEnd
              
              There can be now anything left to ! or ( which is left to keyword function which of course could result in false positives.

              The expression to find the beginning of the function parameters block is a little bit more restrictive because of adding \b left to keyword function to avoid some special false positives.

              The expression to find the end of the function parameters block is also more restrictive as there must be now after ) a whitespace character or { (beginning of function body) or // (beginning of a line comment) or /* (beginning of a block comment). The additional restrictions avoid some wrong detected endings of function parameter blocks.

                Aug 04, 2020#7

                There is installed with UltraEdit for Windows v27.00.0.94 and UEStudio v20.00.0.50 an updated javascript.uew and also an updated css.uew for syntax highlighting of JavaScript code and CSS definitions. The syntax highlighting wordfile javascript.uew contains the improved function strings definition as developed by V@no and me. The wordfile css.uew contains additional CSS keywords.

                The following copy operation must be done to get the two wordfiles used after the update on using default installation path and default wordfiles directory and haven't customized these two wordfiles at all.

                64-bit UltraEdit on 64-bit Windows and 32-bit UltraEdit on 32-bit Windows:
                css.uew and javascript.uew must be copied from %ProgramFiles%\IDM Computer Solutions\UltraEdit\wordfiles to %APPDATA%\IDMComp\UltraEdit\wordfiles with replacing the two existing wordfiles in the destination directory.

                32-bit UltraEdit on 64-bit Windows:
                css.uew and javascript.uew must be copied from %ProgramFiles(x86)%\IDM Computer Solutions\UltraEdit\wordfiles to %APPDATA%\IDMComp\UltraEdit\wordfiles with replacing the two existing wordfiles in the destination directory.

                64-bit UEStudio on 64-bit Windows and 32-bit UEStudio on 32-bit Windows:
                css.uew and javascript.uew must be copied from %ProgramFiles%\IDM Computer Solutions\UEStudio\wordfiles to %APPDATA%\IDMComp\UEStudio\wordfiles with replacing the two existing wordfiles in the destination directory.

                32-bit UEStudio on 64-bit Windows:
                css.uew and javascript.uew must be copied from %ProgramFiles(x86)%\IDM Computer Solutions\UEStudio\wordfiles to %APPDATA%\IDMComp\UEStudio\wordfiles with replacing the two existing wordfiles in the destination directory.

                The source directory path can be different on having installed UltraEdit or UEStudio for current user only or with using the advanced installation option for an installation to a custom directory.
                The destination directory path can be different on using a custom directory for wordfiles as displayed in configuration window opened in UltraEdit or UEStudio via Advanced - Settings or Configuration - Editor display - Syntax highlighting.

                In case of css.uew or javascript.uew was customized by a user in the past and the modifications of newly installed wordfiles should be taken over without losing the customizations, a text file comparison must be done with the wordfile in subdirectory wordfiles in program files directory of UE/UES with the appropriate wordfile in subdirectory wordfiles in UltraEdit/UEStudio application data directory of the user account respectively the configured wordfiles directory with merging the differences to customized css.uew or javascript.uew which should be taken over from updated default wordfile.
                Best regards from an UC/UE/UES for Windows user from Austria

                413
                Basic UserBasic User
                413

                  Oct 17, 2020#8

                  Found some problematic functions:

                  Code: Select all

                  ; function nonAnnon (param){} //should be non-Anonymous
                  obj.blah = function (param){} //only shows "blah" as variable
                  obj.blah = function testObj(param){} //not recognized
                  func("b", function testFunc(param){}); //not recognized
                  
                  I'm using combined version for anonymous and arrow functions and this is my fix for these issues:

                  Code: Select all

                  /TGBegin "Named Functions"
                  /TGFindStr = "(?-i)^[\t ;]*(?:.*?[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function[\t ]*([\w$]+)[\t ]*\([^\)]*?\)"
                  /TGBegin "Parameters"
                  /TGFindStr = "[\t\n ]*([^,\s]+)"
                  /TGFindBStart = "(?-i)\bfunction[\t ]*[\w$]+[\t ]*\("
                  /TGFindBEnd = "\)(?=[\s{]|//|/\*)"
                  /TGEnd
                  /TGEnd
                  /TGBegin "Anonymous Functions"
                  /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[._\w$]+[\t ]*[:=,][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)\(\s*?[\w$][^\)]*?\))[\t ]*=>"
                  /TGFindStr = "(?-i)(?:^[\t ]*)?((?:.*?[!(]|[\w$]+\(|(?:(?:const|let|var)[\t ]+)?[._\w$]+[\t ]*[:=,][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)?function)[\t ]*([\w$]+)?[\t ]*\([^\)]*?\)"
                  /TGBegin "Parameters"
                  /TGFindStr = "[\t\n ]*([^,\s]+)"
                  /TGFindBStart = "(?-i)\bfunction[\t ]*\("
                  /TGFindBEnd = "\)(?=[\s{]|//|/\*)"
                  /TGFindStr = "[\t\n ]*([^,\s()\-]+)"
                  /TGFindBStart = "\("
                  /TGFindBEnd = "\)[\t ]*=>"
                  /TGEnd
                  /TGEnd
                  /TGBegin "Arrow Functions (no par.)"
                  /TGFindStr = "(?-i)^[\t ]*((?:[\w$]+[\t ]*?\(|(?:(?:const|let|var)[\t ]+)?[\w$]+[\t ]*[:=][\t ]*(?:{[\w$]+[\t ]*:[\t ]*)?)(?:\([\t ]*?\)|[\w$]+))[\t ]*=>"
                  /TGEnd
                  
                  [EDIT]
                  Crap, now named functions are captured by anonymous functions too...

                  41
                  NewbieNewbie
                  41

                    Feb 08, 2023#9

                    Mofi wrote:
                    Aug 04, 2020
                    There is installed with UltraEdit for Windows v27.00.0.94 and UEStudio v20.00.0.50 an updated javascript.uew and also an updated css.uew for syntax highlighting of JavaScript code and CSS definitions. The syntax highlighting wordfile javascript.uew contains the improved function strings definition as developed by V@no and me. The wordfile css.uew contains additional CSS keywords.

                    The following copy operation must be done to get the two wordfiles used after the update on using default installation path and default wordfiles directory and haven't customized these two wordfiles at all.

                    64-bit UltraEdit on 64-bit Windows and 32-bit UltraEdit on 32-bit Windows:
                    css.uew and javascript.uew must be copied from %ProgramFiles%\IDM Computer Solutions\UltraEdit\wordfiles to %APPDATA%\IDMComp\UltraEdit\wordfiles with replacing the two existing wordfiles in the destination directory.

                    32-bit UltraEdit on 64-bit Windows:
                    css.uew and javascript.uew must be copied from %ProgramFiles(x86)%\IDM Computer Solutions\UltraEdit\wordfiles to %APPDATA%\IDMComp\UltraEdit\wordfiles with replacing the two existing wordfiles in the destination directory.

                    64-bit UEStudio on 64-bit Windows and 32-bit UEStudio on 32-bit Windows:
                    css.uew and javascript.uew must be copied from %ProgramFiles%\IDM Computer Solutions\UEStudio\wordfiles to %APPDATA%\IDMComp\UEStudio\wordfiles with replacing the two existing wordfiles in the destination directory.

                    32-bit UEStudio on 64-bit Windows:
                    css.uew and javascript.uew must be copied from %ProgramFiles(x86)%\IDM Computer Solutions\UEStudio\wordfiles to %APPDATA%\IDMComp\UEStudio\wordfiles with replacing the two existing wordfiles in the destination directory.

                    The source directory path can be different on having installed UltraEdit or UEStudio for current user only or with using the advanced installation option for an installation to a custom directory.
                    The destination directory path can be different on using a custom directory for wordfiles as displayed in configuration window opened in UltraEdit or UEStudio via Advanced - Settings or Configuration - Editor display - Syntax highlighting.

                    In case of css.uew or javascript.uew was customized by a user in the past and the modifications of newly installed wordfiles should be taken over without losing the customizations, a text file comparison must be done with the wordfile in subdirectory wordfiles in program files directory of UE/UES with the appropriate wordfile in subdirectory wordfiles in UltraEdit/UEStudio application data directory of the user account respectively the configured wordfiles directory with merging the differences to customized css.uew or javascript.uew which should be taken over from updated default wordfile.
                    What do us users on the Mac version of UltraEdit 2022.0.0.16 need to change to get this /TG syntax to work?
                    My javascript.uew file in ~/Library/Application Support/UltraEdit/wordfiles/javascript.uew
                    shows these "Function String..." lines at the top: 

                    Code: Select all

                    /L10"JavaScript" JSCRIPT_LANG Line Comment = // Block Comment On = /* Block Comment Off = */ Escape Char = \ String Chars = '" File Extensions = JS
                    /Delimiters = ~!@%^&*()-+=|\/{}[]:;"'<> , .?
                    /Function String = "%[ ^t]++function[ ^t]++^([a-zA-Z_][a-zA-Z_0-9]++[^t ]++(*)^)"
                    /Function String 1 = "%[ ^t]++^(*^)=[ ^t]++function[ ^t]++(*)"
                    /Function String 2 = "%[ ^t]++^(*^):[ ^t]++function[ ^t]++(*)"
                    /Indent Strings = "{" "else"
                    /Unindent Strings = "}"
                    /Open Brace Strings =  "{" "(" "[" "<"
                    /Close Brace Strings = "}" ")" "]" ">"
                    /Open Fold Strings = "{"
                    /Close Fold Strings = "}"
                    I'm trying to develop a custom wordfile that colleagues on Mac and Window can both use. Is this possible?

                    Thanks!

                    6,676579
                    Grand MasterGrand Master
                    6,676579

                      Feb 09, 2023#10

                      I don't use UltraEdit for Mac. I don't know for that reason if UltraEdit for Mac supports a hierarchical (grouped) function list and also the usage of the Perl regular expression engine instead of the UltraEdit regular expression engine for searching for strings to show in the function list view. Perl regular expression support is definitely required to be able to use the regular expressions as used in the wordfiles of UltraEdit for Windows.

                      I suggest to extract and use from the attached ZIP file first css.uew and javascript.uew from directory ue_win_v2022_2 which are from UltraEdit for Windows v2022.2.

                      In case of a hierarchical function list is not supported at all by UltraEdit for Mac, there are in the directory old_style in the attached ZIP file the two wordfiles with the Perl regular expression search strings adapted for a flat function list view using old style function string definitions.

                      The wordfile css.uew contains strings with word delimiters which was not possible prior UltraEdit for Windows v2022.1. It could be that these strings are not highlighted in a CSS file by UltraEdit for Mac as by currently latest UltraEdit for Windows.
                      css_javascript_wordfiles.zip (26.17 KiB)   3
                      UltraEdit syntax highlighting wordfiles for CSS and JavaScript
                      Best regards from an UC/UE/UES for Windows user from Austria