The IntelliJ Analyse stack trace is a good tool to add to your bag of tricks.
Simple copy a stack trace to the clipboard, then go to IntelliJ -> Analyze Menu -> Analyze Stack trace
You will see the option to normalize the stacktrace (which is worth choosing), after pressing ok, you will see the output put into the run menu, which will allow you to navigate to classes inside your current project.
This is a nice tool for debugging support stacktraces you may receive, or stack traces originating from a remote server.
As I seem to end up with the odd person dropping by the blog to look at IntelliJ keyboard Short cuts, I figured that it is probably worth pointing people towards the DZone IntelliJ Refcard which has a pretty good introduction to IntelliJ.
I’ve recently started using the TestDox plugin with IntelliJ. It’s a nice little tool that fits in well with agile test driven development practices. It’s easy to get started with, either installing it from the IntelliJ plugins repository using your IDE, or downloading it directly from the plugins repository, and copying it into the plugins directory.
The premise on which the test dox plugin is based on is the idea that your test methods should be long sentences using CamelCase to break up words. By doing this your tests become your documentation. The plugin takes this premise, and exposes the following behaviour in IntelliJ:
- automatic translation of CamelCase test names to sentences. This is exposed through two different views, which, when coupled with nice navigation synchronisation options, makes it possible to use your tests to understand what the code is meant to do at a high level, and makes it easy to drill down to the specifics when needed.
- There is a simple mapping between classes and tests – TestDox knows that HelloWorldTest is the test for HelloWorld. This is configurable to suit your environment (test classname prefixes and suffixes can be specified, as well as test packages).
- documentation windows will be context sensitive, using the above mapping to show the appropriate documentation for the class/test currently being edited.
- alt-shift-t swapping between the test class and the base class – great for navigation
- alt-shift-t will prompt to create a test class if it doesn’t exist. Very cool fr the cases where you have created a class before the test (for whatever reason)
Overall this is a great little tool. There’s only a couple of minor tweaks I’d like to see made to the tool.
- The biggest that would be nice for the open source project, would be to make editing the source code of the IntelliJ plugin slightly easier. It would be cool to be able to make slight changes to the software, and help improve the project, but the cost of entry was slightly too high for me.
- It would be good for the alt-shift-t auto creation to work both ways. That is I want alt-shift-t to help me automatically create the class as well as the test.
- I saw a couple of minor screen repaint issues on 7.0.3 on OSX 10.5
TestDox is a good tool for IntelliJ, and you really should install it and use it.
One of the features I like about TextMate is the smart insertion of characters, like when I’m typing text, highlight a word, and type ", TextMate will wrap the word in quotes. Unfortunately IntelliJ doesn’t have this behaviour by default, and makes surrounding some text in quotes messier than what would be preferred.
It is possible to make this task much easier, through the use of live templates. Here is how to do it.
- navigate to the add a live template screen via the following path: settings – live templates – add
- type "$SELECTION$" as the template text, ensure that the context is suitably broad, give it a meaningful name, and you are done. This can be seen in pictures.
You will now be able to access the template using the cmd-option (ctrl-alt) t "surround with" shortcut, making it easy to wrap text (code) in quotes using IntelliJ.