Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++ function list PHP not working if I didn't close the PHP tag

I want to use function list feature from notepad++ for my PHP code Actually the function list is working normally if I write the close PHP tag ( ?> ).. But if I didn't close the PHP tag, the function list is not working

I just want, the function list is still working even I didn't close the PHP tag

See the image On the top is without close PHP tag On the bottom is with close PHP tag

Then I read this, notepad++ function list doc https://notepad-plus-plus.org/features/function-list.html

I guess, I need to edit the regex.. But the problem is I can't edit the regex because the regex looks like too complex for me

This is the regex and xml of PHP function list

<parser id="php_function" displayName="PHP" commentExpr="((/\*.*?\*)/|(//.*?$))">
<classRange
    mainExpr="^[\s]*(class|abstract[\s]+class|final[\s]+class)[\t ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*([\s]*|[\s]*(extends|implements|(extends[\s]+(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)+[\s]+implements))[\s]+(\,[\s]*|(\\|[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))+[\s]*)?\{"
    openSymbole = "\{"
    closeSymbole = "\}"
    displayMode="node">
    <className>
        <nameExpr expr="(class|abstract[\s]+class|final[\s]+class)[\s]+[\w]+"/>
        <nameExpr expr="[\s]+[\w]+\Z"/>
        <nameExpr expr="[\w]+\Z"/>
    </className>
    <function
        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]*\([^\{]*\{">
        <functionName>
            <funcNameExpr expr="(?!(if|while|for|switch))[\w_]+[\s]*\([^\{]*"/>
            <!-- comment below node if want display method with parmas -->
            <funcNameExpr expr="(?!(if|while|for|switch))[\w_]+"/>
        </functionName>
    </function>
</classRange>
<function
    mainExpr="^[\s]*function[\s]+\w+\("

    displayMode="$className->$functionName">
    <functionName>
        <nameExpr expr="(?!(if|while|for))[\w_]+[\s]*\("/>
        <nameExpr expr="(?!(if|while|for))[\w_]+"/>
    </functionName>
    <className>
        <nameExpr expr="[\w_]+(?=[\s]*::)"/>
    </className>
</function>
</parser>

Can someone help me

Thank you

like image 596
d_nizh Avatar asked Jan 30 '16 12:01

d_nizh


3 Answers

[Solved]

We just need to add enter/add new line after close the class or function tag

So maybe this is a bug

Thanks

like image 193
d_nizh Avatar answered Nov 09 '22 17:11

d_nizh


For me the problem was that there was no closing PHP tag.

May be that helps someone.

Add a "?>" closing PHP tag if it is already not there.

like image 42
Rohit Ailani Avatar answered Nov 09 '22 15:11

Rohit Ailani


There are several reasons why function list can't render function tree.

  1. In older versions of Notepad++ PHP section closing tab is required. Just simple add ?> at the end of file. Sometimes after closing tab new line is required.
  2. functionList.xml incorrect parse PHP file. For example this function description broke function list rendering:
    /**
     * Unset an instance of this class.
     *
     * @param Spreadsheet $spreadsheet Injected spreadsheet identifying the instance to unset
     */
    public function __destruct()
    {
        $this->workbook = null;
    }

In this case you must change (or add) commentExpr In functionList.xml in %APPDATA% (There are two functionList.xml locations. Program Files directory and %APPDATA% directory)

<parser
    id         ="php_syntax"
    displayName="PHP"
    commentExpr="(?'MLC'(?s-m)/\*.*?\*/)|(?'SLC'(?m-s)(?:#|/{2}).*$)|(?'STRLIT'(?s-m)&quot;[^&quot;\\]*(?:\\.[^&quot;\\]*)*&quot;|&apos;[^&apos;\\]*(?:\\.[^&apos;\\]*)*&apos;)"
>
like image 2
JK_ Avatar answered Nov 09 '22 17:11

JK_