[Java. Intention Actions] IDEA-378080 Fix exception when renaming unnamed variables as lambda parameters

GitOrigin-RevId: 2e6173d4b11962c6197ff3216b68d11bcc1b7751
This commit is contained in:
Georgii Ustinov
2025-08-28 18:20:53 +00:00
committed by intellij-monorepo-bot
parent 740cb8a5bf
commit 84526c727c
4 changed files with 19 additions and 0 deletions
@@ -151,6 +151,7 @@ public class JavaRefactoringSupportProvider extends JavaBaseRefactoringSupportPr
SearchScope useScope = PsiSearchHelper.getInstance(elementToRename.getProject()).getUseScope(elementToRename);
if (!(useScope instanceof LocalSearchScope)) return false;
PsiElement[] scopeElements = ((LocalSearchScope)useScope).getScope();
if (scopeElements.length == 0 && elementToRename instanceof PsiVariable variable && variable.isUnnamed()) return true;
if (scopeElements.length > 1 && // assume there are no elements with use scopes with holes in them
!isElementWithComment(scopeElements) && // ... except a case of element and it's doc comment
!isResourceVariable(scopeElements)) {