mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-10 13:17:09 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
+15
@@ -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;
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -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;
|
||||
}
|
||||
}
|
||||
+14
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
@@ -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();
|
||||
}
|
||||
}
|
||||
+24
@@ -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;
|
||||
}
|
||||
}
|
||||
+17
@@ -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();
|
||||
}
|
||||
}
|
||||
+26
@@ -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;
|
||||
}
|
||||
}
|
||||
+47
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user