mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
separate warning for constructors
This commit is contained in:
+2
@@ -2034,4 +2034,6 @@ inner.class.referenced.via.subclass.quickfix=Rationalize inner class access
|
||||
boolean.parameter.display.name='public' method with 'boolean' parameter
|
||||
boolean.parameter.problem.descriptor='public' method <code>#ref</code> with 'boolean' parameter
|
||||
boolean.parameters.problem.descriptor='public' method <code>#ref</code> with 'boolean' parameters
|
||||
boolean.parameter.constructor.problem.descriptor='public' constructor <code>#ref</code> with 'boolean' parameter
|
||||
boolean.parameters.constructor.problem.descriptor='public' constructor <code>#ref</code> with 'boolean' parameters
|
||||
boolean.parameter.only.report.multiple.option=Only report methods with multiple boolean parameters
|
||||
+10
-4
@@ -45,11 +45,17 @@ public class BooleanParameterInspection extends BaseInspection {
|
||||
@NotNull
|
||||
@Override
|
||||
protected String buildErrorString(Object... infos) {
|
||||
if (((Integer)infos[0]).intValue() == 1) {
|
||||
return InspectionGadgetsBundle.message("boolean.parameter.problem.descriptor");
|
||||
final PsiMethod method = (PsiMethod)infos[0];
|
||||
final int booleanParameterCount = ((Integer)infos[1]).intValue();
|
||||
if (booleanParameterCount == 1) {
|
||||
return method.isConstructor()
|
||||
? InspectionGadgetsBundle.message("boolean.parameter.constructor.problem.descriptor")
|
||||
: InspectionGadgetsBundle.message("boolean.parameter.problem.descriptor");
|
||||
}
|
||||
else {
|
||||
return InspectionGadgetsBundle.message("boolean.parameters.problem.descriptor");
|
||||
return method.isConstructor()
|
||||
? InspectionGadgetsBundle.message("boolean.parameters.constructor.problem.descriptor")
|
||||
: InspectionGadgetsBundle.message("boolean.parameters.problem.descriptor");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +102,7 @@ public class BooleanParameterInspection extends BaseInspection {
|
||||
if (count == 0 || onlyReportMultiple && count == 1) {
|
||||
return;
|
||||
}
|
||||
registerMethodError(method, Integer.valueOf(count));
|
||||
registerMethodError(method, method, Integer.valueOf(count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -32,6 +32,12 @@ public class BooleanParameterInspectionTest extends LightInspectionTestCase {
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testConstructor() {
|
||||
doTest("class X {" +
|
||||
" public /*'public' constructor 'X' with 'boolean' parameter*/X/**/(boolean x) {}" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool getInspection() {
|
||||
return new BooleanParameterInspection();
|
||||
|
||||
Reference in New Issue
Block a user