do not suggest to make read only parameter local (IDEA-95021)

This commit is contained in:
anna
2012-11-15 17:09:55 +01:00
parent f928e63256
commit 1a64b3452a
4 changed files with 12 additions and 1 deletions
@@ -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(); }
}