mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
wrap return value: ignore lambda return
This commit is contained in:
+1
-1
@@ -179,7 +179,7 @@ public class WrapReturnValueProcessor extends FixableUsagesRefactoringProcessor
|
||||
@Override
|
||||
public void visitReturnStatement(final PsiReturnStatement statement) {
|
||||
super.visitReturnStatement(statement);
|
||||
if (PsiTreeUtil.getParentOfType(statement, PsiMethod.class) != myMethod) return;
|
||||
if (PsiTreeUtil.getParentOfType(statement, PsiMethod.class, PsiLambdaExpression.class) != myMethod) return;
|
||||
final PsiExpression returnValue = statement.getReturnValue();
|
||||
if (returnValue != null) {
|
||||
returnTypes.add(returnValue.getType());
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
Wrapper foo() {
|
||||
I i = () -> {
|
||||
return 1;
|
||||
};
|
||||
return new Wrapper("");
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
Integer bar();
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Wrapper {
|
||||
String myField;
|
||||
Wrapper(String s) {
|
||||
myField = s;
|
||||
}
|
||||
|
||||
String getMyField() {
|
||||
return myField;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Test {
|
||||
String foo() {
|
||||
I i = () -> {
|
||||
return 1;
|
||||
};
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
interface I {
|
||||
Integer bar();
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class Wrapper {
|
||||
String myField;
|
||||
Wrapper(String s) {
|
||||
myField = s;
|
||||
}
|
||||
|
||||
String getMyField() {
|
||||
return myField;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.refactoring;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiField;
|
||||
@@ -55,6 +56,7 @@ public class WrapReturnValueTest extends MultiFileTestCase {
|
||||
public void testRawReturnType() { doTest(true, "Existing class does not have appropriate constructor"); }
|
||||
public void testReturnInsideLambda() { doTest(false, null, true); }
|
||||
public void testTypeAnnotations() { doTest(false); }
|
||||
public void testWithLambdaInside() { doTest(true); }
|
||||
|
||||
private void doTest(final boolean existing) {
|
||||
doTest(existing, null);
|
||||
|
||||
Reference in New Issue
Block a user