mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
[java] local can be final: accept lambda parameters with explicit types (IDEA-223120)
GitOrigin-RevId: a6ee13c64c0139ba0a68f318daf448182a0f3f1d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
09b8dc66e1
commit
e35f056f85
@@ -243,10 +243,14 @@ public class LocalCanBeFinal extends AbstractBaseJavaLocalInspectionTool impleme
|
||||
}
|
||||
});
|
||||
|
||||
if (body.getParent() instanceof PsiMethod && REPORT_PARAMETERS) {
|
||||
final PsiMethod method = (PsiMethod)body.getParent();
|
||||
if (!(method instanceof SyntheticElement)) { // e.g. JspHolderMethod
|
||||
Collections.addAll(result, method.getParameterList().getParameters());
|
||||
if (body.getParent() instanceof PsiParameterListOwner && REPORT_PARAMETERS) {
|
||||
final PsiParameterListOwner methodOrLambda = (PsiParameterListOwner)body.getParent();
|
||||
if (!(methodOrLambda instanceof SyntheticElement)) { // e.g. JspHolderMethod
|
||||
for (PsiParameter parameter : methodOrLambda.getParameterList().getParameters()) {
|
||||
if (parameter.getTypeElement() != null) {
|
||||
result.add(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
class Test{
|
||||
|
||||
public void t() {
|
||||
I i1 = (Integer <warning descr="Parameter 'i' can have 'final' modifier">i</warning>) -> {};
|
||||
I i2 = i -> {};
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
void f(Integer i);
|
||||
}
|
||||
@@ -54,6 +54,12 @@ public class LocalCanBeFinalTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
myTool.REPORT_VARIABLES = true;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLambdaParameters() {
|
||||
myTool.REPORT_PARAMETERS = true;
|
||||
myTool.REPORT_VARIABLES = false;
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testParameters() {
|
||||
myTool.REPORT_PARAMETERS = true;
|
||||
|
||||
Reference in New Issue
Block a user