mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:10:43 +07:00
[java-refactoring] Inline variable: ignore references from method calls
Fixes IDEA-356914 Exception in Inline variable on red code GitOrigin-RevId: ca785f72ba4b99fed0a0f3410a21df7dd13b7c5a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
eafd66854b
commit
655bf65a7d
@@ -374,6 +374,8 @@ public final class InlineLocalHandler extends JavaInlineActionHandler {
|
||||
final SmartPointerManager pointerManager = SmartPointerManager.getInstance(project);
|
||||
for (PsiElement element : refsToInline) {
|
||||
PsiJavaCodeReferenceElement refElement = (PsiJavaCodeReferenceElement)element;
|
||||
// Erroneous method call which is resolved to a local variable: simply skip it, otherwise we may create incorrect PSI
|
||||
if (refElement.getParent() instanceof PsiMethodCallExpression) continue;
|
||||
pointers.add(pointerManager.createSmartPsiElementPointer(InlineUtil.inlineVariable(local, defToInline, refElement)));
|
||||
}
|
||||
return pointers;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
public class LambdaInitialization {
|
||||
Runnable foo() {
|
||||
Runnable <caret>s = () -> {
|
||||
s();
|
||||
};
|
||||
return s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public class LambdaInitialization {
|
||||
Runnable foo() {
|
||||
return () -> {
|
||||
s();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -356,6 +356,8 @@ public class InlineLocalTest extends LightJavaCodeInsightTestCase {
|
||||
public void testCompositeAssignment() { doTest(); }
|
||||
|
||||
public void testCompositeAssignmentCast() { doTest(); }
|
||||
|
||||
public void testLambdaInitialization() { doTest(); }
|
||||
|
||||
private void doTest(String conflictMessage) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user