2016-08-29 3 views
0

関数リストのnotepad ++からの関数リストプラグインは正しく機能していますが、関数名はfor/while/ifで始まります。メモ帳++関数リスト関数名がreserverd wordsで始まる場合、PHPが動作しません。

たとえば、私はフォームクラスの関数を持っています。つまり、「フォーム」(form_informationなど)から始まります。 関数名は 'for'で始まるので、関数名は関数リストには表示されません。

誰かが同じ問題を抱えているのでしょうか、それともこの正規表現の解決策ですか?

これは、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> 

お時間をいただき、ありがとうございます!

+0

'(?if(while | for | switch))')を '(?while | forスイッチ)\ b)'に変更し、 '(? )) 'yo'(?!(while | for)\ b) '..それはあなたを助けるかもしれません。 – ClasG

+0

ありがとうございました!それも私のために働いた:) –

答えて

0

私はちょうど%のAPPDATA%\メモ帳++ \ 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)ある - 唯一の単語全体としてこれらの単語にマッチする単語境界否定先読みする前に、右の交代グループの後。

enter image description here

+0

ありがとう!それは私のために働いた! –

+0

はい、ここで先頭と末尾に '\ b'sが必要であることに気をつけてください。そうしないと、見出しは行の各文字の前に実行されます。 –

0

あなたのパーサーの問題点は、機能名がifwhileforswitchないことをテストすることです。しかし、名前が続くかどうかはチェックしません。 form。正規表現に単語境界を追加すると、それはあなたを助けるかもしれません。

変更(?!(if|while|for|switch))

(?!(if|while|for|switch)\b) 

とあなたを助けるかもしれない

(?!(if|while|for)\b) 

から(?!(if|while|for))

+0

ありがとう!それも私のために働いた:) –

関連する問題