From f8a49b10a3a90b60520aaeac830c2a8bf15f6bfe Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 14 Jan 2015 11:35:44 +0100 Subject: [PATCH] IG: fix option so it is useful --- .../siyeh/InspectionGadgetsBundle.properties | 3 ++- ...oneDeclaresCloneNotSupportedInspection.java | 18 +++++++++--------- .../CloneDeclaresCloneNotSupported.html | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties index 459950f67bf8..547635b92ad1 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/InspectionGadgetsBundle.properties @@ -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=#ref() 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 diff --git a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneDeclaresCloneNotSupportedInspection.java b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneDeclaresCloneNotSupportedInspection.java index 3f605269bff4..b91bec416a28 100644 --- a/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneDeclaresCloneNotSupportedInspection.java +++ b/plugins/InspectionGadgets/InspectionGadgetsAnalysis/src/com/siyeh/ig/cloneable/CloneDeclaresCloneNotSupportedInspection.java @@ -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(); diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html index e50bfac4f8df..b1f175d56f7e 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/CloneDeclaresCloneNotSupported.html @@ -8,9 +8,9 @@ prohibit cloning will not be able to do so in the standard way. This inspection or clone() methods on final classes.

-Use the checkbox below to indicate if this inspection should only warn on public methods. +Use the checkbox below to indicate if this inspection should only warn on protected methods. In Effective Java, Second Edition (but not in the first edition) it is recommended to omit the CloneNotSupportedException -declaration, because methods that don't throw checked exceptions are easier to use. +declaration on public methods, because methods that don't throw checked exceptions are easier to use.