December 02, 2005

IntelliJ IDEA 6.0 "Demetra": Structural Search Inspections

Static code analysis (code inspections) has long been a strong point of IntelliJ IDEA, and with the addition of the InspectionGadgets plugin in version 4.5, the capabilities of IDEA have become nearly unmatched in the market. After all, is there any developer who doesn’t enjoy getting many of his bugs found by the development environment, automatically, and often with suggested automatic fixes?

The inspection system of IntelliJ IDEA has always been extensible, however, adding new inspections required writing plugins, and was a rather non-trivial task – until now. In Demetra, we have combined inspections with the Structural Search and Replace feature, which allows to find and modify fragments of Java code by specifying patterns to search for.

The Structural Search Inspection allows the developer to specify a number of structural search templates which are automatically searched in every file the user is editing, and their occurrences are highlighted. If the developer has specified a replacement template, it is used to build the quickfix for the warning.

Essentially, this allows every developer to build a collection of “anti-patterns” – code fragments which should never be used in the code – and provide replacements for them.

This feature will become even more powerful with the addition of team-wide sharing of inspection profiles, as the entire team will be able to share the collection of “anti-patterns” and their recommended replacement. However, the profile sharing is a feature that’s currently in early stages of development, so that will be a topic for another blog post…

Posted by Dmitry Jemerov at December 2, 2005 08:31 PM
Comments
Post a comment









Remember personal info?