HighlightUtil: cr fixes (IDEA-CR-48700):

- extract side effects when removing return statement
- suggest to replace void with Object in case when null is returned
- generateReturnValueFromVoidMethodInfo -> registerReturnValueFixes

GitOrigin-RevId: 0b068f00758fb1fd521f76a1da6964e114ef0853
This commit is contained in:
Artemiy Sartakov
2019-07-02 06:52:16 +03:00
committed by intellij-monorepo-bot
parent cd01ec6325
commit 117357c4db
17 changed files with 136 additions and 114 deletions
@@ -0,0 +1,12 @@
// "Delete return statement and extract side effects" "true"
class Test {
void foo(boolean b) {
getWithSideEffects(/*2*/);/*1*/
}
private String getWithSideEffects() {
System.out.println("baz");
}
}
@@ -1,4 +1,4 @@
// "Delete return value '"foo"'" "true"
// "Delete return value" "true"
class Test {
@@ -0,0 +1,16 @@
// "Delete return value and extract side effects" "true"
class Test {
void foo(boolean b) {
if (b) /*1*/ {
getWithSideEffects(/*3*/);
return /*2*/;
}
System.out.println("bar");
}
private String getWithSideEffects() {
System.out.println("baz");
}
}
@@ -1,4 +1,4 @@
// "Delete return value 'null'" "true"
// "Delete return value" "true"
class Test {
@@ -1,9 +1,9 @@
// "Delete return statement" "false"
// "Delete return statement and extract side effects" "true"
class Test {
void foo(boolean b) {
return<caret> getWithSideEffects();
return/*1*/<caret> getWithSideEffects(/*2*/);
}
private String getWithSideEffects() {
@@ -1,4 +1,4 @@
// "Delete return value '"foo"'" "true"
// "Delete return value" "true"
class Test {
@@ -1,9 +1,9 @@
// "Delete return statement" "false"
// "Delete return value and extract side effects" "true"
class Test {
void foo(boolean b) {
if (b) return<caret> getWithSideEffects();
if (b) /*1*/return ("foo"/*2*/) + <caret>getWithSideEffects(/*3*/);
System.out.println("bar");
}
@@ -1,4 +1,4 @@
// "Delete return value 'null'" "true"
// "Delete return value" "true"
class Test {
@@ -0,0 +1,8 @@
// "Make 'foo' return 'java.lang.Object'" "true"
class Test {
<caret><selection>Object</selection> foo() {
return null;
}
}
@@ -1,8 +0,0 @@
// "Change return type for method 'foo'" "true"
class Test {
<caret><selection>void</selection> foo() {
return null;
}
}
@@ -1,4 +1,4 @@
// "Change return type for method 'foo'" "true"
// "Make 'foo' return 'java.lang.Object'" "true"
class Test {