ActionScript Support for TextMate's TmCodeBrowser Plugin

Update 2007-05-30: Added support for const vars

One of the things I’ve been searching for ever since I switched over to using TextMate for ActionScript development has been code browsing of classes/properties/methods. TextMate has the method list in the status bar, but that’s it. I found the TmCodeBrowser plugin recently, and it worked…for everything except for ActionScript. After some back-and-forth emails with Gerd Knops, the author of TmCodeBrowser, here’s how I extended it to support AS files.

  1. Download and install the TmCodeBrowser plugin.
  2. Create a file named .ctags.tmcodebrowser in your home directory (Note the period before the name). TmCodeBrowser will read in the ActionScript search patterns in this file in addition to the default spec for the other languages.
  3. Paste in the following lines into .ctags.tmcodebrowser. YOU MUST add a linebreak after the last line; for some reason the last regex is ignored without the linebreak.
  4. --langdef=ActionScript
    --langmap=ActionScript:.as
    --regex-ActionScript=/^[ \t]*package[ \t]*([A-Za-z0-9_\ \.]*)[ \t]*/\1/package/
    --regex-ActionScript=/^[ \t]*[(private|public|static|protected|internal|\ )( \t)]*function[ \t]+([A-Za-z0-9_]+)[ \t]*\(/\1/method,methods/
    --regex-ActionScript=/.*\.prototype\.([A-Za-z0-9 ]+)=([ \t]?)function([ \t]?)*\(/\1/m,method,methods/
    --regex-ActionScript=/^[ \t]*[(public|private|static|protected|internal|\ )]+[( \t)]*(var|const)[ \t]+([\$]*[A-Za-z0-9_]+)[ \t]*/\2/p,property,properties/
    --regex-ActionScript=/^[ \t]*[(public|private|static|protected|internal|\ )]*[( \t)]*class[ \t]+([A-Za-z0-9_.]+)[ \t]*/\1/c,class,classes/
    
    
  5. Save .ctags.tmcodebrowser and relaunch TextMate.

Gerd explained to me that TmCodeBrowser updates after saving a file. I realized this after opening an AS file and the CodeBrowser panel came up empty. Saving the file refreshed the CodeBrowser.