Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2016-09-08 22:36:05 +03:00
172 changed files with 1849 additions and 1301 deletions
@@ -0,0 +1,15 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int x;
int y;
int f(int a) {
int n = -1;
if (a != 0) {
n = a;
n = 31 * x + n;
return 31 * y + n;
}
return n;
}
}
@@ -1,15 +1,15 @@
// "Move 'return' closer to computation of the value of 'n'" "false"
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
int x;
int y;
int x;
int y;
int f(int a) {
int n = -1;
if (a != 0) {
n = a;
n = 31 * x + n;
n = 31 * y + n;
int f(int a) {
int n = -1;
if (a != 0) {
n = a;
n = 31 * x + n;
n = 31 * y + n;
}
re<caret>turn n;
}
re<caret>turn n;
}
}
@@ -0,0 +1,14 @@
// "Move 'return' closer to computation of the value of 'n'" "false"
class T {
int f(boolean b) {
int n = -1;
try {
if (b) throw new RuntimeException();
n = 1;
re<caret>turn n;
}
finally {
System.out.println(n);
}
}
}
@@ -0,0 +1,17 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
if (b) return 1;
return n;
});
}
void g(I i) {
i.call();
}
}
@@ -0,0 +1,24 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
while (true) {
if (h()) {
return 1;
}
}
});
}
void g(I i) {
i.call();
}
boolean h() {
return true;
}
}
@@ -0,0 +1,17 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
if (b) n = 1;
ret<caret>urn n;
});
}
void g(I i) {
i.call();
}
}
@@ -0,0 +1,26 @@
// "Move 'return' closer to computation of the value of 'n'" "true"
class T {
interface I {
int call();
}
void f(boolean b) {
g(() -> {
int n = -1;
while (true) {
if (h()) {
n = 1;
break;
}
}
ret<caret>urn n;
});
}
void g(I i) {
i.call();
}
boolean h() {
return true;
}
}
@@ -0,0 +1,47 @@
/*
* 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.codeInsight.daemon.quickFix;
import com.intellij.codeInspection.LocalInspectionTool;
import com.intellij.codeInspection.intermediaryVariable.ReturnSeparatedFromComputationInspection;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
import org.jetbrains.annotations.NotNull;
/**
* @author Pavel.Dolgov
*/
public class ReturnSeparatedFromComputationFix8Test extends LightQuickFixParameterizedTestCase {
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
return new LocalInspectionTool[]{new ReturnSeparatedFromComputationInspection()};
}
public void test() throws Exception {
doAllTests();
}
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/returnSeparatedFromComputation8";
}
@Override
protected Sdk getProjectJDK() {
return IdeaTestUtil.getMockJdk18();
}
}