Creating Custom Inspections
IntelliJ IDEA allows you to create custom inspections based on search templates. The inspection list provides a Structural Search Inspection, which is a powerful tool for creating search templates. Based on this inspection, you can create any number of search templates to inspect your source code and any number of replace templates to be used as means to resolve detected problems.
To create a custom inspection
- Open the Inspections dialog box.
- Select the desired profile from the drop-down list. The inspections associated with the selected profile are displayed in the tree view.
- In the list of inspections, expand the General node and select the check box next to the Structural Search Inspection item. This enables the controls in the Options area, where you can configure a custom inspection.
- Click the Add Search Template button. In the Structural Search dialog box that opens specify the search options.
- Click the Add Replace Template button. In the Structural Replace dialog box that opens specify the replace options.
- Complete the list of inspection templates:
- To edit a template, select it in the Selected Templates list, click the Edit button, and edit the template in the Edit Template dialog box that opens.
- To remove a template, select it in the list and click the Remove button.
- Specify the inspection severity using the Severity drop-down list.
- Associate the inspection with a scope.
If an inspection is not associated with a scope, it applies to all the sources of the current project.