mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
local can be final: add option to configure if implicitly final variables should be highlighted or not (IDEA-172529)
This commit is contained in:
+8
-1
@@ -40,6 +40,7 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool {
|
||||
public boolean REPORT_PARAMETERS = true;
|
||||
public boolean REPORT_CATCH_PARAMETERS = true;
|
||||
public boolean REPORT_FOREACH_PARAMETERS = true;
|
||||
public boolean REPORT_IMPLICIT_FINALS = true;
|
||||
|
||||
private final LocalQuickFix myQuickFix;
|
||||
@NonNls public static final String SHORT_NAME = "LocalCanBeFinal";
|
||||
@@ -58,6 +59,9 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool {
|
||||
if (!REPORT_FOREACH_PARAMETERS) {
|
||||
node.addContent(new Element("option").setAttribute("name", "REPORT_FOREACH_PARAMETERS").setAttribute("value", "false"));
|
||||
}
|
||||
if (!REPORT_IMPLICIT_FINALS) {
|
||||
node.addContent(new Element("option").setAttribute("name", "REPORT_IMPLICIT_FINALS").setAttribute("value", "false"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -282,7 +286,9 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool {
|
||||
|
||||
private boolean shouldBeIgnored(PsiVariable psiVariable) {
|
||||
PsiModifierList modifierList = psiVariable.getModifierList();
|
||||
if (modifierList == null || modifierList.hasExplicitModifier(PsiModifier.FINAL)) return true;
|
||||
if (modifierList == null) return true;
|
||||
if (REPORT_IMPLICIT_FINALS && modifierList.hasModifierProperty(PsiModifier.FINAL)) return true;
|
||||
if (modifierList.hasExplicitModifier(PsiModifier.FINAL)) return true;
|
||||
if (psiVariable instanceof PsiLocalVariable) {
|
||||
return !REPORT_VARIABLES;
|
||||
}
|
||||
@@ -343,6 +349,7 @@ public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool {
|
||||
panel.addCheckbox(InspectionsBundle.message("inspection.local.can.be.final.option1"), "REPORT_PARAMETERS");
|
||||
panel.addCheckbox(InspectionsBundle.message("inspection.local.can.be.final.option2"), "REPORT_CATCH_PARAMETERS");
|
||||
panel.addCheckbox(InspectionsBundle.message("inspection.local.can.be.final.option3"), "REPORT_FOREACH_PARAMETERS");
|
||||
panel.addCheckbox(InspectionsBundle.message("inspection.local.can.be.final.option4"), "REPORT_IMPLICIT_FINALS");
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ inspection.local.can.be.final.option=Report local variables
|
||||
inspection.local.can.be.final.option1=Report method parameters
|
||||
inspection.local.can.be.final.option2=Report catch parameters
|
||||
inspection.local.can.be.final.option3=Report foreach parameters
|
||||
inspection.local.can.be.final.option4=Report variables which are implicit final
|
||||
inspection.can.be.local.parameter.problem.descriptor=Parameter <code>#ref</code> can have <code>final</code> modifier
|
||||
inspection.can.be.local.variable.problem.descriptor=Variable <code>#ref</code> can have <code>final</code> modifier
|
||||
|
||||
|
||||
Reference in New Issue
Block a user