Monday 8 November 2010
Eclipse Breakthrough
I've been using Eclipse for quite a while now as my code editor. A few years ago I tried using the "smart" CDT features on Gecko but they didn't work very well. Now, five years later (how time flies!) I am very pleased to report that they work much much better! I'm sure the software has improved (Eclipse 3.6.1, CDT 7), but my laptop now having four CPU cores and 8GB of memory has probably helped too :-).
I create an "empty" C++ project with the source directory pointing to an existing hg repository. I turn off the automatic build options, but enable all the indexing features. I turn off the "scalability" option for the C++ editor --- setting the number-of-lines threshold to 100,000 doesn't seem to cause any problems for me. In the project properties, I add resource filters to exclude everything under the .hg and object directories. In the "Paths And Symbols" page of the project properties, I add all the symbol definitions from the generated mozilla-config.h file of my debug build. This probably could be automated but I did it manually. Then I let the indexer run to completion. It doesn't take very long --- minutes, not hours.
With all that done, many features seem to mostly work, at least in layout and gfx code:
- Ctrl-click on an identifier jumps to its definition
- Ctrl-click on an identifier at its definition jumps to the declaration if there's a separate declaration
- Hovering over an identifer shows its definition
- Opening a "Type Hierarchy" shows the superclasses and subclasses of the selected class (or the class of the method containing the caret)
- Opening a "Call Hierarchy" shows the callers/callees of the selected method
- Opening "Quick Type Hierarchy" on a virtual method declaration shows the classes implementing that method
- Opening "References / Project" shows all references to the selected declaration
- Context-sensitive autocomplete often works.
All very useful! And all very smooth and fast, on my laptop anyway. Major kudos to the Eclipse team, this should really improve my productivity.
Of course, it's not perfect. For example, autocomplete after "foo->", where 'foo' is an nsCOMPtr or nsRefPtr, doesn't seem to work. However, the features work well enough that I'm getting into the habit of using the features and expecting them to work.
Comments