[spellchecker] introduce CustomDictionarySettingsListener to get rid of hack in Rider (IJPL-189900)

Before, SpellCheckerSettingsManager extension was replaced by a patched variant in Rider. The new listener allows us to get rid of this hack, making it simpler to extract code related to spellchecker in a separate module in Rider (this is needed to extract intellij.spellchecker to a content module).

GitOrigin-RevId: 38f550b633c5596c41186dab9bff4fc5cc37fb9b
This commit is contained in:
Nikolay Chashnikov
2025-06-03 15:48:38 +02:00
committed by intellij-monorepo-bot
parent 772064c9c3
commit cf104126ff
2 changed files with 21 additions and 0 deletions

View File

@@ -31,6 +31,7 @@ import static java.util.Arrays.asList;
public final class CustomDictionariesPanel extends JPanel {
private final SpellCheckerSettings mySettings;
private final @NotNull Project myProject;
private final @NotNull SpellCheckerManager myManager;
private final CustomDictionariesTableView myCustomDictionariesTableView;
private final List<String> removedDictionaries = new ArrayList<>();
@@ -39,6 +40,7 @@ public final class CustomDictionariesPanel extends JPanel {
public CustomDictionariesPanel(@NotNull SpellCheckerSettings settings, @NotNull Project project, @NotNull SpellCheckerManager manager) {
mySettings = settings;
myProject = project;
myManager = manager;
defaultDictionaries = project.isDefault() ? new ArrayList<>() : asList(SpellCheckerBundle.message("app.dictionary"), SpellCheckerBundle
.message("project.dictionary"));
@@ -145,6 +147,7 @@ public final class CustomDictionariesPanel extends JPanel {
}));
mySettings.setCustomDictionariesPaths(newPaths);
myManager.updateBundledDictionaries(ContainerUtil.filter(oldPaths, o -> !newPaths.contains(o)));
myProject.getMessageBus().syncPublisher(CustomDictionarySettingsListener.CUSTOM_DICTIONARY_SETTINGS_TOPIC).customDictionaryPathsChanged(newPaths);
}
public List<String> getValues() {

View File

@@ -0,0 +1,18 @@
// 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.spellchecker.settings
import com.intellij.util.messages.Topic
import java.util.*
/**
* Provides notifications when custom dictionaries are changed in Settings.
*/
interface CustomDictionarySettingsListener : EventListener {
companion object {
@JvmField
@Topic.ProjectLevel
val CUSTOM_DICTIONARY_SETTINGS_TOPIC: Topic<CustomDictionarySettingsListener> = Topic(CustomDictionarySettingsListener::class.java, Topic.BroadcastDirection.NONE)
}
fun customDictionaryPathsChanged(newPaths: List<String>)
}