mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: fix inline renaming of lambda parameters with conflict (IDEA-377645)
GitOrigin-RevId: ddaf13469dc000dbeaab4fe1f25d1687d87237a5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b3fa4de450
commit
62575dc2aa
@@ -0,0 +1,10 @@
|
||||
class ConfictInLambdaParameter {
|
||||
public void consume(Consumer<Object> c) {
|
||||
}
|
||||
|
||||
public void bug() {
|
||||
consume(o -> { // line 1
|
||||
consume(o1<caret> -> {}); // line 2
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.refactoring;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -116,6 +116,12 @@ public class RenameLocalTest extends LightRefactoringTestCase {
|
||||
"Variable 's' Already Exists",
|
||||
() -> doTestInplaceRename("s"));
|
||||
}
|
||||
|
||||
public void testConflictInLambdaParameter() {
|
||||
assertThrows(BaseRefactoringProcessor.ConflictsInTestsException.class,
|
||||
"Variable 'o' Already Exists",
|
||||
() -> doTestInplaceRename("o"));
|
||||
}
|
||||
|
||||
public void testConflictWithFutureVar() {
|
||||
assertThrows(BaseRefactoringProcessor.ConflictsInTestsException.class,
|
||||
|
||||
@@ -999,6 +999,8 @@ com.intellij.refactoring.introduce.IntroduceTarget
|
||||
- a:render():java.lang.String
|
||||
com.intellij.refactoring.move.MoveCallback
|
||||
- a:refactoringCompleted():V
|
||||
c:com.intellij.refactoring.rename.inplace.VariableInplaceRenamer
|
||||
- p:checkLocalScope():com.intellij.psi.PsiElement
|
||||
com.intellij.refactoring.safeDelete.SafeDeleteDialog$Callback
|
||||
- a:run(com.intellij.refactoring.safeDelete.SafeDeleteDialog):V
|
||||
com.intellij.refactoring.safeDelete.SafeDeleteProcessorDelegate
|
||||
|
||||
+6
@@ -394,6 +394,12 @@ public class VariableInplaceRenamer extends InplaceRefactoring {
|
||||
myEditor.getCaretModel().moveToOffset(myOrigOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected @Nullable PsiElement checkLocalScope() {
|
||||
PsiElement scope = super.checkLocalScope();
|
||||
return scope != null && !(scope instanceof PsiFileSystemItem) ? scope.getParent() : scope;
|
||||
}
|
||||
|
||||
private @Nullable RangeHighlighter highlightConflictingElement(PsiElement conflictingElement) {
|
||||
if (conflictingElement != null) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user