RSS Feed

Blog

Notepad++ Function List for PHP

Notepad++ Function List for PHP
Posted on Oct 1, 2013 by Stephen Owens
Tutorial and Code category
   [ Return ]

Notepad++ added a function list panel (starting with v6.4.1), which can be customized for any programming language by adding a XML parser node to the functionList.xml file. This is a notepad++ function list parser for PHP.

How to Setup the PHP Function List in Notepad++

Notepad++ comes with a few function list parsers pre-configured. To add support for PHP you will need to open the functionList.xml file which is typically found at %APPDATA%\notepad++\

Under a default install on Windows 7, it is located under
C:\Users\[username]\AppData\Roaming\Notepad++\

More about the Notepad++ Function List, and how to setup your own custom language function list parser.

At the top of the file find the node <associationMap> then under it add:

  1. <association langID = "1" id="php_function"/>

view RAW source: http://pastebin.com/raw.php?i=vNQBZU61

Then under the node <parsers> add the following node:

  1. <!--
    
  2. PHP Function List Parser Node for Notepad++
    
  3. http://notepad-plus-plus.org/features/function-list.html
    
  4. -->
    
  5.       <parser id="php_function" displayName="PHP
    source"
    commentExpr="((/\*.*?\*)/|(//.*?$)|(#.*?$))">
    
  6.           <classRange mainExpr="^[\t ]*(((class|interface)[\t
    ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*[\t
    ]+((extends|implements)[\t
    ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)?)|(trait[\t
    ]+[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))\s*\{"
    
  7.               openSymbole="\{"
    
  8.               closeSymbole="\}"
    
  9.               displayMode="node">
    
  10.               <className>
    
  11.                   <nameExpr expr="(class[\t ]+|interface[\t
    ]+|trait[\t ]+)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*"/>
    
  12.                   <nameExpr expr="[\t ]+[\w]+"/>
    
  13.                   <nameExpr expr="[\w]+"/>
    
  14.               </className>
    
  15.               <function mainExpr="^[\t ]*(public[\t
    ]+|protected[\t ]+|private[\t ]+)?(static[\t ]+)?function[\s]+&?[\t
    ]*([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\([^\)\(]*\)|\([^\)\(]*\))[\n\s]*\{">
    
  16.                   <functionName>
    
  17.                       <funcNameExpr
    expr="function[\s]+&?[\t
    ]*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*"/>
    
  18.                       <funcNameExpr
    expr="[\s]+&?[\w]+"/>
    
  19.                       <funcNameExpr
    expr="[^&\s]+"/>
    
  20.                   </functionName>
    
  21.               </function>
    
  22.           </classRange>
    
  23.           <function mainExpr="^[\t ]*function[\s]+&?[\t
    ]*([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\([^\)\(]*\)|\([^\)\(]*\))[\n\s]*\{"
    
  24.               displayMode="$className->$functionName">
    
  25.               <functionName>
    
  26.                   <nameExpr
    expr="(?!(if|while|for|switch))[\w_]+[\s]*\("/>
    
  27.                   <nameExpr
    expr="(?!(if|while|for|switch))[\w_]+"/>
    
  28.               </functionName>
    
  29.           </function>
    
  30.       </parser>

view RAW source: http://pastebin.com/raw.php?i=wcHnrqfH

Discussion on the Notepad++ Function List Parser

A discussion on this PHP parser and others can be found on the Source Forge page for Notepad++.

Share
Like what you read? Get updates for free!
comments powered by Disqus