• Login
Community
  • Login

Improving Function parser for JavaScript functions

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 2 Posters 3.8k Views
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.
  • E
    Edtech Everywhere
    last edited by Jan 10, 2016, 12:27 PM

    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?

    C 1 Reply Last reply Jan 10, 2016, 5:35 PM Reply Quote 0
    • C
      Claudia Frank @Edtech Everywhere
      last edited by Jan 10, 2016, 5:35 PM

      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
      • E
        Edtech Everywhere
        last edited by Jan 10, 2016, 6:34 PM

        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.

        C 1 Reply Last reply Jan 11, 2016, 6:34 PM Reply Quote 0
        • C
          Claudia Frank @Edtech Everywhere
          last edited by Jan 11, 2016, 6:34 PM

          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
          • E
            Edtech Everywhere
            last edited by Jan 15, 2016, 6:32 PM

            Hi Claudia!

            Thanks!

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

            C 1 Reply Last reply Jan 15, 2016, 6:42 PM Reply Quote 0
            • C
              Claudia Frank @Edtech Everywhere
              last edited by Jan 15, 2016, 6:42 PM

              @Edtech-Everywhere

              thank you for the feedback and testing.

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 0
              2 out of 6
              • First post
                2/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors