Thursday, January 08, 2009

Viewing the lexer tokens of a file

This tip is only for the serious NetBeans geek, but I still found it pretty darn cool if you're working with the NetBeans Lexer (as I am to implement SQL completion in PHP).

If you're wondering how the heck a language's lexer is lexing a source file, you can bring up the token view.


How do you bring this up? It's not available from the Window menu. What you have to do is create a keymap for it, like CTRL-T or Meta-T. You go to Tools->Options (or Netbeans->Preferences on the Mac), select the KeyMap tab, search for "token", and then edit the keymap for "Tokens View" by pressing on the "..." icon under the "Shortcut" column. 

Then type in the keystrokes you want to use the token view (I used Meta-T).   Close the options dialog, and do your keystrokes, and voila, you get the Tokens View.  


Nice! Thanks to Petr Pisl for this tip.


Anonymous said...

My Keymap settings tab does not include a search field... How come?

(NetBeans 6.5, Solaris x86.)

Unknown said...

I have no idea, I'm surprised it doesn't. I'm not even sure who to ask about this on the NB team. I suggest taking your question to, I think you'll get a good answer there.