mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 06:05:01 +07:00
unused inspection settings: allow to configure visibility for members to check
This commit is contained in:
@@ -1,72 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspection.OptionsPanel">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="2">
|
||||
<grid id="27dc6" binding="myPanel" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="2">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="394" height="400"/>
|
||||
<xy x="357" y="305" width="299" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="empty" title=""/>
|
||||
<children>
|
||||
<component id="b6cc3" class="javax.swing.JCheckBox" binding="myCheckLocalVariablesCheckBox" default-binding="true">
|
||||
<vspacer id="eb5d4">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="172" height="22"/>
|
||||
</grid>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="c6c56" class="com.intellij.openapi.ui.ComboBox" binding="myCheckClassesCheckBox">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="d4721" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="c6c56"/>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.classes"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4e0ea" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="5954e"/>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.fields"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="5954e" class="com.intellij.openapi.ui.ComboBox" binding="myCheckFieldsCheckBox">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="c9f09" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="74fa3"/>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.methods"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="74fa3" class="com.intellij.openapi.ui.ComboBox" binding="myCheckMethodsCheckBox">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="2b841" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="96ef2"/>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.parameters"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="96ef2" class="com.intellij.openapi.ui.ComboBox" binding="myCheckParametersCheckBox">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="38d94" class="javax.swing.JCheckBox" binding="myCheckLocalVariablesCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.localvars"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="6664b" class="javax.swing.JCheckBox" binding="myCheckParametersCheckBox" default-binding="true">
|
||||
<component id="168d8" class="javax.swing.JCheckBox" binding="myCheckGettersSettersCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="172" height="22"/>
|
||||
</grid>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.parameters"/>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.accessors"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="c49dc" class="javax.swing.JCheckBox" binding="myCheckMethodsCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="172" height="22"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.methods"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2077d" class="javax.swing.JCheckBox" binding="myReportUnusedParametersInPublics" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.public.method.parameters"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b2b9f" class="javax.swing.JCheckBox" binding="myCheckFieldsCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.fields"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="bcd0d" class="javax.swing.JCheckBox" binding="myCheckClassesCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="messages/InspectionsBundle" key="inspection.unused.symbol.check.classes"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="eb5d4">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
|
||||
+37
-19
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.intellij.codeInspection.unusedSymbol;
|
||||
|
||||
import com.intellij.psi.PsiModifier;
|
||||
import com.intellij.ui.ListCellRendererWrapper;
|
||||
import com.intellij.util.VisibilityUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -37,34 +40,49 @@ public class UnusedSymbolLocalInspection extends UnusedSymbolLocalInspectionBase
|
||||
|
||||
public class OptionsPanel {
|
||||
private JCheckBox myCheckLocalVariablesCheckBox;
|
||||
private JCheckBox myCheckClassesCheckBox;
|
||||
private JCheckBox myCheckFieldsCheckBox;
|
||||
private JCheckBox myCheckMethodsCheckBox;
|
||||
private JCheckBox myCheckParametersCheckBox;
|
||||
private JCheckBox myReportUnusedParametersInPublics;
|
||||
private JComboBox<String> myCheckClassesCheckBox;
|
||||
private JComboBox<String> myCheckFieldsCheckBox;
|
||||
private JComboBox<String> myCheckMethodsCheckBox;
|
||||
private JComboBox<String> myCheckParametersCheckBox;
|
||||
private JPanel myPanel;
|
||||
private JCheckBox myCheckGettersSettersCheckBox;
|
||||
|
||||
public OptionsPanel() {
|
||||
myCheckLocalVariablesCheckBox.setSelected(LOCAL_VARIABLE);
|
||||
myCheckClassesCheckBox.setSelected(CLASS);
|
||||
myCheckFieldsCheckBox.setSelected(FIELD);
|
||||
myCheckMethodsCheckBox.setSelected(METHOD);
|
||||
myCheckGettersSettersCheckBox.setSelected(!isIgnoreAccessors());
|
||||
String[] visibilities = new String[] {"none", PsiModifier.PUBLIC, PsiModifier.PROTECTED, PsiModifier.PACKAGE_LOCAL, PsiModifier.PRIVATE};
|
||||
myCheckClassesCheckBox.setModel(new DefaultComboBoxModel<>(visibilities));
|
||||
myCheckFieldsCheckBox.setModel(new DefaultComboBoxModel<>(visibilities));
|
||||
myCheckMethodsCheckBox.setModel(new DefaultComboBoxModel<>(visibilities));
|
||||
myCheckParametersCheckBox.setModel(new DefaultComboBoxModel<>(visibilities));
|
||||
|
||||
myCheckParametersCheckBox.setSelected(PARAMETER);
|
||||
myReportUnusedParametersInPublics.setSelected(REPORT_PARAMETER_FOR_PUBLIC_METHODS);
|
||||
myReportUnusedParametersInPublics.setEnabled(PARAMETER);
|
||||
final ListCellRendererWrapper<String> renderer = new ListCellRendererWrapper<String>() {
|
||||
@Override
|
||||
public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
|
||||
if (value != null && !"none".equals(value)) {
|
||||
setText(VisibilityUtil.toPresentableText(value));
|
||||
}
|
||||
}
|
||||
};
|
||||
myCheckClassesCheckBox.setRenderer(renderer);
|
||||
myCheckMethodsCheckBox.setRenderer(renderer);
|
||||
myCheckFieldsCheckBox.setRenderer(renderer);
|
||||
myCheckParametersCheckBox.setRenderer(renderer);
|
||||
|
||||
myCheckClassesCheckBox.setSelectedItem(getClassVisibility());
|
||||
myCheckFieldsCheckBox.setSelectedItem(getFieldVisibility());
|
||||
myCheckMethodsCheckBox.setSelectedItem(getMethodVisibility());
|
||||
myCheckParametersCheckBox.setSelectedItem(getParameterVisibility());
|
||||
|
||||
final ActionListener listener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LOCAL_VARIABLE = myCheckLocalVariablesCheckBox.isSelected();
|
||||
CLASS = myCheckClassesCheckBox.isSelected();
|
||||
FIELD = myCheckFieldsCheckBox.isSelected();
|
||||
METHOD = myCheckMethodsCheckBox.isSelected();
|
||||
|
||||
PARAMETER = myCheckParametersCheckBox.isSelected();
|
||||
REPORT_PARAMETER_FOR_PUBLIC_METHODS = PARAMETER && myReportUnusedParametersInPublics.isSelected();
|
||||
myReportUnusedParametersInPublics.setEnabled(PARAMETER);
|
||||
setIgnoreAccessors(!myCheckGettersSettersCheckBox.isSelected());
|
||||
setClassVisibility((String)myCheckClassesCheckBox.getSelectedItem());
|
||||
setFieldVisibility((String)myCheckFieldsCheckBox.getSelectedItem());
|
||||
setMethodVisibility((String)myCheckMethodsCheckBox.getSelectedItem());
|
||||
setParameterVisibility((String)myCheckParametersCheckBox.getSelectedItem());
|
||||
}
|
||||
};
|
||||
myCheckLocalVariablesCheckBox.addActionListener(listener);
|
||||
@@ -72,7 +90,7 @@ public class UnusedSymbolLocalInspection extends UnusedSymbolLocalInspectionBase
|
||||
myCheckMethodsCheckBox.addActionListener(listener);
|
||||
myCheckClassesCheckBox.addActionListener(listener);
|
||||
myCheckParametersCheckBox.addActionListener(listener);
|
||||
myReportUnusedParametersInPublics.addActionListener(listener);
|
||||
myCheckGettersSettersCheckBox.addActionListener(listener);
|
||||
}
|
||||
|
||||
public JComponent getPanel() {
|
||||
|
||||
Reference in New Issue
Block a user