- I don't have the Cocoa API memorized.
- Better Solution:
- Use the source code indexer to give me some hints...
1. What It Does
The PBXtra.bundle adds some some simple symbol searching / completion capabilities to Project Builder for Objective-C. It does this by creating an NSTextView category (PBXtra) and adding a new method called PBXtra_listMatchingSymbols:.
It should be stressed that this is just a thin wrapper around the Project Builder indexing engine and that I haven't written any amazing code to parse Objective-C source code.
- Copy the PBXtra.pbplugin directory into
- Copy the PBKeyBinding.dict file into
You may have to create these directories if they don't exist already.
Note: You can also use the ~/Developer/ProjectBuilder Extras/Plug-ins/ directory, which will only load this plugin when you are logged in. Thanks go to Armin Briegel for pointing this out.
3. How To
Once you've installed the files, start Project Builder. Open a project and make sure you have done a Build at least once. Project Builder indexes source code when you build a project, so until you do that, there won't be any symbols to find.
After that, you should be able to see its functionality quite easily.
Type in something like:
and hit Option-M.
You should see something along the lines of the image below:
At this point, hitting Option-M again will complete as much as possible - meaning the longest common prefix - and allow you to keep browsing the symbols. So in this example,
nsstr would become
NSString in the selection, and the popup would stay around.
Return, enter and tab will all insert the full text of the selection in to the text selection.
- The "algorithm" (if it can be called that) that determines the current context for filtering symbol types is not what I would call robust. It seems to work in my testing, but I've no doubt some difficult cases could trip it up.
- This entire thing is based on private non-final APIs inside Project Builder. It works on the latest (August 2002) version of Project Builder - I doubt it works on earlier versions and I could very well break on the next release.
- No hints about which receivers respond to which messages are readily available. This is not an easy problem to solve since Objective-C is so heavily dependent on runtime rather than compile time typing.
- Source code is not pretty - I rushed and it shows. I'll still post it. Maybe sourceforge. Probably just a tarball on my site. Contact me if you are in a rush to look at it.
5. Questions | Comments | Feedback
Please feel free to contact me via email - I'm interested to hear your criticisms and thoughts. Honestly, since this is based on such a shady foundation (private API's and the like) I'm not going to devote a huge amount of time to this, but I will likely patch up the major annoyances.
Mike Ferris - TextExtras souce was a good reference and a few extra hints via email had me well on my way.
7. Revision History
v0.3 - released 2002-10-15
- Repackaged as Project Builder plugin
v0.2 - released 2002-10-07
- popup selection completes as you continue to type
- case insensitive sorting
- Option-M completes the greatest common prefix in the popup list
- tweaked the context sensing code a bit to fix some annoyances
v0.1.1 - released 2002-10-06
- collapse duplicate symbol names in popup list
- added border around list and removed "ghost" popup in lower-left of the screen
- removed some debugging code causing completion delay
- completes immediately if there is only 1 match
- no popup if there are no symbols
v0.1 - released 2002-10-05
- Initial release