mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
inline: don't check containing method call if inline to method reference
This commit is contained in:
@@ -27,7 +27,6 @@ import com.intellij.psi.search.LocalSearchScope;
|
||||
import com.intellij.psi.search.searches.ReferencesSearch;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.intellij.psi.util.RedundantCastUtil;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
@@ -297,6 +296,7 @@ public class InlineUtil {
|
||||
|
||||
public static TailCallType getTailCallType(@NotNull final PsiReference psiReference) {
|
||||
PsiElement element = psiReference.getElement();
|
||||
if (element instanceof PsiMethodReferenceExpression) return TailCallType.None;
|
||||
PsiExpression methodCall = PsiTreeUtil.getParentOfType(element, PsiMethodCallExpression.class);
|
||||
if (methodCall == null) return TailCallType.None;
|
||||
if (methodCall.getParent() instanceof PsiReturnStatement) return TailCallType.Return;
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
import java.util.function.Supplier;
|
||||
class Foo {
|
||||
|
||||
static int m() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
void o(){
|
||||
mm(Foo::<caret>m);
|
||||
}
|
||||
|
||||
void mm(Supplier<Integer> r) {}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
import java.util.function.Supplier;
|
||||
class Foo {
|
||||
|
||||
void o(){
|
||||
mm(() -> 1);
|
||||
}
|
||||
|
||||
void mm(Supplier<Integer> r) {}
|
||||
}
|
||||
@@ -231,6 +231,10 @@ public class InlineMethodTest extends LightRefactoringTestCase {
|
||||
doTestConflict("Inline cannot be applied to multiline method in constructor call");
|
||||
}
|
||||
|
||||
public void testMethodReferenceInsideMethodCall() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTestConflict(final String conflict) throws Exception {
|
||||
try {
|
||||
doTest();
|
||||
|
||||
Reference in New Issue
Block a user