diff --git a/java/java-impl/src/com/intellij/codeInspection/intermediaryVariable/ReturnSeparatedFromComputationInspection.java b/java/java-impl/src/com/intellij/codeInspection/intermediaryVariable/ReturnSeparatedFromComputationInspection.java index b8252734d98a..d17fe690b12f 100644 --- a/java/java-impl/src/com/intellij/codeInspection/intermediaryVariable/ReturnSeparatedFromComputationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/intermediaryVariable/ReturnSeparatedFromComputationInspection.java @@ -563,8 +563,7 @@ public class ReturnSeparatedFromComputationInspection extends BaseJavaBatchLocal @NotNull PsiReturnStatement returnStatement, @NotNull PsiVariable variable) { String name = variable.getName(); - PsiElement returnElement = returnStatement.getFirstChild(); - holder.registerProblem(returnElement instanceof PsiKeyword ? returnElement : returnStatement, + holder.registerProblem(returnStatement, InspectionsBundle.message("inspection.return.separated.from.computation.descriptor", name), new VariableFix(name)); } @@ -592,7 +591,7 @@ public class ReturnSeparatedFromComputationInspection extends BaseJavaBatchLocal @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { - PsiElement element = getNearestEnclosingStatement(descriptor.getPsiElement()); + PsiElement element = descriptor.getPsiElement(); if (element instanceof PsiReturnStatement) { doApply(((PsiReturnStatement)element)); } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterGenericTypeCompatible.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterGenericTypeCompatible.java new file mode 100644 index 000000000000..8675d8200686 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterGenericTypeCompatible.java @@ -0,0 +1,16 @@ +// "Move 'return' closer to computation of the value of 'raw'" "true" +import java.util.*; + +class T { + List f(boolean b) { + List raw = null; + if (b) { + return g(); + } + return raw; + } + + List g() { + return Collections.singletonList(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterLabeledFor3.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterLabeledFor3.java new file mode 100644 index 000000000000..3813db0cc9cc --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterLabeledFor3.java @@ -0,0 +1,15 @@ +// "Move 'return' closer to computation of the value of 'n'" "true" +class T { + int f(int[][] a) { + int n = -1; + myLabel: + for (int i = 0; i < a.length; i++) { + for (int j = 0; j < a[i].length; j++) { + if (a[i][j] == 0) { + return j; + } + } + } + return n; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterLabeledFor4.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterLabeledFor4.java new file mode 100644 index 000000000000..fe3f5b91e728 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/afterLabeledFor4.java @@ -0,0 +1,17 @@ +// "Move 'return' closer to computation of the value of 'n'" "true" +class T { + int f(int[][] a) { + int n = -1; + myLabel: + for (int i = 0; i < a.length; i++) { + if (a[i].length == 0) { + return -i - 1; + } + for(int j = 0; j < a[i].length; j++) { + n = j; + if (a[i][j] == 0) return n; + } + } + return n; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeGenericTypeCompatible.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeGenericTypeCompatible.java new file mode 100644 index 000000000000..f1e2fced219d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeGenericTypeCompatible.java @@ -0,0 +1,16 @@ +// "Move 'return' closer to computation of the value of 'raw'" "true" +import java.util.*; + +class T { + List f(boolean b) { + List raw = null; + if (b) { + raw = g(); + } + return raw; + } + + List g() { + return Collections.singletonList(""); + } +} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/GenericTypeIncompatible.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeGenericTypeIncompatible.java similarity index 67% rename from java/java-tests/testData/inspection/returnSeparatedFromComputation/GenericTypeIncompatible.java rename to java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeGenericTypeIncompatible.java index 788bc2bf0a9a..b4041211784d 100644 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/GenericTypeIncompatible.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeGenericTypeIncompatible.java @@ -1,3 +1,4 @@ +// "Move 'return' closer to computation of the value of 'raw'" "false" import java.util.*; class T { @@ -6,7 +7,7 @@ class T { if (b) { raw = g(); } - return raw; + return raw; } List g() { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeLabeledFor3.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeLabeledFor3.java new file mode 100644 index 000000000000..49f892563a9d --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeLabeledFor3.java @@ -0,0 +1,16 @@ +// "Move 'return' closer to computation of the value of 'n'" "true" +class T { + int f(int[][] a) { + int n = -1; + myLabel: + for (int i = 0; i < a.length; i++) { + for (int j = 0; j < a[i].length; j++) { + if (a[i][j] == 0) { + n = j; + break myLabel; + } + } + } + return n; + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeLabeledFor4.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeLabeledFor4.java new file mode 100644 index 000000000000..f7ea90db3b3f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeLabeledFor4.java @@ -0,0 +1,18 @@ +// "Move 'return' closer to computation of the value of 'n'" "true" +class T { + int f(int[][] a) { + int n = -1; + myLabel: + for (int i = 0; i < a.length; i++) { + if (a[i].length == 0) { + n = -i - 1; + break myLabel; + } + for(int j = 0; j < a[i].length; j++) { + n = j; + if (a[i][j] == 0) break myLabel; + } + } + return n; + } +} diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SideEffectInIf.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeSideEffectInIf.java similarity index 53% rename from java/java-tests/testData/inspection/returnSeparatedFromComputation/SideEffectInIf.java rename to java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeSideEffectInIf.java index d99f7d85ddb1..8887673a86e2 100644 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SideEffectInIf.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation/beforeSideEffectInIf.java @@ -1,9 +1,10 @@ +// "Move 'return' closer to computation of the value of 'r'" "false" class T { int[] f(boolean b) { int[] r = new int[]{-1}; if (b) { r[0] = 1; } - return r; + return r; } } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/Assert.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/Assert.java deleted file mode 100644 index cfd08d21bc86..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/Assert.java +++ /dev/null @@ -1,7 +0,0 @@ -class T { - int f(int a) { - int n = a; - assert n != 0; - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/AssignmentChainUnderIf.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/AssignmentChainUnderIf.java deleted file mode 100644 index cde65b63d675..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/AssignmentChainUnderIf.java +++ /dev/null @@ -1,14 +0,0 @@ -class T { - int x; - int y; - - int f(int a) { - int n = -1; - if (a != 0) { - n = a; - n = 31 * x + n; - n = 31 * y + n; - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/BreakFromLoopInTryWithResources.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/BreakFromLoopInTryWithResources.java deleted file mode 100644 index 8e93b50f297a..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/BreakFromLoopInTryWithResources.java +++ /dev/null @@ -1,19 +0,0 @@ -import java.io.*; - -class T { - private static String getString() throws IOException { - String s; - try (BufferedReader reader = open()) { - while (true) { - s = reader.readLine(); - if (s == null || s.startsWith("$")) { - break; - } - } - } - return s; - } - private static BufferedReader open() throws FileNotFoundException { - return null; - } -} diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/DoWhileTrue.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/DoWhileTrue.java deleted file mode 100644 index 4dc901873377..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/DoWhileTrue.java +++ /dev/null @@ -1,22 +0,0 @@ -class T { - String f() { - String r = ""; - do { - if (!hasNext()) break; - String s = next(); - if (s != null) { - r = s; - break; - } - } while (true); - return r; - } - - boolean hasNext() { - return true; - } - - String next() { - return null; - } -} diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/ForWithoutCondition.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/ForWithoutCondition.java deleted file mode 100644 index 4c6aa0c71b3c..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/ForWithoutCondition.java +++ /dev/null @@ -1,12 +0,0 @@ -class T { - int f() { - int n = -1; - for(int i=0;; i++) { - if (i % 127 == 0 && i % 129 == 0) { - n = i + 1; - break; - } - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/GenericTypeCompatible.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/GenericTypeCompatible.java deleted file mode 100644 index e07ce3aa3a26..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/GenericTypeCompatible.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.util.*; - -class T { - List f(boolean b) { - List raw = null; - if (b) { - raw = g(); - } - return raw; - } - - List g() { - return Collections.singletonList(""); - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/HashCode.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/HashCode.java deleted file mode 100644 index a776160b1645..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/HashCode.java +++ /dev/null @@ -1,12 +0,0 @@ -class T { - int size; - int width; - int height; - - public int hashCode() { - int result = size; - result = 31 * result + width; - result = 31 * result + height; - return result; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseNoWrite.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseNoWrite.java deleted file mode 100644 index 0214a19911ab..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseNoWrite.java +++ /dev/null @@ -1,8 +0,0 @@ -class T { - int f(boolean b) { - int n = 0; - if (b) System.out.println("yes"); - else System.out.println("no"); - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInBoth.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInBoth.java deleted file mode 100644 index 4694568c9444..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInBoth.java +++ /dev/null @@ -1,8 +0,0 @@ -class T { - int f(boolean b) { - int n = 0; - if (b) n = 1; - else n = 2; - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInElse.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInElse.java deleted file mode 100644 index 025bb187f8ac..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInElse.java +++ /dev/null @@ -1,8 +0,0 @@ -class T { - int f(boolean b) { - int n = 0; - if (b) System.out.println("yes"); - else n = 2; - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInIf.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInIf.java deleted file mode 100644 index 8c560c887e9d..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/IfElseWriteInIf.java +++ /dev/null @@ -1,8 +0,0 @@ -class T { - int f(boolean b) { - int n = 0; - if (b) n = 1; - else System.out.println("no"); - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledBlock.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledBlock.java deleted file mode 100644 index 5193d3a4b826..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledBlock.java +++ /dev/null @@ -1,12 +0,0 @@ -class T { - int f(boolean b) { - int n; - myLabel: - { - n = 1; - if (b) break myLabel; - n = 2; - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledFor.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledFor.java deleted file mode 100644 index 22b3f60317d4..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledFor.java +++ /dev/null @@ -1,13 +0,0 @@ -class T { - int f(int[] a) { - int n = -1; - myLabel: - for (int i = 0; i < a.length; i++) { - if (a[0] == 0) { - n = i; - break myLabel; - } - } - return n; - } -} diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledFor2.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledFor2.java deleted file mode 100644 index 2daf31437ddc..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledFor2.java +++ /dev/null @@ -1,11 +0,0 @@ -class T { - int f(int[] a) { - int n = -1; - myLabel: - for (int i = 0; i < a.length; i++) { - n = i; - if (a[0] == 0) break myLabel; - } - return n; - } -} diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledIf.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledIf.java deleted file mode 100644 index e5311e318774..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/LabeledIf.java +++ /dev/null @@ -1,9 +0,0 @@ -class T { - int f(boolean b) { - int n = 0; - myLabel: - if (b) n = 1; - else break myLabel; - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedBlock.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedBlock.java deleted file mode 100644 index a3df6bf1f2f0..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedBlock.java +++ /dev/null @@ -1,9 +0,0 @@ -class T { - int f() { - int n; - { - n = 1; - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedBlockSideEffect.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedBlockSideEffect.java deleted file mode 100644 index 32397633c904..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedBlockSideEffect.java +++ /dev/null @@ -1,10 +0,0 @@ -class T { - int f() { - int n; - { - n = 1; - System.out.println(); - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIf.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIf.java deleted file mode 100644 index 79f4d13c7f3a..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIf.java +++ /dev/null @@ -1,11 +0,0 @@ -class T { - int f(boolean a, boolean b) { - int n = -1; - if (a) { - if (b) { - n = 1; - } - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIfInnerElse.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIfInnerElse.java deleted file mode 100644 index 78b03a5ddd34..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIfInnerElse.java +++ /dev/null @@ -1,10 +0,0 @@ -class T { - int f(boolean a, boolean b) { - int n = -1; - if (a) { - if (b) n = 1; - else n = 2; - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIfOuterElse.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIfOuterElse.java deleted file mode 100644 index 13bc1d6edf9e..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/NestedIfOuterElse.java +++ /dev/null @@ -1,10 +0,0 @@ -class T { - int f(boolean a, boolean b) { - int n = -1; - if (a) { - if (b) n = 1; - } - else n = 2; - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/ReturnOutsideTryWithResources.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/ReturnOutsideTryWithResources.java deleted file mode 100644 index 979d8a9e1a09..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/ReturnOutsideTryWithResources.java +++ /dev/null @@ -1,15 +0,0 @@ -import java.io.*; - -class T { - private static String getString() throws IOException { - String s; - try (BufferedReader r = open()) { - s = r.readLine(); - } - return s; - } - - private static BufferedReader open() throws FileNotFoundException { - return null; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleDoWhile.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleDoWhile.java deleted file mode 100644 index b5dcac468e69..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleDoWhile.java +++ /dev/null @@ -1,25 +0,0 @@ -class T { - String f(String a) { - String r = ""; - int i = 0; - do { - int j = a.indexOf(",", i); - String s = j > i ? a.substring(i, j) : a.substring(i); - if (s.startsWith("@")) { - r = s; - break; - } - i = j + 1; - } - while (i >= 0); - return r; - } - - boolean hasNext() { - return true; - } - - String next() { - return null; - } -} diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleFor.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleFor.java deleted file mode 100644 index d7a3764ffe1a..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleFor.java +++ /dev/null @@ -1,12 +0,0 @@ -class T { - int f(int[] a, int b) { - int n = -1; - for (int i = 0; i < a.length; i++) { - if (a[i] == b) { - n = i; - break; - } - } - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleForeach.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleForeach.java deleted file mode 100644 index 3954b42db3d3..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleForeach.java +++ /dev/null @@ -1,12 +0,0 @@ -class T { - String f(String[] a) { - String r = ""; - for (String s : a) { - if (s != null && s.contains("@")) { - r = s + ":" + s.length(); - break; - } - } - return r; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleIf.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleIf.java deleted file mode 100644 index d48a1f9b48ac..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleIf.java +++ /dev/null @@ -1,7 +0,0 @@ -class T { - int f(boolean b) { - int n = 0; - if (b) n = 1; - return n; - } -} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleWhile.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleWhile.java deleted file mode 100644 index daf25c38b846..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/SimpleWhile.java +++ /dev/null @@ -1,21 +0,0 @@ -class T { - String f() { - String r = ""; - while (hasNext()) { - String s = next(); - if (s != null) { - r = s; - break; - } - } - return r; - } - - boolean hasNext() { - return true; - } - - String next() { - return null; - } -} diff --git a/java/java-tests/testData/inspection/returnSeparatedFromComputation/WhileTrue.java b/java/java-tests/testData/inspection/returnSeparatedFromComputation/WhileTrue.java deleted file mode 100644 index dfbfb024bae5..000000000000 --- a/java/java-tests/testData/inspection/returnSeparatedFromComputation/WhileTrue.java +++ /dev/null @@ -1,15 +0,0 @@ -class T { - long f() { - long r; - long s = System.currentTimeMillis(); - long t = s; - while (true) { - t = System.currentTimeMillis(); - if (t - s > 100) { - r = t; - break; - } - } - return r; - } -} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/codeInspection/ReturnSeparatedFromComputationTest.java b/java/java-tests/testSrc/com/intellij/codeInspection/ReturnSeparatedFromComputationTest.java deleted file mode 100644 index f0dfbd7e672a..000000000000 --- a/java/java-tests/testSrc/com/intellij/codeInspection/ReturnSeparatedFromComputationTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.intellij.codeInspection; - -import com.intellij.JavaTestUtil; -import com.intellij.codeInspection.intermediaryVariable.ReturnSeparatedFromComputationInspection; -import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; - -/** - * @author Pavel.Dolgov - */ -public class ReturnSeparatedFromComputationTest extends LightCodeInsightFixtureTestCase { - @Override - protected String getBasePath() { - return JavaTestUtil.getRelativeJavaTestDataPath() + "/inspection/returnSeparatedFromComputation"; - } - - public void testReturnOutsideTryWithResources() { - doTest(); - } - - public void testBreakFromLoopInTryWithResources() { - doTest(); - } - - public void testSimpleIf() { - doTest(); - } - - public void testSimpleFor() { - doTest(); - } - - public void testIfElseWriteInBoth() { - doTest(); - } - - public void testIfElseWriteInIf() { - doTest(); - } - - public void testIfElseWriteInElse() { - doTest(); - } - - public void testIfElseNoWrite() { - doTest(); - } - - public void testNestedIf() { - doTest(); - } - - public void testNestedIfInnerElse() { - doTest(); - } - - public void testNestedIfOuterElse() { - doTest(); - } - - public void testNestedBlock() { - doTest(); - } - - public void testNestedBlockSideEffect() { - doTest(); - } - - public void testAssert() { - doTest(); - } - - public void testLabeledBlock() { - doTest(); - } - - public void testLabeledFor() { - doTest(); - } - - public void testLabeledFor2() { - doTest(); - } - - public void testLabeledIf() { - doTest(); - } - - public void testWhileTrue() { - doTest(); - } - - public void testSimpleWhile() { - doTest(); - } - - public void testForWithoutCondition() { - doTest(); - } - - public void testSimpleForeach() { - doTest(); - } - - public void testDoWhileTrue() { - doTest(); - } - - public void testSimpleDoWhile() { - doTest(); - } - - public void testSideEffectInIf() { - doTest(); - } - - public void testHashCode() { - doTest(); - } - - public void testGenericTypeCompatible() { - doTest(); - } - - public void testGenericTypeIncompatible() { - doTest(); - } - - - private void doTest() { - myFixture.enableInspections(new ReturnSeparatedFromComputationInspection()); - myFixture.testHighlighting(getTestName(false) + ".java"); - } -} diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml index 4d3f78ec8262..b3a6c4fb5f47 100644 --- a/resources/src/META-INF/IdeaPlugin.xml +++ b/resources/src/META-INF/IdeaPlugin.xml @@ -649,7 +649,7 @@ implementationClass="com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal"/>