Community
    • Login

    Improving Function parser for JavaScript functions

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 4.2k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Edtech EverywhereE Offline
      Edtech Everywhere
      last edited by

      Current Function List for JavaScript includes all asynchronous calls into the function list.

      For example,
      setTimeout(function (req, res) { });

      will be recognized as a function with the name function() in the list. How to alter functionList.xml to exclude functions without names in Function List?

      Claudia FrankC 1 Reply Last reply Reply Quote 0
      • Claudia FrankC Offline
        Claudia Frank @Edtech Everywhere
        last edited by

        Hello Edtech-Everywhere,
        actually, if I paste your example into the editor, I don’t have the function listed, even
        after pressing refresh multiple times.
        Are you sure you do not use an modified functionList.xml?

        Cheers
        Claudia

        1 Reply Last reply Reply Quote 0
        • Edtech EverywhereE Offline
          Edtech Everywhere
          last edited by

          Hi Claudia,

          Thanks. I agree that exact example was not correct. Please try to insert a space between setTimeout and function:

          setTimeOut( function(x){ });

          functionList.xml is from original distribution.

          Claudia FrankC 1 Reply Last reply Reply Quote 0
          • Claudia FrankC Offline
            Claudia Frank @Edtech Everywhere
            last edited by

            Hello @Edtech-Everywhere,

            ok, I tried to understand the mainExpr regex but must say I’m not really sure if I did, nevertheless
            when inserting \K after function it seems to work, atleast it did work with my example shown below.

            Old:

            "((^|[\s]+|[;\}\.])([_A-Za-z][\w_]*\.)*[_A-Za-z][\w_]*[\s]*[=:]|^|[\s;\}]+)[\s]*function([\s]+[_A-Za-z]?[\w_]*\([^\)\(]*\)|\([^\)\(]*\))[\n\s]*\{"
            

            New:

            "((^|[\s]+|[;\}\.])([_A-Za-z][\w_]*\.)*[_A-Za-z][\w_]*[\s]*[=:]|^|[\s;\}]+)[\s]*function\K([\s]+[_A-Za-z]?[\w_]*\([^\)\(]*\)|\([^\)\(]*\))[\n\s]*\{"
            

            Example:

            hello();
            function hello() {document.write('Hello');}
            
            setTimeOut( function(x){ });
            
            <HTML>
                <HEAD>
                    <TITLE>Estate Agent 2</TITLE>
                    <SCRIPT>
                        function House(name,rooms,price,garage) {
                            this.name=name;
                            this.rooms=rooms;
                            this.price=price;
                            this.garage=garage;
                            this.view=view;
                        }
                        function view() {
                            with (this) document.write(name+' has '+rooms+' rooms, '+(garage?'a':'no')+' garage, and costs £'+price+'<BR>');
                        }
                        house1=new House('House 1',4,100000,false);
                        house2=new House('Big House',5,200000,true);
                        house1.view();
                        house2.view();
                    </SCRIPT>
                </HEAD>
            </HTML>
            

            May I ask you to test this extensively and report back if it does what it should and
            no other thing has been broken?

            Cheers
            Claudia

            1 Reply Last reply Reply Quote 0
            • Edtech EverywhereE Offline
              Edtech Everywhere
              last edited by

              Hi Claudia!

              Thanks!

              It seems that the issue has been solved. I will keep you updated if I found any bugs.

              Claudia FrankC 1 Reply Last reply Reply Quote 0
              • Claudia FrankC Offline
                Claudia Frank @Edtech Everywhere
                last edited by

                @Edtech-Everywhere

                thank you for the feedback and testing.

                Cheers
                Claudia

                1 Reply Last reply Reply Quote 0

                Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                With your input, this post could be even better 💗

                Register Login
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors