IG: fix option so it is useful

This commit is contained in:
Bas Leijdekkers
2015-01-14 12:36:35 +01:00
parent 34441726d6
commit f8a49b10a3
3 changed files with 13 additions and 12 deletions
@@ -2135,7 +2135,8 @@ utility.class.code.can.be.enum.quickfix=Convert to 'enum'
non.public.clone.display.name='clone()' method not 'public'
non.public.clone.problem.descriptor=<code>#ref()</code> method not 'public' #loc
only.warn.on.public.clone.methods=Only warn on 'public' clone methods
only.warn.on.protected.clone.methods=Only warn on 'protected' clone methods
clone.returns.class.type.display.name='clone()' should have return type equal to the class it contains
clone.returns.class.type.problem.descriptor=''clone()'' should have return type ''{0}'' #loc
clone.returns.class.type.quickfix=Change return type to '{0}'
clone.returns.class.type.quickfix=Change return type to ''{0}''
clone.returns.class.type.family.quickfix=Change return type to class type
@@ -39,7 +39,7 @@ import javax.swing.*;
public class CloneDeclaresCloneNotSupportedInspection extends BaseInspection {
private boolean onlyWarnOnPublicClone = true;
private boolean onlyWarnOnProtectedClone = true;
@Override
@NotNull
@@ -67,16 +67,16 @@ public class CloneDeclaresCloneNotSupportedInspection extends BaseInspection {
@Nullable
@Override
public JComponent createOptionsPanel() {
return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("only.warn.on.public.clone.methods"),
this, "onlyWarnOnPublicClone");
return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("only.warn.on.protected.clone.methods"),
this, "onlyWarnOnProtectedClone");
}
@Override
public void readSettings(@NotNull Element node) throws InvalidDataException {
super.readSettings(node);
for (Element option : node.getChildren("option")) {
if ("onlyWarnOnPublicClone".equals(option.getAttributeValue("name"))) {
onlyWarnOnPublicClone = Boolean.parseBoolean(option.getAttributeValue("value"));
if ("onlyWarnOnProtectedClone".equals(option.getAttributeValue("name"))) {
onlyWarnOnProtectedClone = Boolean.parseBoolean(option.getAttributeValue("value"));
}
}
}
@@ -84,9 +84,9 @@ public class CloneDeclaresCloneNotSupportedInspection extends BaseInspection {
@Override
public void writeSettings(@NotNull Element node) throws WriteExternalException {
super.writeSettings(node);
if (!onlyWarnOnPublicClone) {
node.addContent(new Element("option").setAttribute("name", "onlyWarnOnPublicClone")
.setAttribute("value", String.valueOf(onlyWarnOnPublicClone)));
if (!onlyWarnOnProtectedClone) {
node.addContent(new Element("option").setAttribute("name", "onlyWarnOnProtectedClone")
.setAttribute("value", String.valueOf(onlyWarnOnProtectedClone)));
}
}
@@ -131,7 +131,7 @@ public class CloneDeclaresCloneNotSupportedInspection extends BaseInspection {
if (method.hasModifierProperty(PsiModifier.FINAL)) {
return;
}
if (onlyWarnOnPublicClone && !method.hasModifierProperty(PsiModifier.PUBLIC)) {
if (onlyWarnOnProtectedClone && method.hasModifierProperty(PsiModifier.PUBLIC)) {
return;
}
final PsiClass containingClass = method.getContainingClass();
@@ -8,9 +8,9 @@ prohibit cloning will not be able to do so in the standard way. This inspection
or <b>clone()</b> methods on <b>final</b> classes.
<!-- tooltip end -->
<p>
Use the checkbox below to indicate if this inspection should only warn on <b>public</b> methods.
Use the checkbox below to indicate if this inspection should only warn on <b>protected</b> methods.
In <i>Effective Java, Second Edition</i> (but not in the first edition) it is recommended to omit the <b>CloneNotSupportedException</b>
declaration, because methods that don't throw checked exceptions are easier to use.
declaration on <b>public</b> methods, because methods that don't throw checked exceptions are easier to use.
<p>
</body>