diff --git a/plugins/grazie/src/test/kotlin/com/intellij/grazie/ide/language/JavaSupportTest.kt b/plugins/grazie/src/test/kotlin/com/intellij/grazie/ide/language/JavaSupportTest.kt index 1d9a14726c01..2d5226734884 100644 --- a/plugins/grazie/src/test/kotlin/com/intellij/grazie/ide/language/JavaSupportTest.kt +++ b/plugins/grazie/src/test/kotlin/com/intellij/grazie/ide/language/JavaSupportTest.kt @@ -15,8 +15,6 @@ import com.intellij.spellchecker.settings.SpellCheckerSettings import com.intellij.testFramework.LightProjectDescriptor import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.tools.ide.metrics.benchmark.Benchmark -import com.intellij.ui.ChooserInterceptor -import com.intellij.ui.UiInterceptors import java.util.function.Consumer diff --git a/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java b/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java index 42f668b6f865..0c77a5e979a9 100644 --- a/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java +++ b/spellchecker/src/com/intellij/spellchecker/quickfixes/RenameTo.java @@ -28,6 +28,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.util.*; +import java.util.stream.Collectors; public class RenameTo extends IntentionAndQuickFixAction implements Iconable, EventTrackingIntentionAction { @@ -35,7 +36,7 @@ public class RenameTo extends IntentionAndQuickFixAction implements Iconable, Ev private final TextRange range; private final SmartPsiElementPointer pointer; private final SpellcheckerRateTracker tracker; - private final SequencedSet suggestions = new LinkedHashSet<>(); + private volatile List suggestions; private SmartPsiElementPointer namedPointer; public RenameTo(String typo, TextRange range, PsiElement psi, SpellcheckerRateTracker tracker) { @@ -103,8 +104,8 @@ public class RenameTo extends IntentionAndQuickFixAction implements Iconable, Ev } } - public static @Nls String getFixName(SequencedCollection suggestions) { - return suggestions.size() == 1 ? + public static @Nls String getFixName(List suggestions) { + return (suggestions != null && suggestions.size() == 1) ? SpellCheckerBundle.message("rename.to.0", suggestions.getFirst()) : SpellCheckerBundle.message("rename.to"); } @@ -131,13 +132,14 @@ public class RenameTo extends IntentionAndQuickFixAction implements Iconable, Ev } private void generateSuggestions(String name, PsiElement element) { - if (suggestions.isEmpty()) { + if (suggestions == null) { TextRange range = this.range.shiftLeft(element.getText().indexOf(name)); - SpellCheckerManager.getInstance(pointer.getProject()).getSuggestions(typo) + this.suggestions = SpellCheckerManager.getInstance(pointer.getProject()).getSuggestions(typo) .stream() .map(suggestion -> range.replace(name, suggestion)) .filter(suggestion -> RenameUtil.isValidName(element.getProject(), element, suggestion)) - .forEach(suggestions::add); + .distinct() + .toList(); } }