mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
do not suggest to make read only parameter local (IDEA-95021)
This commit is contained in:
+1
@@ -104,6 +104,7 @@ public class ParameterCanBeLocalInspection extends BaseJavaLocalInspectionTool {
|
||||
if (controlFlow == null) return Collections.emptyList();
|
||||
|
||||
final Set<PsiParameter> result = filterParameters(controlFlow, parameters);
|
||||
result.retainAll(ControlFlowUtil.getWrittenVariables(controlFlow, 0, controlFlow.getSize(), false));
|
||||
for (final PsiReferenceExpression readBeforeWrite : ControlFlowUtil.getReadBeforeWrite(controlFlow)) {
|
||||
final PsiElement resolved = readBeforeWrite.resolve();
|
||||
if (resolved instanceof PsiParameter) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems/>
|
||||
@@ -0,0 +1,8 @@
|
||||
class Test {
|
||||
public static final boolean myFoo = false;
|
||||
|
||||
public static void foo(int p) {
|
||||
if (!myFoo) return;
|
||||
System.out.println("p = " + p);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.intellij.codeInspection;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection;
|
||||
import com.intellij.codeInspection.varScopeCanBeNarrowed.ParameterCanBeLocalInspection;
|
||||
import com.intellij.testFramework.InspectionTestCase;
|
||||
|
||||
@@ -33,4 +32,5 @@ public class ParameterCanBeLocalTest extends InspectionTestCase {
|
||||
public void testSimple () throws Exception { doTest(); }
|
||||
public void testIf () throws Exception { doTest(); }
|
||||
public void testFor () throws Exception { doTest(); }
|
||||
public void testReadOnly () throws Exception { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user