I would like to reflect over some lesser known features offered by intellij IDEA that have helped while working in real world projects over the past few months.
For those who don’t know, Intellij IDEA (and from now on, ‘Intellij’) is a polyglot IDE developed by Jetbrains while is primarily focused to the JVM market but as has first class support for popular web based platforms, database and server systems, cloud and platform services along with supporting wealth of languages and data standard such as Groovy, Scala, Python, JSON or XML and so on..
More often that I would like, I seem to find myself having to refactor in deep, complex and highly coupled codebases. Like most of us I expect. The ‘Change Signature’ feature has been there with me throughout the years and does all the hard grunting work when refactoring..
One example that I recall using it most over the last few months was that when I needed to change a number of method signatures in a common classes (we were removing legacy DTOs) that had literally 100s of execution paths flowing through these classes & with the graph dependencies spanning over dozens of classes in many packages it made the complexity mindblowing – Up steps the change signature feature did the work, it removed the redundant parameters along with adding & initializing newly introduced parameter sets – with zero issues to report..
While developing, I get all see the server log outputs passing through intellij logging console which is great but once our application enters the real world then we rely heavily on our app support teams to send back errors which have occurred on our managed servers (e.g. PROD). The ‘Normalize Stacktraces’ feature gives us the option to take the plaintext stacktrace and convert these into a sets of navigable stack frames that then allows for me to click through the call stack.. Simple and effective, especially when dealing with external log files.
Copy Path/Copy Reference (https://www.jetbrains.com/idea/help/cutting-copying-and-pasting.html) Ever needed to get the physical/logical location of the files in your project? Well if so, then you will pleased to hear that Intellij this very option to copy filesystem paths or logical references (full qualified class locations) to the clipboard – comes in handy when you need to paste locations into external documents/wikis/Tutorials..
Database – Copy as SQL Inserts (https://www.jetbrains.com/phpstorm/help/database-console.html) –
If you are using Intellij Database console then you may not be aware from a resultset you can copy the query results as Inserts; This came in incredibly useful when I have need 1 set of data to be applied to another database instance – some of the database tables I was working with had several dozen columns and many 100s of results so you can see that manually crafting the SQL inserts options is not an option. The feature does support many exports but this is the one that has been of most us to me in the past.
Debugger (disable until selected breakpoint is hit) – (https://www.jetbrains.com/idea/help/debugging.html); A few days back while debugging I found myself relying on a set of features Intellij provides with its newly redesigned debugger window. The problem was that I had a conditional breakpoint that I only need to hit what a var was or a certain values but after it was it I needed another set of breakpoints to come into action to further analyze the issue. This was when the ‘disable until selected breakpoint is hit’ feature came into its own by sitting silently until the condition was seen then they sprang to life.
Expanding (Structural) Select (https://www.jetbrains.com/idea/help/selecting-text-in-the-editor.html) – If you find yourself working in code that is verbose with multiple layers the you will find this feature of use. As Intellij understands the language you are working in then by simply pressing CTRL-W will have it expand out the selection to the outer scope. This is very useful when you need to select nested code where the the boundaries are easy to spot.. CTRL-SHIFT-W does the reverse.
String Manipulator Plugin (http://blog.jetbrains.com/idea/2014/10/touring-plugins-string-manipulation/) –
This feature is the only 3rd party plugin to make it into the list. The String manipulator gives you a set of actions that you can apply to text; for example make the test all uppercase, change to Base64, get the MD5 Hash. However, what I have found it most useful is when working with test XML test document that have escaped XML as part of its content that I need to manipulate for our integration tests; I found myself constantly unescaping XML content -> analyze -> enhance -> re-escape the XML content & pasting back into text messages. Along with scratch files & the structure select option, I got this refactor cycle to military precision.
Scratch Files – (https://code.google.com/p/idea-string-manip/)
By far my favourite addition to the intellij feature family, this simple yet highly productive feature has changed the way i manage transitive code (SQL, Java, XML, JSON, Groovy etc..) – Scratch files are in memory files that understands the context it is created under – for example if you say ‘create me a scratch file for SQL’ then it knows how to format this and what other options it can give knowing that the scratch file is SQL (such as run SQL against the database). I find myself using this feature most when manipulating large SQL/JSON/XML files or when I need to analyze HTML/JS files not in the project. At this time, this feature will not allow you to execute Java/Groovy code which is bit of a let down but i expect this feature is in the works.
Compare with Clipboard (https://www.jetbrains.com/idea/help/comparing-files.html) – A nifty feature if you have to validate external files with the ones in your project. I real world example was a few days back I was helping out a BA by seeing how her XSD schema differed to what was released to PROD 6 months prior – As it is the real world, she emailed through the XSD which simply opened into a text editor – copied the XSD and then compared to the released XSD document (tagged in our VCS) – boom; in few slick moves we got to see what the changes were..
That is the lot for now. As you may have picked up, I feel passionately about the tools that help us developers to be as productive and IntelliJ is by far one of these tools that I like to have by my side.