Skip to content

Latest commit

 

History

History
92 lines (68 loc) · 3.23 KB

inspections.md

File metadata and controls

92 lines (68 loc) · 3.23 KB

Inspections

Generate options panel

If your plugin targets IDE versions 2023.1+ only, JetBrains now recommends using the new Declarative Inspection Options feature.

There simple UI components in the com.intellij.codeInspection.ui package that are dedicated for use in InspectionProfileEntry implementations.

This action and the related sub-actions can generate the method body of the createOptionsPanel() method for some of these components.

NOTE:

For now, these actions replace the whole body of the createOptionsPanel() method, and don't just insert the code snippet. This is partly because of their usage patterns throughout the intellij-community project.

SingleCheckboxOptionsPanel

It replaces the method body with a simple new SingleCheckboxOptionsPanel instance creation. The label and field name parameter values are left empty.

Example...

From:

public class SomeInspection extends LocalInspectionTool {
  @Override
  public @Nullable JComponent createOptionsPanel() {
      return super.createOptionsPanel();
  }
}

To:

public class SomeInspection extends LocalInspectionTool {
  @Override
  public @Nullable JComponent createOptionsPanel() {
      return new SingleCheckboxOptionsPanel("", this, "");
  }
}

generate_single_checkbox_options_panel

MultipleCheckboxOptionsPanel

MultipleCheckboxOptionsPanel is designed for panels with one or more checkboxes, thus the workflow here is a bit different.

Upon selecting this option from the list, you can also select the number of checkbox additions (the addCheckbox() calls) to generate. For now, it is possible to choose from 1 to 5.

Example...

From:

public class SomeInspection extends LocalInspectionTool {
  @Override
  public @Nullable JComponent createOptionsPanel() {
      return super.createOptionsPanel();
  }
}

To (given 3 checkboxes were selected):

public class SomeInspection extends LocalInspectionTool {
  @Override
  public @Nullable JComponent createOptionsPanel() {
      MultipleCheckboxOptionsPanel panel = new MultipleCheckboxOptionsPanel(this);
      panel.addCheckbox("", "");
      panel.addCheckbox("", "");
      panel.addCheckbox("", "");
      return panel;
  }
}

generate_multiple_checkbox_options_panel

SingleIntegerFieldOptionsPanel

Generating this essentially works the same way and with the same parameterization as SingleCheckboxOptionsPanel.

ConventionOptionsPanel

Works the same as SingleIntegerFieldOptionsPanel or SingleCheckboxOptionsPanel, but it is generated with its own proper parameter list.