mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: don't warn about unnecessary final on compile-time constants (IDEA-210351)
GitOrigin-RevId: 337f6b6d55eacf3c7b259ffa1f6661527ce57f54
This commit is contained in:
committed by
intellij-monorepo-bot
parent
5bb8e629c9
commit
a0465f179e
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2017 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2019 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -195,8 +195,9 @@ public class UnnecessaryFinalOnLocalVariableOrParameterInspection extends BaseIn
|
||||
check(parameter);
|
||||
}
|
||||
|
||||
private boolean isNecessaryFinal(PsiVariable parameter, PsiElement context) {
|
||||
return !PsiUtil.isLanguageLevel8OrHigher(parameter) && VariableAccessUtils.variableIsUsedInInnerClass(parameter, context);
|
||||
private boolean isNecessaryFinal(PsiVariable variable, PsiElement context) {
|
||||
return PsiUtil.isConstantExpression(variable.getInitializer()) ||
|
||||
!PsiUtil.isLanguageLevel8OrHigher(variable) && VariableAccessUtils.variableIsUsedInInnerClass(variable, context);
|
||||
}
|
||||
|
||||
private void check(PsiParameter parameter) {
|
||||
|
||||
+16
@@ -36,4 +36,20 @@ public class UnnecessaryFinalOnLocalVariableOrParameter {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
class Sample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final int ALPHA_OPAQUE = (short) 0xFFFF; // IDEA suggests to remove final
|
||||
final int ALPHA_TRANSLUCENT = (short) 0; // IDEA suggests to remove final
|
||||
|
||||
int size = 5;
|
||||
short[][] data = {
|
||||
new short[size],
|
||||
new short[size]
|
||||
};
|
||||
|
||||
data[1][1] = ALPHA_TRANSLUCENT;
|
||||
data[1][1] = ALPHA_OPAQUE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user