notepad++的函数列表插件运行良好,只是函数名以"for / while / if“开头。
例如,我在表单类中有函数。因此,它们以"form“(例如form_information)开头。所以函数名不会出现在函数列表中,因为函数名以'for‘开头。
有人也有同样的问题吗,或者可能是这个问题的解决方案?
这是PHP函数列表的regex和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>
谢谢您抽时间见我!
发布于 2016-08-29 07:21:18
我刚刚看了一下%APPDATA%\Notepad++\functionList.xml,,看起来问题是在没有字词边界的情况下检查了if|while|for|switch。您需要在适当的位置添加单词边界。请参见修改后的第一个<function>节点:
<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]*::)?\b(?!(if|while|for|switch)\b)[\w_~]+[\s]*\([^\{]*\{">
<functionName>
<funcNameExpr expr="\b(?!(if|while|for|switch)\b)[\w_]+[\s]*\([^\{]*"/>
<!-- comment below node if want display method with parmas -->
<funcNameExpr expr="\b(?!(if|while|for|switch)\b)[\w_]+"/>
</functionName>
</function> POI是\b(?!(if|while|for|switch)\b) -词边界,在负前瞻之前,在交替组之后,只匹配这些单词作为整个单词。

发布于 2016-08-29 07:22:00
解析器的一个问题是它测试函数名不是if、while、for或switch。但是它不检查名字是否继续-例如form。在正则表达式中添加一个单词边界,它可能会对您有所帮助。
将(?!(if|while|for|switch))更改为
(?!(if|while|for|switch)\b)和(?!(if|while|for))到
(?!(if|while|for)\b)这可能对你有帮助。
https://stackoverflow.com/questions/39200387
复制相似问题