【问题标题】:Notepad++ function list PHP not working if I didn't close the PHP tag如果我没有关闭 PHP 标记,Notepad++ 函数列表 PHP 不起作用
【发布时间】:2016-01-30 12:30:20
【问题描述】:

我想在我的 PHP 代码中使用 notepad++ 中的函数列表功能 实际上,如果我写了关闭 PHP 标记 ( ?> ),函数列表可以正常工作。但是如果我没有关闭 PHP 标记,则函数列表不起作用

我只是想要,即使我没有关闭PHP标签,函数列表仍然有效

查看图片 顶部没有关闭 PHP 标记 底部带有关闭的 PHP 标记

然后我读到了这个,notepad++ 函数列表文档 https://notepad-plus-plus.org/features/function-list.html

我想,我需要编辑正则表达式。但问题是我无法编辑正则表达式,因为正则表达式看起来对我来说太复杂了

这是PHP函数列表的正则表达式和xml

<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>

谁能帮帮我

谢谢

【问题讨论】:

  • 抱歉英语不好
  • 那你自己写答案

标签: php regex function plugins notepad++


【解决方案1】:

[已解决]

我们只需要在关闭类或函数标签后添加回车/添加新行

所以也许这是一个错误

谢谢

【讨论】:

    【解决方案2】:

    对我来说,问题是没有关闭 PHP 标记。

    可能对某人有帮助。

    添加一个“?>”结束 PHP 标记(如果它已经不存在)。

    【讨论】:

      【解决方案3】:

      函数列表无法渲染函数树的原因有多种。

      1. 在旧版本的 Notepad++ PHP 部分需要关闭标签。只需在文件末尾添加 ?&gt; 即可。有时在关闭标签后需要换行。
      2. functionList.xml 解析 PHP 文件不正确。例如这个函数描述破坏了函数列表渲染:
      /** * 取消设置此类的一个实例。 * * @param Spreadsheet $spreadsheet 注入的电子表格,标识要取消设置的实例 */ 公共函数 __destruct() { $this->workbook = null; }

      在这种情况下,您必须在 %APPDATA% 的 functionList.xml 中更改(或添加)commentExpr (有两个functionList.xml位置。Program Files目录和%APPDATA%目录)

      <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;)"
      >
      

      【讨论】:

        【解决方案4】:

        内部“功能列表”对我来说根本不起作用。我试图删除一个或两个“functionlist.xml”文件,这是在某些网站上推荐的,但对我没有任何效果。

        我更喜欢插件“functionList” https://sourceforge.net/projects/npp-plugins/files/Function%20List/

        补丁来自 https://github.com/gwarnants/FunctionList-PHP-Patch

        在我的 Notepad++ 6.9.2 上效果很好

        【讨论】:

          【解决方案5】:

          在functionList.xml 中替换php 解析器。使用你可以在 notepad++ 论坛中找到的这个新的 ->

          https://notepad-plus-plus.org/community/topic/15124/php-function-list-and-abstract-functions/17

          它可以处理抽象类和函数。

          【讨论】:

            猜你喜欢
            • 2017-01-05
            • 2011-08-15
            • 2014-05-15
            • 2013-08-31
            • 1970-01-01
            • 1970-01-01
            • 2010-11-22
            • 2016-06-29
            • 1970-01-01
            相关资源
            最近更新 更多