function-list



  • Hi, has anybody an idea?

    notepad++ (vers. 6.9) doesn’t show static functions in the function-list.

    Is there any way to change it?

    Thanks

    Michael



  • Hello @Michael-Peter,

    Is there any way to change it?

    I assume so, either you check functionList.xml if there is something you can change
    or you provide a little bit more information about which language you are talking.
    Please don’t expect that everyone knows the language in detail so an example
    to illustrate your question might be helpful as well.

    Cheers
    Claudia



  • Oh, sorry, the language is PHP.

    If I have construction like below, the functionlist shows funktion f2, but not f1.

    CODE:

    <?php declare(strict_types=1);
    class Html {

    // ------------------------------------------------------------------
    static function f1() {
    // ------------------------------------------------------------------
    echo ‘hello world’;
    }

    // ------------------------------------------------------------------
    function f2() {
    // ------------------------------------------------------------------
    echo ‘hello world’;
    }

    ?>



  • Hello @Michael-Peter,

    code is missing the closing } for the class.

    Cheers
    Claudia



  • Hello @Michael-Peter,

    in addition to the missing } another issue is when having class code which isn’t indented then it doesn’t
    find the function as well. The mainExpr needs to be changed, to be more concrete the second check
    about static|public … starts with \s+ which means, there must be at least one space before the modifier follows.
    To solve this \s+ needs to be replaced to \s*
    Like this

    mainExpr="^[\s]*((static|public|protected|private|final)*(\s*(static|public|protected|private|final))+[\s]+)?(function[\s]+)+([\w]+([\s]+[\w]+)?([\s]+|\*[\s]+|[\s]+\*|[\s]+\*[\s]+))?([\w_]+[\s]*::)?(?!(if|while|for|switch))[\w_~]+[\s]*\([^\{]*\{">
    

    Cheers
    Claudia



  • Hello Michael,

    In addition to the two correct assertions, in the Claudia’s post, concerning :

    • The missing closing brace, for the class Html

    • The change of \s+ into \s*, in the regex relative to a function, embedded in a class

    may be, it would be judicious to change, also, at line #196, the regex, for mainExpr of a function, located outside a class, into :

    mainExpr="^[\s]*((static|public|protected|private|final)\s+)?function[\s]+\w+\("
    

    I just added the list of each possible reserved word, that may be located BEFORE the word function, and some mandatory blank characters, with the regex ((static|public|protected|private|final)\s+)?

    I said “may be”, as I don’t know the PHP language, unfortunately :-((

    But, considering the example below :

    <?php declare(strict_types=1);
    class Html {
    
    // ------------------------------------------------------------------
    static function f1() {
    // ------------------------------------------------------------------
    echo ‘hello world’;
    }
    
    // ------------------------------------------------------------------
    function f2() {
    // ------------------------------------------------------------------
    echo ‘hello world’;
    }
    }
    
    // ------------------------------------------------------------------
    private function f3() {
    // ------------------------------------------------------------------
    echo ‘hello world’;
    }
    
    // ------------------------------------------------------------------
    function f4() {
    // ------------------------------------------------------------------
    echo ‘hello world’;
    }
    
    ?>
    

    With my modification, at line #196, the function f3, as well as the functions f1, f2 and f4, appears, too, in the Function List panel !

    Best Regards,

    guy038

    P.S. :

    You can modify the functionList.xml file, directly, from inside Notepad++. Just close and re-start N++ to get the modifications in the Function List panel !



  • Hello @guy038,

    afaik the modifiers are only allowed in classes.
    You cannot have a function, outside a class, defined as e.g. private function xyz().
    I did a quick search on the internet but didn’t find a hint that it is possible now.
    But if I’m wrong, then of course your changes make sense (as always;-))

    Cheers
    Claudia

    Btw. don’t tell me your still skiing ;-)



  • Claudia Frank matches the point with her contribution: “…another issue is when having class code which isn’t indented then it doesn’t find the function as well…”.

    Thanks a lot…


Log in to reply