[spell-checker] Allow to provide custom name for spellchecker variants

Fixes IDEA-344686 Spellchecker: RenameTo QuickFix uses wrong name to generate suggestons objects in Scala

GitOrigin-RevId: 00f00a67dc9bd1eacaeea2890c7f07b6d037f0c7
This commit is contained in:
Tagir Valeev
2024-02-09 10:15:54 +01:00
committed by intellij-monorepo-bot
parent 95fab49390
commit 56b91582b2
2 changed files with 30 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Iconable;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNamedElement;
import com.intellij.psi.PsiNamedElementWithCustomPresentation;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.refactoring.rename.RenameUtil;
import com.intellij.spellchecker.SpellCheckerManager;
@@ -29,7 +30,7 @@ public class RenameTo extends PsiUpdateModCommandQuickFix implements Iconable {
protected void applyFix(@NotNull Project project, @NotNull PsiElement psiElement, @NotNull ModPsiUpdater updater) {
PsiNamedElement named = PsiTreeUtil.getNonStrictParentOfType(psiElement, PsiNamedElement.class);
if (named == null) return;
String name = named.getName();
String name = named instanceof PsiNamedElementWithCustomPresentation custom ? custom.getPresentationName() : named.getName();
if (name == null) return;
List<String> names = SpellCheckerManager.getInstance(project).getSuggestions(name)
.stream()